## Could this Be a Bug in V.11.1.1.0

-1

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.11.1.1.0?

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).

Question was closed 2018-03-16T06:00:29.057

Please do not use the [tag:bugs] tag when posting new questions. See the tag description for further explanation. – Szabolcs – 2018-03-15T17:03:27.937

2Also, this is not a bug. You're looking for CubeRoot. -8^(1/3) is equivalent to -(8^(1/3)) – Szabolcs – 2018-03-15T17:04:17.607

4only Microsoft Excel takes -x^n to mean (-x)^n – george2079 – 2018-03-15T17:16:53.370

@Szabolcs. Thank you for updating the tag. I used this example because we all know the cube root of -8 is -2. Why would Mathematica interpret -8^(1/3) and (-8)^(1/3) differently? – D. Andrew – 2018-03-15T17:17:28.077

At Szabolcs. I would really appreciate if the typos or syntax error in the question above is pointed out rather than being closed off as an off-topic. I don't seem to find any. Type1 and type2 formats are some of the general ways one would write an equation like this. Thank you. – D. Andrew – 2018-03-15T19:35:45.463

2

@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.

– Szabolcs – 2018-03-15T19:36:54.967

@Szabolcs, do you see the edited question? – D. Andrew – 2018-03-15T19:39:23.697

@Szabolcs, I mean the question that inspired the Cuberoot question. This was a calculation I was doing to obtain Telles Points from some Guass Points. How differrently could I have written type1 and type2 expressions to avoid the kind of results Mathematica gave for both types? – D. Andrew – 2018-03-15T19:50:53.123

1@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. – Szabolcs – 2018-03-15T20:47:02.300

@Szabolcs. Thank you for your response. Yes, CubeRoot[x] is sufficient for -8. But you wont typically write complicated expressions with CubeRoot[.....]. Type1 and Type2 formats would be how you write those equations normally. I'm looking at a general situation here, whereby you have no idea an intermediate negative value will be generated during calculation and you need to take the cuberoot of such number. We will not always be able to pull apart expressions as I did with expression in type2 ans 3. Parenthenses is one way we will typically set precedences for our expressions. – D. Andrew – 2018-03-16T01:32:11.747

1"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). – J. M.'s ennui – 2018-03-16T05:56:07.710

5

Precedence.

FullForm[Hold[-8^(1/3)]]
FullForm[Hold[-(8^(1/3))]]
FullForm[Hold[(-8)^(1/3)]]
(* 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.

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.
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! – D. Andrew – 2018-03-16T01:07:31.970
1For 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. – John Doty – 2018-03-16T02:49:04.563