TikZ seems to graph the cube root function with the code provided - on the positive x-axis. Why isn't TikZ plotting the whole graph?



\noindent \hspace*{\fill}
\begin{axis}[width=6in,axis equal image,clip=false,
    axis lines=middle,
    domain=-10:10, samples=201,
    restrict y to domain=-2.5:2.5,
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
\addplot[samples=501,domain=-10:10,blue] {x^(1/3))} node[above,pos=0.9]{$\scriptstyle{y} = f(x)$};

  • 2
    Probably because of the mathematical definition of x^{1/3}: exp(ln(x)/3). That's the way it is defined in any pocket calculator. – Bernard Oct 12 '14 at 0:29
  • @Bernard Thanks for the information. How do I get a plot of the cube root function? – Adelyn Oct 12 '14 at 0:37
  • 1
    Make two plots: one between -10 and -0.0001, say, of -(-x)^(1/3), and one between 0.0001 and 10 of x^(1/3). Not sure how tikz works, but mathematically, you'll have problems at 0, hence the very small but non zero values. However if tikz has a sign and an abs function (I don't know: personally I do these things with pstricks), it might be simpler to plot sgn(x)(abs(x))^(1/3)between -10 and 10. – Bernard Oct 12 '14 at 0:48
  • 2
    Does PGF Math Function to compute cube root solve your problem. – Peter Grill Oct 12 '14 at 1:55
  • 1
    Another approach would be to compute a Talor's series or use successive approximation. But Tikz actually uses lookup tables for all the nonlinear math functions, so simply constructing an array of values and importing into LaTeX is ultimately the best approach. – John Kormylo Oct 12 '14 at 19:51

Browse other questions tagged or ask your own question.