Matlab wrong cube root [closed]

Solution 1:

In the following I'll assume that $n$ is odd, $n>2$, and $x<0$.

When asked for $\sqrt[n]{x}$, MATLAB will prefer to give you the principal root in the complex plane, which in this context will be a complex number in the first quadrant. MATLAB does this basically because the principal root is the most convenient one for finding all of the other complex roots.

You can dodge this issue entirely by taking $-\sqrt[n]{-x}$.

If you want to salvage what you have, then you'll find that the root you want on the negative real axis is $|z| \left ( \frac{z}{|z|} \right )^n$. Basically, this trick is finding a complex number with the same modulus as the root $z$ (since all the roots have the same modulus), but $n$ times the argument. This "undoes" the change in argument from taking the principal root.

Solution 2:

Try nthroot(-1,3).

If you type (-1)^(1/3), it'll give you the solution to $x^3=-1$ on the complex plane with lower argument.

Solution 3:

If you want the real cube root of $a<0$, try $-|a|^{\Large\frac{1}{3}}$.