23
$\begingroup$

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.

$\endgroup$

closed as off-topic by Bill Dubuque, user26857, user91500, Claude Leibovici, JonMark Perry Feb 9 '17 at 7:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about mathematics, within the scope defined in the help center." – Bill Dubuque, user26857, user91500, Claude Leibovici, JonMark Perry
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Maybe because $\;\frac12+\frac{\sqrt3}2i=e^{\pi i/3}\;$ is one of the three roots of unit in the complex field...? $\endgroup$ – Timbuc Dec 3 '14 at 4:47
  • 2
    $\begingroup$ See also this post on the Undocumented Matlab blog. $\endgroup$ – horchler Dec 3 '14 at 5:29
  • 1
    $\begingroup$ FWIW, this is not (solely) a Matlab issue. Mathematica does the same: N @ (-1)^(1/3) → 0.5 + 0.866025i but CubeRoot[-1] → -1. $\endgroup$ – Raphael Dec 3 '14 at 16:00
  • 3
    $\begingroup$ "Wrong", you say? $\endgroup$ – imallett Dec 4 '14 at 4:21
  • 1
    $\begingroup$ I think "wrong" is the wrong word to use. Without context there is no objective way to select the "best" result for a many valued function. $\endgroup$ – Tim Seguine Dec 4 '14 at 7:14
22
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Would the downvoter care to comment? $\endgroup$ – Ian Dec 3 '14 at 4:51
  • 2
    $\begingroup$ Why they down voted a perfectly healthy answer I don't understand... $\endgroup$ – Fmonkey2001 Dec 3 '14 at 4:53
  • 3
    $\begingroup$ And now someone's down-voted the question, which is a perfectly legitimate one. $\endgroup$ – user_of_math Dec 3 '14 at 4:55
  • $\begingroup$ 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|}\;$. $\;\;\;\;\;\;\;$ $\endgroup$ – user57159 Dec 3 '14 at 22:45
  • 1
    $\begingroup$ @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. $\endgroup$ – Ian Dec 3 '14 at 22:45
12
$\begingroup$

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.

$\endgroup$
7
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Can you explain why this works? $\endgroup$ – turkeyhundt Dec 3 '14 at 4:50
  • $\begingroup$ @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. $\endgroup$ – Fmonkey2001 Dec 3 '14 at 5:01
  • $\begingroup$ Oh. Ha. Right.. $\endgroup$ – turkeyhundt Dec 3 '14 at 5:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.