trouble with complex numbers

Dr. Phillip M. Feldman pfeldman at verizon.net
Wed Aug 5 16:16:31 EDT 2009


I am using Python 2.5, and most of the cmath functions are not yet available
in this version.  Thanks!

Phillip

P.S. In your code, that should be x+= 0J

P.P.S. I wish that the documentation indicated anything that is new.


Christian Heimes-2 wrote:
> 
> <snip>
> 
> phase() has been added to Python 2.6 and 3.0. It's not available in 
> Python 2.5 and earlier. If you'd used cmath.phase() instead of the ugly 
> "from cmath import *" statement you'd have seen the correct error message.
> 
> You can write your own phase() function. This function is mostly correct 
> unless either the real and/or the imag part is NaN or INF.
> 
> from math import atan2
> 
> def phase(z):
>      z += 1j # convert int, long, float to complex
>      return atan2(z.imag, z.real)
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: http://www.nabble.com/trouble-with-complex-numbers-tp24821423p24835436.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list