Menu

[r4493]: / trunk / py4science / workbook / wallis_pi.tex  Maximize  Restore  History

Download this file

28 lines (18 with data), 847 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\section{Wallis' slow road to $\pi$}
Wallis' formula is an infinite product that converges (slowly) to
$\pi$:\begin{equation}
\pi=\prod_{i=1}^{\infty}\frac{4i^{2}}{4i^{2}-1}.\end{equation}
The listing~\ref{code:wallis_pi} contains a skeleton with no
implementation but with some plotting commands already inserted, so
that you can visualize the convergence rate of this formula as more
terms are kept.
\lstinputlisting[label=code:wallis_pi,caption={IGNORED}]{examples/wallis_pi.py}
After running the script successfully, you should obtain a plot similar
to Figure~\ref{fig:wallis_pi}.
\begin{center}%
\begin{figure}
\begin{centering}\includegraphics[width=4in]{fig/wallis_pi_convergence}\par\end{centering}
\caption{\label{fig:wallis_pi}Convergence rate for Wallis' infinite product
approximation to $\pi.$}
\end{figure}
\par\end{center}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.