[Matrix-SIG] Power of trigs
Thu, 19 Mar 1998 15:32:25 -0000
From: Dave Stinchcombe <firstname.lastname@example.org>
To: email@example.com <firstname.lastname@example.org>
Date: 19 March 1998 11:49
Subject: [Matrix-SIG] Power of trigs
>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.
Decision seems to be simple in this case -
just convert explicitly first argument to a complex number format:
>>> pow(-1, 1.0)
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: negative number to float power
But I am glad to rise again the question of weak argument's checking in
I do not want always to check validity of all possible combinations of input
I just want pow() to return most suitable and valid result.