# Tikzpicture e-function

I have the problem that i get an error message (dimension too large) when i try to draw an e-function:

\documentclass[BCOR=3mm,11pt,headsepline,footsepline]{scrbook}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{pgf,tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[dvipdfm]{geometry}
\usepackage{tabulary}
\usepackage{subfigure}
\usepackage{float}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes,snakes}
\usepackage{ntheorem}
\geometry{
inner=2cm,
outer=2cm,
top=2cm,
bottom=2.5cm,
footnotesep=1cm,
%   bindingoffset=1cm,
}

\mdtheorem[%
apptotikzsetting={\tikzset{mdfbackground/.append style=%
{top color=white,
bottom color=white},
mdfframetitlebackground/.append style =%
{top color=gray!10!white,
bottom color=gray!10!white}
}},
,roundcorner=10pt,middlelinewidth=1.3pt,
frametitlerule=true,frametitlerulewidth=1.3pt,
innertopmargin=10pt,%
]{wissen}{Fehlerschwerpunkt}
\begin{document}
\begin{tikzpicture}[scale=0.9, >=latex,y=7cm,x=1cm]
\draw[-angle 45,line width = 0.8pt] (-6,0) -- (6,0) node[right] {\scriptsize $x$};
\draw[-angle 45,line width = 0.8pt] (0,-0.1) -- (0,0.5) node[above] {\scriptsize $y$};
\foreach \x in {-5,-4,...,-1,1,2,...,5} \draw (\x, 3pt) -- (\x,-3pt) node[anchor=north] {\tiny \x};
\foreach \y in {0.1,0.2,0.3,0.4} \draw (3pt,\y) -- (-3pt,\y) node[anchor=east] {\tiny \y};
\draw[color=red, line width = 1pt, domain=-4:5, samples=100]     plot (\x,{(9*exp(\x))/(exp(\x)+9)^2});
\end{tikzpicture}
\end{document}

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Oct 19 '14 at 18:09
• It looks like you possibly have two or three separate accounts (1 2 3). The StackExchange staff can merge them together for you if you wish. – Paul Gessler Oct 19 '14 at 19:22

For plots you are better of using pgfplots:

## Code:

\documentclass{scrbook}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
xmax=6.9,
xmin=-5.5,
ymin=-0.05,
ymax=0.35,
xlabel={$x$},
ylabel={$y$},
]
\addplot [domain=-4:5, samples=100, ultra thick, blue] {9*exp(x)/(exp(x)+9)^2};
\end{axis}
\end{tikzpicture}
\end{document}


A PSTricks solution:

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\psset{
yunit = 20
}
\begin{pspicture}(-5,-0.05)(7.35,0.37)
\psaxes[
dx = 2,
Dx = 2,
dy = 0.1,
Dy = 0.1
]{->}(0,0)(-5,-0.05)(7,0.35)[$x$,0][$y$,90]
\psplot[
algebraic,
plotpoints = 1000, % larger number means smoother curve (and longer compile time)
linewidth = 1.5pt,
linecolor = blue
]{-4}{5}{9*Euler^x/(Euler^x+9)^2}
\end{pspicture}

\end{document}


PGF-Manual wrotes:

It should be noted that all calculations must not exceed ±16383.99999 at any point, because the underlying computations rely on TeX dimensions. This means that many of the underlying computations are necessarily approximate and that in addition, are not very fast. TeX is, after all, a typesetting language and not ideally suited to relatively advanced mathematical operations. However, it is possible to change the computations as described in Section 76.

So i have changed the code to:

\begin{tikzpicture}[scale=0.9, >=latex,y=9cm,x=0.8cm]
\draw[-angle 45,line width = 0.8pt] (-6,0) -- (6,0) node[right] {\scriptsize $x$};
\draw[-angle 45,line width = 0.8pt] (0,-0.1) -- (0,0.5) node[above] {\scriptsize $y$};
\foreach \x in {-5,-4,...,-1,1,2,...,5} \draw (\x, 3pt) -- (\x,-3pt) node[anchor=north] {\tiny \x};
\foreach \y in {0.1,0.2,0.3,0.4} \draw (3pt,\y) -- (-3pt,\y) node[anchor=east] {\tiny \y};
\draw[color=red, line width = 1pt, domain=-4:5, samples=100]     plot (\x,{(9*exp((\x)))/(exp((\x))+9)/(exp((\x))+9)});
\end{tikzpicture}


So that the Term (exp(x)+9)^2 has not to be calculated for higher numbers

In this particular case you can avoid the large denominator term by changing

plot (\x,{(9*exp(\x))/(exp(\x)+9)^2})


to this

plot (\x,{(9*exp(\x))/(exp(\x)+9)/(exp(\x)+9})


With this change, your example compiles without error and produces this (on my system):

• Isn't this already covered by @columkle's answer? – Peter Grill Oct 20 '14 at 17:57
• @PeterGrill - it is now that he's edited it, I don;t think it was earlier. Perhaps I should simply have commented, or perhaps we can merge them. – Thruston Oct 20 '14 at 22:20