abs and plot problem
Hi there. Using Cocalc, I am encountering problems trying to plot some functions. The following simple example shows how I am able to plot the modulus of a simple function using my own modulus function, but how it fails using abs(). Which is really weird.
_ = var('a,x')
MODULUS(x) = sqrt(real(x)^2 + imag(x)^2)
Hmod = MODULUS(ax + ix^2)
Habs = abs(ax + ix^2)
plot([Hmod(a=n) for n in [1..5]], (x,0, 2))
plot([Habs(a=n) for n in [1..5]], (x,0, 2))
Hmod can be plotted, while Habs will return "TypeError: unable to coerce to a real number".
On the other hand the following works:
plot(Habs(a=1), (x,0, 2))
So it works without list comprehension and with my MODULUS function... Don't know what to think of that.
Anyone can help on that? I have seriously more complicated cases that I seem to be unable to plot because of this very problem. Thanks a lot.
Strange. This works
but this fails
@FredericC: yes that's really weird, and it actually looks a bit random. I have had your second line work some time and others not... but I can't figure what to do to make it work (or not) systematically...