abs and plot problems [closed]

asked 2019-10-22 09:26:20 -0600

cedrik0s gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by tmonteil
close date 2019-10-22 09:37:31.228277