Why it comes up with the imaginary number?

28 views (last 30 days)
I found a very simple calculation but two different results:
1) -0.6^0.1 = 0.9502
2)
g=-0.6;
gg=0.1
g.^gg = 0.9037 + 0.2936i
Does anyone have an idea what's going on here?

Accepted Answer

Star Strider
Star Strider on 16 Sep 2022
The first raises 0.6 to the 0.1 power, then negates it.
The second takes -0.6 to the 0.1 power, and taking a non-integer power of a negative value creates a complex result.
G1 = -0.6^0.1
G1 = -0.9502
G2 = (-0.6)^0.1
G2 = 0.9037 + 0.2936i
.
  4 Comments
James Tursa
James Tursa on 22 Sep 2022
Also note that raising a negative number to a fractional power is actually multi-valued, and MATLAB only gives one of the possible results. Rearranging calculations into something that looks mathematically the same can often result in a different answer in these situations. E.g., a few of the possibilities for this specific example:
format longg
x1 = (-0.6)^0.1
x1 =
0.903694107692789 + 0.293628014959008i
x2 = 0.6^0.1 * exp(pi*i/10)
x2 =
0.903694107692789 + 0.293628014959008i
x3 = 0.6^0.1 * exp(3*pi*i/10)
x3 =
0.558513673987152 + 0.768728123211847i
x4 = 0.6^0.1 * exp(5*pi*i/10)
x4 =
5.81829826846399e-17 + 0.950200216505676i
x1^10
ans =
-0.6
x2^10
ans =
-0.6
x3^10
ans =
-0.6 - 5.55111512312578e-17i
x4^10
ans =
-0.6 + 3.67394039744206e-16i
All of x1, x2, x3, and x4 are 10th roots of -0.6. In this case, x3 and x4 suffer a bit of round-off error in the calculations, but they get essentially the same answer as x1 and x2 when raised to the power of 10.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!