Python Forum
Negative numbers and fractional powers - 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: Negative numbers and fractional powers (/thread-1153.html)



Negative numbers and fractional powers - Flexico - Dec-08-2016

Python doesn't like it when I ask it things like, (-6)**(1/3). I can at least get some answer by changing it to (-6+0j)**(1/3), and it gives me a complex answer, but that's not quite complete, because in the complex plane, numbers have three cube roots. I can get multiple roots usingĀ [mpmath.root(a,b,k) for k in range(b)] (returning a**(1/b)), but that only works for whole-number roots, rather than arbitrary real exponents.

Is there a function out there somewhere that can give me every solution to an arbitrary a**b? I already use Sympy, so it would be great if it could work symbolically to give exact answers.


RE: Negative numbers and fractional powers - Larz60+ - Dec-08-2016

possibly Sage?
http://www.sagemath.org/