# Example: Animated definite integral

Published 2009-11-04 | Author: Efraín Soto Apolinar

This animation helps explain the geometric interpretation of the definite integral.

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

%
%
% Author:
% Efraín Soto Apolinar.
% http://www.aprendematematicas.org/
%
% This animation helps explain the
% geometric interpretation of the
% definite integral.
%
\documentclass[10pt]{beamer}
\usepackage[utf8]{inputenc} % Language = Spanish
%

\usepackage{color}
\usepackage{tikz}
\usepackage{hyperref}
\hypersetup{pdfpagemode=FullScreen}
\usepackage{ifthen}
\usepackage{animate}
%
\usetheme{Warsaw}
\usecolortheme{whale}
%
%
%
\newcounter{angle}
\setcounter{angle}{0}
%
\begin{document}
%
%
%
\newcounter{r}
\newcommand{\escalar}[1]{
\setcounter{r}{#1 * #1 * #1}
}
%
\newcounter{m}
\setcounter{m}{0}
\newcounter{mc}
%
%
%
\begin{frame}[fragile]{Animated Integral}
\begin{center}
\begin{animateinline}[loop, poster = first, controls, palindrome]{2}
\whiledo{\them < 21}{
\begin{tikzpicture}[scale=1.25]
\draw[red,thick,<->] (-1,1) parabola bend (0,0) (2.1,4.41)
node[below right] {$y=x^2$};
\draw[loosely dotted] (-1,0) grid (4,4);
%\path[use as bounding box] (-2,-1) rectangle (5,5);
\draw[->] (-0.2,0) -- (4.25,0) node[right] {$x$};
\draw[->] (0,-0.25) -- (0,4.25) node[above] {$y$};
\foreach \x/\xtext in {1/1, 2/2, 3/3}
\draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};
\foreach \y/\ytext in {1/1, 2/2, 3/3, 4/4}
\draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};
%
\setcounter{mc}{\value{m}*\value{m}}
(0,0) parabola (0.1*\them,0.01*\themc) |- (0,0);
\escalar{\them}
\draw (3cm,2pt) node[above]
{$\displaystyle\int\limits_0^{\them/10} \!\!x^2\mathrm{d}x = \displaystyle\frac{\ther}{3000}$};
\draw[fill=orange,color=orange] (0.1*\them,0.01*\themc) circle (0.5pt);
\end{tikzpicture}
%
\stepcounter{m}
\ifthenelse{\them < 21}{
\newframe
}{
\end{animateinline}\relax % BREAK
}
} % END \whiledo...
\end{center}
\end{frame}

%
%
%
\end{document}


• #1 Thiago, November 13, 2009 at 2:25 p.m.

Interesting, but the last frame is not aligned. regards

• #2 Kjell Magne Fauske, November 13, 2009 at 9:33 p.m.

Yes, that is a bit annoying. We could not figure out why.

• #3 Alexander, November 27, 2009 at 2:42 p.m.

If you are interested, here is a corrected version which solves the last frame and the empty first frame issues. Moreover, it uses the \multiframe command provided by animate.sty instead of the \whiledo loop.

ftp://ftp.fzd.de/private/grahn/animated-definite-integral.tex

ftp://ftp.fzd.de/private/grahn/animated-definite-integral.pdf

• #4 Kjell Magne Fauske, December 29, 2009 at 7:28 p.m.

The example has now been updated and the last frame issue fixed.

• #5 Dimitri, March 6, 2010 at 3:55 p.m.

Its a bug? The area working only in full-screen-mode correctly.

• #6 Patricio Niculqueo, July 12, 2012 at 9:30 a.m.

How I can see this animation, sorry but I haven't so much experience with this things.

• #7 Iván, September 14, 2012 at 7:22 p.m.

Muy chidooo!!!