Home > Net >  (-8)^(-2/3) returns wrong result
(-8)^(-2/3) returns wrong result

Time:11-14

I'm using Matlab R2020b (Mac OS 12.0.1).

When I enter (-8)^(-2/3), it returns:

ans =

  -0.1250 - 0.2165i

Shouldn't it be 0.2500, instead?

CodePudding user response:

Depends on the order of calculation.

(-8)^(-2/3) means divide -2 by 3 and then raise -8 to that power.

But if you do ((-8)^(-2))^(1/3) or nthroot((-8)^(-2),3) instead, you'll get 0.25.

CodePudding user response:

Raising negative numbers to fractional powers is a complex multi-valued operation. MATLAB is simply picking one of the solutions for you. E.g., for the solutions to (-8)^(1/3). start with the roots to the following polynomial equation:

x^3 8=0

Using MATLAB for this:

>> roots([1 0 0 8])
ans =
  -2.0000   0.0000i
   1.0000   1.7321i
   1.0000 - 1.7321i

Then raising this result to the -2 power yields:

>> ans.^-2
ans =
   0.2500   0.0000i
  -0.1250 - 0.2165i
  -0.1250   0.2165i

MATLAB happened to give you the second solution above for the (-8)^(-2/3) calculation.

BOTTOM LINE: Whenever you are dealing with complex multi-valued operations, if you want specific results you will need to account for that in your code, because MATLAB might pick something else.

  • Related