cube root of negative numbers gets complex numbers? Is it a bug?
25 views (last 30 days)
Show older comments
For example, cube root of -8 gets 1.0000 + 1.7321i, which should be -2 from the common sense.
0 Comments
Answers (1)
Roger Stafford
on 20 Apr 2017
Edited: Roger Stafford
on 20 Apr 2017
It's not a bug. That complex value is one of the three valid cube roots of -8. If you want to get the real -2 value, use the 'nthroot' function:
https://www.mathworks.com/help/matlab/ref/nthroot.html
x = nthroot(-8,3) ---> -2
0 Comments
See Also
Categories
Find more on Manage Products 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!