cube root of negative numbers gets complex numbers? Is it a bug?

25 views (last 30 days)
For example, cube root of -8 gets 1.0000 + 1.7321i, which should be -2 from the common sense.

Answers (1)

Roger Stafford
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 Manage Products in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!