TikZ PGF – Fixing Dimension Too Large Error with exp(x) in pgfplots

tikz-pgf

I hope, someone can help me. I've the following problem:

I want to draw a Graph like this
exp Problem

The picture shows the following graphs: exp(x), ln(x), x

my code is:

\begin{tikzpicture} 
    \draw[ultra thin,color=gray] (-0.1,-0.1) grid (5,5);
    \draw[->] (-0.2,0) -- (5.2,0) node[below] {$x$}; 
    \draw[->] (0,-0.2) -- (0,5.2) node[above] {$y$};

    \draw (0,0)--(5,5);

    \draw[color=blue, samples=150, thick, domain=0:1.6095]   
            plot (\x,{exp(\x r)}) node[right] {$f(x) = exp x$};
    \draw[color=cyan, samples=150, thick, domain=1:5]
            plot (\x,{ln(\x r)}) node[right] {$f(x) = ln x$};
\end{tikzpicture}

My LaTeX Compliler throws me the follwoing message:

plot (\x,{exp(\x r)})

node[right] {$f(x) = exp x$}; I can't work with sizes bigger than about 19 feet. Continue and I'll use the

largest value I can.

The Domain Value for exp(x) is 1.6095 because exp(1.6095) = 5

I hope, you can help me.

Best Answer

In your question title it mentions pgfplots but you don't use it. And if you don't use r(radian) indicator everything runs smoothly. I'll take the easy way out by just giving a simple pgfplots example.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture} 
\begin{axis}[xmin=-0.5,xmax=5,ymin=-0.5,ymax=5,no markers,samples=50,grid=both]
\addplot {exp(x)};
\addplot {ln(x)};
\addplot {x};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Please see the pgfplots manual for a lot more.

Related Question