# Plot of x^(1/3) has range of 0-inf in Mathematica and R

Just doing a quick plot of the cuberoot of x, but both Mathematica 9 and R 2.15.32 are not plotting it in the negative space. However they both plot x cubed just fine:

Plot[{x^(1/3), x^3},
{x, -2, 2}, PlotRange -> {-2, 2}, AspectRatio -> Automatic]


http://www.wolframalpha.com/input/?i=x%5E%281%2F3%29%2Cx%5E3

plot(function(x){x^(1/3)} , xlim=c(-2,2), ylim=c(-2,2))


Is this a bug in both software packages, or is there something about the cubed root that I don't understand?

In[19]:= {1^3, 1^(1/3), -1^3, -1^(1/3), 42^3, -42^3, 42^(1/3) // N, -42^(1/3) // N}
Out[19]= {1, 1, -1, -1, 74088, -74088, 3.47603, -3.47603}


Interestingly when passing -42 into the R function I get NaN, but when I multiply it directly I get -3.476027.

> f = function(x){x^(1/3)}
> f(c(42, -42))
[1] 3.476027      NaN
> -42^(1/3)
[1] -3.476027

-
In case you didn't know, there is also a Mathematica stack exchange site. See for example Finding real roots of negative numbers – Jonas Meyer Jan 8 '13 at 23:04
Look at a table of values. See the real and complex plot? Maybe that is your issue? Regards – Amzoti Jan 8 '13 at 23:08
Thanks Amzoti and Jonas I need to study more about the imaginary unit. I think you should make those answers instead of just a comment. – Robert Jan 8 '13 at 23:27

I think: if $z < 0$, Mathematica is using the principal branch of the log along with the identity $$z^{1/3} = \exp((1/3)*\log(z)).$$
If you use $z = -1$, you get $$z^{1/3} = \text{e}^{(1/3)*\log(z)} = \text{e}^{\pi/3} = \exp(i\pi/3) = {1 + \sqrt{3}i\over 2}$$ In a word, the software is being "scrupulous to a fault." It's a small price to pay for the program being so complex-number savvy.

-
I think you are missing an $i$ in your last equality, $(1+\sqrt{3}i)/2$. – Daryl Jan 9 '13 at 3:36
@Daryl: Thanks. I edited it. :-) – Babak S. Jan 9 '13 at 6:10
very good detective work! +1 – amWhy Feb 21 '13 at 0:09

If you merely want to plot the function, then you can be smarter. The function $x/|x|$ returns $1$ when $x\geq0$ and $-1$ otherwise. Thus, the function $\frac{x}{|x|}|x|^{1/3}$ has the same image as $x^{1/3}$ but it is defined over the whole domain $\mathbb{R}$.

For example, $\sqrt[3]{3}$ has three values: W|A