Why it comes up with the imaginary number?
28 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
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
G2 = (-0.6)^0.1
.
4 Comments
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
x2 = 0.6^0.1 * exp(pi*i/10)
x3 = 0.6^0.1 * exp(3*pi*i/10)
x4 = 0.6^0.1 * exp(5*pi*i/10)
x1^10
x2^10
x3^10
x4^10
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.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!