In PR 8814 I write,
Something has to be done to allow one to compute real_root(float, odd) as real. At first I thought to handle this in real_root, but then I thought it might be better to catch it in _eval_power itself. Which do you think is better:
# This is how a negative rational base behaves: >>> root(S('-1/10'),3) (-1)**(1/3)*10**(2/3)/10 # Now, for a negative float... >>> root(S('-.1'),3) 0.464158883361278*(-1)**(1/3) # <-- should a negative float give this (a) >>> _.n() 0.232079441680639 + 0.401973384383085*I # <-- or this (b)?
The SymPy trend is to fully evaluate an expression if args are numbers, but by selecting the principle root in the case of Pow, the user looses the option to select the real branch post-calc. (Hence, I favor not fully evaluating in this case, selecting behavior (a).) If the power is not an odd rational, the usual, fully evaluated result is obtained.
/c
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/da5b3c19-ef67-4bcd-b5c3-b6c167bd378d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
By allowing the (-1)**(1/3) to remain we leave open (as with Rational bases) the option of getting to the real root with real_root. I wish we had a good mechanism to check if something like root(x, 3) + 2 == 0 when substituting in -8 for x. It is for this reason that the following returns no solution:>>> solve(root(x,3)+2)[]
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/5dd074d2-2156-41e0-a6e0-ed6e0d3e8771%40googlegroups.com.