This question already has an answer here:

Here is an elementary third root calculation of -8 (or any negative real number) with and without parentheses, but Mathematica seems to be given different answers!

In[1]:= -8^(1/3) // N
Out[1]= -2.
In[2]:= (-8)^(1/3) // N,
Out[2]= 1. + 1.73205 I,
In[3]:= (8)^(1/3) // N
Out[3]= 2.
In[4]:= 8^(1/3) // N
Out[4]= 2.

I noticed this weird behaviour when I was trying to compute Telles transformation points from some Gauss points. My set up required using nested parentheses, but it turned out after several tries I have to examine each component of my equation only to notice this strange behaviour with and without parentheses. Could this be a bug in V.

The question above was motivated by this basic computation

type1: k = (e (e^2 - 1) + Abs[e^2 - 1])^(1/3) + (e (e^2 - 1) - 
  Abs[e^2 - 1])^(1/3) + e /. e -> -0.861136
a1 = e (e^2 - 1) /. e -> -0.861136;
a2 = Abs[e^2 - 1] /. e -> -0.861136;
type2: k = (a1 + a2)^(1/3) + (a1 - a2)^(1/3) - 0.861136
type3: k = CubeRoot[a1 + a2] + CubeRoot[a1 - a2] - 0.861136

0.0873074 + 0.28566 I (type1 output)

0.0873074 + 0.28566 I (type2 output)

-0.407471(type3 output)

Typically one would write out equations in the type1 or type2 formats especially if you have more complicated functions to deal with. I am not sure why type1 and type2 are not giving the expected answer (type3).


marked as duplicate by J. M. is away Mar 16 '18 at 6:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Also, this is not a bug. You're looking for CubeRoot. -8^(1/3) is equivalent to -(8^(1/3)) $\endgroup$ – Szabolcs Mar 15 '18 at 17:04
  • 4
    $\begingroup$ only Microsoft Excel takes -x^n to mean (-x)^n $\endgroup$ – george2079 Mar 15 '18 at 17:16
  • 2
    $\begingroup$ @D.Andrew "we all know the cube root of -8 is -2" The equation $x^3=-8$ has three complex solutions. The one conventionally taken to be $(-8)^{1/3}$ (i.e. the principal root) is $1 + i \sqrt{3}$, when working with complex numbers. Only when restricting ourselves to reals do we take $-2$. This (the real cube root) is imlpemented as CubeRoot in Mathematica. $\endgroup$ – Szabolcs Mar 15 '18 at 19:36
  • 1
    $\begingroup$ @D.Andrew I'm sorry, I don't understand. Is it not sufficient for you to use CubeRoot[x] instead of x^(1/3)? If not, can you explain why not? As for closing the question: there is of course no typo. This is a templated close reason which is used in cases when the question is the result of misunderstanding or mistake that is trivial or not related to Mathematica (e.g. purely mathematical, as in this case). People are not trying to deny you an answer. If you still have a practical, Mathematica-related problem, please describe it. $\endgroup$ – Szabolcs Mar 15 '18 at 20:47
  • 1
    $\begingroup$ "But you wont typically write complicated expressions with CubeRoot[.....]." - well, it happens that in your application, you don't want the principal root when a lot of other people do want it as the result of computing x^(1/3), so you do need to make it a bit "complicated" (i.e. using CubeRoot[] instead). $\endgroup$ – J. M. is away Mar 16 '18 at 5:56


(* Hold[Times[-1,Power[8,Times[1,Power[3,-1]]]]] *)
(* Hold[Times[-1,Power[8,Times[1,Power[3,-1]]]]] *)
(* Hold[Power[-8,Times[1,Power[3,-1]]]] *)

Note that the first two are the same, the third is different.

Added edit:

Your type3 is not the expected answer: fractional powers of negative numbers are generally complex in Mathematica. You got it accidentally when you negated the power of a positive number by not respecting precedence. Use Surd or CubeRoot to get type3.

  • $\begingroup$ At John. Thank you for your response. I get the precedence stuff. But Cuberoot[-8] gave -2 and even Cuberoot[(-8)] still give -2. My main concern is how do you then write complicated functions whose intermediate values will give a negative number and subsequently you need to get a Cuberoot of such number? You cannot always pull apart the expressions as I did in type2 and type3. How do you then know if your calculated values are accurate? Looking at type 1 and type 2 eqns, how would you write it differently to get a real number? I can tell for a fact the answer should not be complex! $\endgroup$ – D. Andrew Mar 16 '18 at 1:07
  • $\begingroup$ I'm looking at a general issue here. I just wanted to be sure that the output I'm getting are accurate when dealing with roots. $\endgroup$ – D. Andrew Mar 16 '18 at 1:09
  • 1
    $\begingroup$ For a negative number, if you want its cube root's complex "principal value", take the 1/3 power. If you want the real value, use CubeRoot. The complex conjugate of the principal value is also a root. These are all accurate roots: cube any of them and you'll get the original number back. Which one to use, or perhaps all three, depends on what you're trying to accomplish. Remember that intermediate results may need to be complex even in a real problem, that's just how algebra works. $\endgroup$ – John Doty Mar 16 '18 at 2:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.