[SciPy-User] numpy array root operation

David Warde-Farley wardefar@iro.umontreal...
Wed Mar 21 22:31:13 CDT 2012


On 2012-03-21, at 10:43 PM, Odin Den wrote:

>>>> -32**(1/5)
>>>> -2.0

I just noticed that this was probably a REPL prompt (my mail client shows it as quotation indentation, which failed to register in my mind).

You have your order of operations wrong. Exponentiation is higher priority than multiplication (i.e. the unary -) so what you are getting is -1 * (32 ** (1/5)).

>>> (-32)**(1/5.)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: negative number cannot be raised to a fractional power



More information about the SciPy-User mailing list