1

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
Robert
  • 113

3 Answers3

2

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.

Mikasa
  • 67,374
1

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.

apnorton
  • 17,706
  • 1
    I reread my answer, and thought it needed a little clarification: Mathematica doesn't use the roots in the upper-left quadrant all the time--rather, it uses the principal root (informally, the root with the lowest positive imaginary part). This happens to occur in the upper-left quadrant for the cube root. – apnorton Jan 08 '13 at 23:41
1

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}$.

See also TeX.SE.

Dror
  • 141