[Matrix-SIG] Power of trigs

Paul F. Dubois Paul F. Dubois" <dubois1@llnl.gov
Thu, 19 Mar 1998 07:25:51 -0800


Complex literals are of the form n.nnnn j. In this case, Numeric needs you
to help it know that you want a complex power.

>>> import Numeric
>>> Numeric.power(2., .5)
1.41421356237
>>> Numeric.power(-2.0, .5)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: math domain error
>>> Numeric.power(-2.0+0j, .5)
(8.65927457072e-017+1.41421356237j)
>>>


-----Original Message-----
From: Dave Stinchcombe <dars@soton.ac.uk>
To: matrix-sig@python.org <matrix-sig@python.org>
Date: Thursday, March 19, 1998 3:48 AM
Subject: [Matrix-SIG] Power of trigs


>Hi again,
>This morning I needed to write a quick and easy root finder, so obviously I
>grabbed Numeric Python.
>
>I have a problem though. I wrote the line:
>Numeric.power(Numeric.cos(phi),1-2*nus)
>
>where nus is a constant of 0.3. phi is an array holding a list of values
>I'm searching through. The problem comes that this line fails when phi is
>greater than pi/2.
>
>Now obviously this is due to the fact I'm trying to calculate a complex (or
>at the very least an imaginary) number. But I want to. Can any one give
>some suggestions as to how to cope, or in some way make python also believe
>in complex numbers.
>
>Yours
>Dave
>
>
>
>------------------------------------------------------
>Matrix-SIG maillist  -  Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>