I'm trying to plot the square and cubic root of x using this code:
\begin{tikzpicture}[scale=.5, >=stealth]
\begin{axis}[
xmin=-5,xmax=5,
ymin=-5,ymax=5,
axis x line=middle,
axis y line=middle,
axis line style=<->,
]
\addplot[no marks,blue] expression[samples=100]{sqrt{x}}
node[pos=0.65,anchor=south west]{$y=\sqrt{x}$};
\addplot[no marks,red] expression[domain=-pi:pi,samples=100]{sqrt[3]{x}}
node[pos=0.65,anchor=south west]{$y=\sqrt[3]{x}$};
\end{axis}
\end{tikzpicture}
but I get the following errors:
I've tried writing \sqrt instead of sqrt but the errors are the same. How can I solve this?
Ok so, trying, as suggested by a comment, to try different formulas I got it working with x^(1/2) and x^(1/3)
The problem now is that I get the wrong graph for the cube root.
The code now is:
\begin{tikzpicture}[scale=.5, >=stealth]
\begin{axis}[
xmin=-5,xmax=5,
ymin=-5,ymax=5,
axis x line=middle,
axis y line=middle,
axis line style=<->,
]
\addplot[no marks,blue] expression[domain=0:5,samples=100]{x^(1/2)}
node[pos=0.65,anchor=south west]{$y=\sqrt{x}$};
\addplot[no marks,red] expression[domain=-5:5,samples=100]{x^(1/3)}
node[pos=0.65,anchor=south west]{$y=\sqrt[3]{x}$};
\end{axis}
\end{tikzpicture}
But for the cube root I'm missing the negative branch:
How can I solve this?
sqrt(x)
andexp(ln(x)/3)
for the square and cubic root. Please, can you put your complete MWE? Just for me there are some mistakes to compile it. See after also this link: tex.stackexchange.com/questions/19052/…