Tiago Katcipis wrote:
> im not understanding why is this a problem...i have this simple function
> 
> def newton_divergente(x): 
>   return math.pow(x, 1.0/3.0)
> 
> but when x = -20 it returns this error
> 
> return math.pow(x, 1.0/3.0)
> ValueError: math domain error
> 
> but why is that? is it impossible to calculate -20 ^ (1/3) ?
> 
> here on my calculator i get the result -6,666666667, but python seens to
> dont now the answer, why? am i doing something wrong? =/

Your calculator is not doing so well either since

In [15]: -6.666666667**3
Out[15]: -296.29629634074081

but this seems to work:
In [13]: -20**(1./3.)
Out[13]: -2.7144176165949063

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to