trouble with complex numbers
Chris Rebert
clp2 at rebertia.com
Wed Aug 5 04:40:59 EDT 2009
On Tue, Aug 4, 2009 at 11:28 PM, Dr. Phillip M.
Feldman<pfeldman at verizon.net> wrote:
>
> When I try to compute the phase of a complex number, I get an error message:
>
> In [3]: from cmath import *
> In [4]: x=1+1J
> In [5]: phase(x)
> <snip>
> NameError: name 'phase' is not defined
> <snip>
> AttributeError: 'complex' object has no attribute 'phase'
I suspect the problem lies in what you snipped away:
In [1]: from cmath import phase
In [2]: x=1+1J
In [3]: phase(x)
Out[3]: 0.78539816339744828
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list