2019-10-23 19:19:48 +0200 | received badge | ● Student (source) |
2019-10-22 18:04:34 +0200 | commented question | abs and plot problem @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... |
2019-10-22 16:37:08 +0200 | asked a question | 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. |
2019-10-22 16:37:08 +0200 | asked a question | abs and plot problems Hi there. I am encountering problems trying to plot some functions. The following example shows how I am able to plot the modulus of a simple function using my own modulus function, but 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". 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. |