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
Or, instead of n(): >>> expand_complex(root(-8, 3)) 1 + sqrt(3)*I This is a question of definitions and conventions: The cite: http://mathworld.wolfram.com/CubeRoot.html """ The schoolbook definition of the cube root of a negative number is (-x)^(1/3) = - (x)^(1/3). However, extension of the cube root into the complex plane gives a branch cut along the negative real axis for the principal value of the cube root. By convention, "the" (principal) cube root is therefore a complex number with positive imaginary part. As a result, Mathematica and other symbolic algebra programs that return results valid over the entire complex plane therefore return complex results for (-1)^(1/3). For example, in Mathematica, ComplexExpand[(-1)^(1/3)] gives the result 1/2 + i*sqrt(3)/2. """ Also """ Informally, the term "principal root" is often used to refer to the root of unity having smallest positive complex argument. """ Wolfram alpha gives the same: http://www.wolframalpha.com/input/?i=%28-8%29%5E%281%2F3%29 So I see, that SymPy follows the Mathematica. (Although it is not standard gauge) 1. SymPy assumes that results valid over the entire complex plane. (This is a global assumption) 2. SymPy has 'expand_complex' function, to clarify the excat value of "principal roots" 3. And also. I suppose, that the common rule is: to use common expression (-1)^(1/3) in the intermediate expressions as long as possible, and use the concrete value in complex as late as possible. (But it is not used when we calculate roots of positive 1.) > > 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 > > 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) > The last, I think, is a question, what the expression is simpler: (-9)**(1/3) or 3**(2/3) * (-1)**(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? > Although I am not sure about above conversions (the questions are about above rule (3) for even principal roots for positive and negative numbers, and principal roots of positive unity which are exp(2*pi*i/n), But I rely upon Mathematica's conversions, so I think we might leave it as it is now. -- Alexey U. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.