How can I get MATLAB to calculate $(-1)^{1/3}$ as $-1$? Why is it giving me $0.5000 + 0.8660i$ as solution? I have same problem with $({-1\over0.1690})^{1/3}$ which should be negative.
3 Answers
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.
- 104,572
-
-
2Why they down voted a perfectly healthy answer I don't understand... – Fmonkey2001 Dec 03 '14 at 04:53
-
3And now someone's down-voted the question, which is a perfectly legitimate one. – user_of_math Dec 03 '14 at 04:55
-
Taking $-\sqrt[n]{-x}$ only works if you assume $x$ is negative. $:$ "If you want to salvage what ... on the negative real axis is" not what's given in this answer, as can be seen from trying $:z=8;$. $;;;$ You can actually "dodge this issue entirely by taking" $:($ signum $(x))^n\cdot \sqrt[n]{|x|};$. $;;;;;;;$ – Dec 03 '14 at 22:45
-
1@RickyDemer Yes, and the OP was asking about a negative input. I didn't answer a question they didn't ask. I also mentioned this in the first paragraph. – Ian Dec 03 '14 at 22:45
-
@RickyDemer Wich will give you $\sqrt 2$ as a result for $\sqrt{-2}$... Ouch. – AlexR Dec 04 '14 at 20:50
-
-
@Ian Your answer was okay since the OP specifically asked for the $3^{\text{rd}}$ root. The problem arises for even-order roots, where the ${\rm sgn}^n(x)$ doesn't salvage a correct root. – AlexR Dec 05 '14 at 07:27
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.
- 1,948
If you want the real cube root of $a<0$, try $-|a|^{\Large\frac{1}{3}}$.
- 10,041
- 4,320
- 14
- 34
-
-
@turkeyhundt Since it's an odd root you can pull the negative out and just take the absolute value of $a$ to the $1/3$ power and then multiple by the negative at the very end. – Fmonkey2001 Dec 03 '14 at 05:01
-
N @ (-1)^(1/3) → 0.5 + 0.866025ibutCubeRoot[-1] → -1. – Raphael Dec 03 '14 at 16:00