Python Forum
pow function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: pow function (/thread-12777.html)



pow function - luoheng - Sep-12-2018

hi,
I met a problem when using the built-in function pow().
here is the code:
In [1]: pow(-2, 1/3)
Out [1]: (0.6299605249474367+1.0911236359717214j)
In [2]: (-2) ** 1/3
Out [2]: -0.6666666666666666
The document says pow(x, y) is equivalent to x ** y, but it is different here.
Why??
I use python3.6, anaconda Spyder.


RE: pow function - Gribouillis - Sep-12-2018

Operator precedence implies that
>>> (-2) ** 1/3 == ((-2) ** 1)/3
True
which is different from (-2) ** (1/3)