[Matrix-SIG] Power of trigs

Tim Hochberg hochberg@wwa.com
Thu, 19 Mar 1998 09:17:08 -0600

From: Dave Stinchcombe <dars@soton.ac.uk>

>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:
>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.

Power will return complex numbers if one of the arguments is complex,
otherwise it assumes you want a real answer and raises an exception. Two
things that should work to convince power that you mean business are:

power(cos(phi)+0j, 1-2*nus)
power(cos(phi).astype(Complex), 1-2*nus)