[Tutor] Little problem with math module

Tiago Katcipis katcipis at inf.ufsc.br
Mon Apr 21 05:31:24 CEST 2008


ops, now i realize the mistake i was making. Thanks for the help people

Tiago Katcipis escreveu:
> 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? =/
>
> thanks to everyone who tries do help
>
> best regards
>
> katcipis
>
>   



More information about the Tutor mailing list