# Cube root function [duplicate]

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?

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\noindent \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
axis lines=middle,
xmin=-10,xmax=10,
domain=-10:10, samples=201,
xlabel=$x$,ylabel=$y$,
ymin=-2.5,ymax=2.5,
restrict y to domain=-2.5:2.5,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={\empty},ytick={\empty},
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)$};
\end{axis}
\end{tikzpicture}
\hspace{\fill}

\end{document}

• 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
• 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
• Does PGF Math Function to compute cube root solve your problem. – Peter Grill Oct 12 '14 at 1:55
• 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