[Tex/LaTex] Math formulas not working in TikZ

tikz-pgf

I often experience problems with evaluating expressions like sqrt(\x) or 2^{\x^2} in TikZ pictures. Here is an example:

{
\begin{tikzpicture}[scale=2]
\draw[draw=gray!50!white,fill=gray!50!white]
plot[smooth,samples=100,domain=0:1] (\x*\x,1+\x) --
plot[smooth,samples=100,domain=0:1] (\x,2^{\x^2});
\draw[domain=0:1] plot (\x*\x,1+\x);
\draw[samples=100,domain=0:1] plot (\x,2^{\x^2});
\draw (-.5,0)--(1.25,0) node[right]{$x$};
\draw (0,-.5)--(0,2.25) node[above]{$y$};
\draw (1,2pt)--(1,-2pt) node[below] {$1$};
\foreach \y/\ytext in {1,2}
\draw (2pt,\y)--(-2pt,\y) node[left] {$\y$};
\end{tikzpicture}
}


I managed to avoid using sqrt(\x), but I can't get the other function to work. What am I doing wrong?

You need some corrections. For tiKZ to parse the function expression correctly, it needs two culy braces around it. So, (\x*\x,1+\x) should be ({\x*\x},{1+\x}) and so on for the rest of the expressions. Also, why avoid sqrt(\x) or the like? TikZ can easily deal with these functions as for example \pgfmathsqrt{x} \pgfmathresult.

\documentclass[tikz,border=2pt]{standalone}
\begin{document}

\begin{tikzpicture}[scale=2]
\draw[draw=gray!50!white,fill=gray!50!white]
plot[smooth,samples=100,domain=0:1] ({\x*\x},{1+\x}) --
plot[smooth,samples=100,domain=0:1] ({\x},{2^(\x^2)});
\draw[domain=0:1] plot (\x*\x,1+\x);
\draw[samples=100,domain=0:1] plot ({\x},{2^(\x^2)});
\draw (-.5,0)--(1.25,0) node[right]{$x$};
\draw (0,-.5)--(0,2.25) node[above]{$y$};
\draw (1,2pt)--(1,-2pt) node[below] {$1$};
\foreach \y/\ytext in {1,2}
\draw (2pt,\y)--(-2pt,\y) node[left] {$\y$};
\end{tikzpicture}

\end{document}