09.01.2012 02:03, smichr пишет:
> Is there any reason that we should return something other than -2 for
> the cube root of -8?
>
>>>> root(-8,3)
> 2*(-1)**(1/3)
>>>> _.n()
> 1.0 + 1.73205080756888*I
>
> Of course real_root was written to work around this, but if odd powers
> just removed a simple negative it wouldn't be necessary.
>
>>>> real_root(-8,3)
> -2
>
I wanted to add that it will be better to have special method that
transform common expression like this:
>>> root(-8,3)
2*(-1)**(1/3)
to the concrete real value.
But, fortunately, the same method 'real_root' does it fine:
>>> real_root(root(-8,3))
-2
More over, this case sufficiently documented.
--
Alexey U.
> Note that the -1 does not always appear raised to the fractional
> power:
>
>>>> root(-8,3)
> 2*(-1)**(1/3)
>>>> root(-9,3)
> (-9)**(1/3)
>
> When I make the change to make things like root(-8, 3) return -2, no
> tests fail. Is this a change we should make?
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.