MATLAB: How is (-2)^(2/3) different than ((-2)^2)^(1/3)


Hi everybody.
It's the first time I ask a question here.
I would like to understand how is that possible that the following expressions give different results:
>> (-2)^(2/3)
ans =
-0.7937 + 1.3747i
>> ((-2)^2)^(1/3)
ans =

Best Answer

  • This seeming inconsistency is due to the fact that ideally each of these two expressions has three roots or values and these are the same values, namely the three "cube roots of unity" times the real value 2^(2/3). They are:
    +2^(2/3) = 1.5874
    -1/2^(1/3)+3^(1/2)/2^(1/3)*i = -0.7937 + 1.3747*i
    -1/2^(1/3)-3^(1/2)/2^(1/3)*i = -0.7937 - 1.3747*i
    It would generally be an inconvenience if matlab always returned all three each time, so it chooses to give what is regarded as a "principal" value and this depends on the form of the expression. In your case your two different expression forms, though equivalent mathematically, had different principal forms and thus received different values.
    This is similar to the situation with 4^(1/2) which has two roots, +2 and -2. It would be inconvenient for most purposes if both were returned by matlab, so only +2 is returned. If you write it as
    4^(1/2) = ((-2)*(-2))^(1/2) = ((-2)^(1/2))*((-2)^(1/2))
    you can trick it into giving you -2 as the answer.