[SciPy-user] casting complex numbers
Ryan Krauss
ryanlists at gmail.com
Thu Feb 16 22:33:41 CST 2006
Is there a way to make python return a complex number number instead
of nan when taking the sqrt of a negative float? I have an
automatically generated function based on Maxima symbolic output that
is giving bad output because of this. Basically, part of the symoblic
expression includes sqrt(-s**2*x) where s is complex and this
expression would evaluate nicely in python. For whatever reason,
Maxima prefers to output this expression as sqrt(-x)*s, which would
also evaluate correctly if sqrt(-x) gave 1.0j*sqrt(x), but since x is
a float it is returning nan. I am hoping for flag similar to from
__future__ import division instead of having to declare all my
variables as complex.
Thanks,
Ryan
More information about the SciPy-user
mailing list