cube root of negative numbers gets complex numbers? Is it a bug?
Show older comments
For example, cube root of -8 gets 1.0000 + 1.7321i, which should be -2 from the common sense.
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
Categories
Find more on Region and Image Properties 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!