[Tex/LaTex] Definite Integral Animation Examples

animationsbeamer

Does anyone know where I can find a template that will show Riemann sums converging to the definite integral, dynamically for a beamer presentation?

Best Answer

With PSTricks.

GIF version:

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\def\f(#1){(#1+1)*(#1-1)*(#1-3.5)}

\psset{algebraic,plotpoints=100}

\begin{document}
\multido{\i=1+1}{20}{%
\begin{pspicture}(-1.5,-5.5)(4.5,4.5)
    \psStep[linewidth=0.4pt,linecolor=gray,fillstyle=solid,fillcolor=orange](-0.5,3.0){\i}{\f(x)}
    \psplot[linecolor=blue]{-1.0}{3.5}{\f(x)}
    \psaxes[linecolor=gray]{->}(0,0)(-1.5,-5.5)(4,4)[$x$,0][$y$,90]
\end{pspicture}}
\end{document}

Beamer version:

enter image description here

Read the given comments at the top!

% please compile it with pdflatex -shell-escape main.tex
% Filename for this code is main.tex
\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents*}{integral.tex}
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\def\f(#1){(#1+1)*(#1-1)*(#1-3.5)}

\psset{algebraic,plotpoints=100}

\begin{document}
\multido{\i=1+1}{20}{%
\begin{pspicture}(-1.5,-5.5)(4.5,4.5)
    \psStep[linewidth=0.4pt,linecolor=gray,fillstyle=solid,fillcolor=orange](-0.5,3.0){\i}{\f(x)}
    \psplot[linecolor=blue]{-1.0}{3.5}{\f(x)}
    \psaxes[linecolor=gray]{->}(0,0)(-1.5,-5.5)(4,4)[$x$,0][$y$,90]
\end{pspicture}}
\end{document}
\end{filecontents*}

\immediate\write18{latex integral}
\immediate\write18{dvips integral}
\immediate\write18{ps2pdf integral.ps}
% do cleaning here if necessary!

\usepackage{animate}
\begin{document}
\begin{frame}{Definite Integral}
\begin{center}
    \animategraphics[controls,loop,autoplay,scale=0.5]{5}{integral}{}{}
\end{center}
\end{frame}
\end{document}
Related Question