Plotting....

10 views
Skip to first unread message

Michel

unread,
Dec 6, 2009, 2:27:44 AM12/6/09
to sage-support
I never have any luck with plotting in Sage. The simplest plots fail.
For example the following

plot(20*log(abs((1+I*x)^4+4),10),(x,0,3))

fails with

TypeError: float() argument must be a string or a number

I don't see what's wrong with it.

Laurent

unread,
Dec 6, 2009, 4:17:26 AM12/6/09
to sage-s...@googlegroups.com
Michel ha scripte:
> I never have any luck with plotting in Sage. The simplest plots fail.
> For example the following
>
> plot(20*log(abs((1+I*x)^4+4),10),(x,0,3))
>
The answer of this
f(x) = abs((1+I*x)**4+4)
f(1)
is 0.

Then the logarithm produces -infinity.
Maybe your parenthesis of abs are wrong. Chuck Norris can plot that
function on a interval which contains 1, but Sage cannot.

Laurent


Francois Maltey

unread,
Dec 6, 2009, 8:38:34 AM12/6/09
to sage-s...@googlegroups.com
Hello Laurent and Michel ! [Maybe french users...]


>> I never have any luck with plotting in Sage. The simplest plots fail.
>> For example the following
>>
>> plot(20*log(abs((1+I*x)^4+4),10),(x,0,3))
>>
>>
> The answer of this
> f(x) = abs((1+I*x)**4+4)
> f(1)
> is 0.
>
> Then the logarithm produces -infinity
I found also this error in some case, it's possible to go arround by a
lambda function.
This is the method in maple or mupad with -> in plot (t->tan(t),
t=0..10) against plot (tan(t), t=0..10)


In my sage-4.2 plot (lambda x : 20*log(abs(1+I*x), 10), (x,0,4)) seems
perfectly right.


Fran�ois

Michel

unread,
Dec 6, 2009, 4:51:18 PM12/6/09
to sage-support
Thanks for the reply. But no. The problem is not due to the fact that
the function has a singularity. Indeed.

plot(20*log(abs((1+I*x)^4),10),(x,0,3))

fails with the same error which is incomprehensible to me.

On the other hand turning the expression into a lambda function made
it possible to plot it. Thanks for this practical advice.

I wish someone could explain this rationally to me.

20*log(abs((1+I*x)^4),10)

seems to be a perfectly fine symbolic expression so IMHO it should be
possible to plot it.

William Stein

unread,
Dec 6, 2009, 5:30:45 PM12/6/09
to sage-support
This is a bug. There absolutely no reason that plotting should give the error
"float() argument must be a string or a number".
We could give an error about not being able to evaluate the function at certain
points. However, the above error is not OK. The error in fact is
not in plotting
but in making a fast_float compiled version of the expression:

sage: s = 20*log(abs((1+I*x)^4),10)
sage: fast_float(s,x)
Traceback (most recent call last):
...
TypeError: float() argument must be a string or a number

In fact, SAge *should* be using fast_callable, not fast_float. This
works just fine if you force it manually:

s = 20*log(abs((1+I*x)^4),10)
plot(fast_callable(s,vars=[x]), (x,0,3))
[[nice picture as output]]

Many, many thanks for your bug report. It is bug reports from users
like you that really helps Sage to be a first-rate mathematical
software system.

We are now tracing this issue at 7614:

http://trac.sagemath.org/sage_trac/ticket/7614

William

Jason Grout

unread,
Dec 7, 2009, 6:42:59 AM12/7/09
to sage-s...@googlegroups.com
Yes, but there are still some issues with plotting assuming the defaults
provided by fast_float that are not implemented in fast_callable. So
fast_callable needs to be improved before switching to it. See
http://trac.sagemath.org/sage_trac/ticket/5572

This is noted on the new ticket from this thread.

Thanks,

Jason



--
Jason Grout

kcrisman

unread,
Dec 7, 2009, 7:03:37 AM12/7/09
to sage-support


On Dec 6, 5:30 pm, William Stein <wst...@gmail.com> wrote:
Thank goodness. I have run into this (and reported it on this list)
at least twice before :)

- kcrisman

Francois Maltey

unread,
Dec 7, 2009, 7:29:51 AM12/7/09
to sage-s...@googlegroups.com
Hello,

This bug feels very similar to 7614 (not 7165) and so 5572.

http://trac.sagemath.org/sage_trac/ticket/7165


Reply all
Reply to author
Forward
0 new messages