normal logarithm imaginary number problem
2 views (last 30 days)
Show older comments
Hello,
i have a problem. If i want to calculate the normal logarithm with an exponent.
(log(0.5))^(1/1.55)
or
(-0.6931)^(1/1.55)
matlab results:
-0.3477 + 0.7087i
but I want an other result. If I write the equation on this way:
-0.6931^(1/1.55)
matlab results
-0.7894
Why is there a difference? The normal logarithm of 0.5 is -0.6931 and with an exponent of (1/1.55) my calculator show 0.7894 (not -0,7894 or -0.3477 + 0.7087i).
I need this (x=0.5)
(log(x))^(1/1.55)= 0.7894
0 Comments
Accepted Answer
Stephen23
on 17 Feb 2015
Edited: Stephen23
on 17 Feb 2015
"Why is there a difference": because the order of operations is different. In particular, the ^ has a higher priority over the -, so the calculations are actually different. With the brackets these are all equivalent:
(log(0.5))^(1/1.55)
= (-0.6931)^(1/1.55)
= (-0.6931)^0.6452
= -0.3477 + 0.7087i
Whereas according to standard order of operations rules, without the brackets the following are equivalent:
-0.6931^(1/1.55)
= -(0.6931^(1/1.55))
= -(0.6931^0.6452)
= -(0.7894)
= -0.7894
If you want to get 0.7894, then you can simply take the absolute value:
>> abs(log(0.5))^(1/1.55)
ans = 0.7894
And if you need to keep the sign as well:
>> x = 0.5;
>> sign(log(x)) * abs(log(x))^(1/1.55)
ans = -0.7894
0 Comments
More Answers (0)
See Also
Categories
Find more on Performance and Memory 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!