pow function
5013 3 0- mosari
- Member
- 30 posts
- Joined: July 2010
- Offline
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Offline
- mark
- Staff
- 2592 posts
- Joined: July 2005
- Offline
mosari
The pow function raise error with non integer exponent. how could I compute something like pow(x,0.3)
>>> import math
>>> math.pow(3, .3)
1.3903891703159093
>>> math.pow(-3, .3)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ValueError: math domain error
When you have a rational exponent (i.e. a non integer), the expression is equivalent to… well, let's see how my ASCII art is:
(m/n) n —–
a = \ / (m)
\/ a
That is, the nth root of (pow(a, m)).
Since radicals are ill defined when the base is negative, you end up
with imaginary results. Which might prove difficult.
For example: pow(-5, 0.5) == sqrt(-5)
I assume this is your problem?
- mosari
- Member
- 30 posts
- Joined: July 2010
- Offline
-
- Quick Links