I want to plot $y = 2^x$ over a small domain. Unfortunately, even though tikz (v 2.1) seems to be able to calculate 2^{negative numbers} it is not plotting them correctly.
My minimal example is:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
The value of $2^{-1}$ is \pgfmathparse{pow(2,-1)}\pgfmathresult.
\begin{tikzpicture}
\draw[thick,->] (-2,0) -- (2,0) node[right]{$x$};
\draw[thick,->] (0,0) -- (0,5) node[above]{$y$};
\draw[blue,domain=-2:2] plot (\x,{exp(ln(2)*\x)});
\draw[red,domain=-2:2] plot (\x,{pow(2,\x)});
\end{tikzpicture}
\end{document}
The red and blue graphs should be identical, and they are for the very first point (x = -2) and all the non-negative values, but there seems to be some problem with the plotting algorithm that means there is a bizarre kink to make the red graph almost symmetrical.
Is this a known problem, and if so, has it been fixed in later versions of tikz?
pgfplots
works fine, which is probably a more convenient way of plotting functions than using "raw" TikZ.