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

1.3k Views Asked by At

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
2

There are 2 best solutions below

3
On BEST ANSWER

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.

1
On

Really funny you'd mention that... my Calc professor talked about that last semester. ;)

Many software packages plot the principal root, rather than the real root. http://mathworld.wolfram.com/PrincipalRootofUnity.html

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

Mathematica uses the roots in the upper-left quadrant when plotting the cube root. Thus, it thinks it's complex, and therefore doesn't graph it.