eigenmath/doc/manual/francois-viete.tex

56 lines
1.5 KiB
TeX
Raw Permalink Normal View History

2008-12-20 00:27:51 +01:00
\section{More examples}
2008-08-25 02:07:15 +02:00
\subsection{Fran\c cois Vi\`ete}
2007-06-16 00:13:20 +02:00
Fran\c cois Vi\`ete was the first to discover an exact formula for $\pi$.
Here is his formula.
\begin{displaymath}
{2\over\pi}={\sqrt2\over2}\times{\sqrt{2+\sqrt2}\over2}\times
{\sqrt{2+\sqrt{2+\sqrt2}}\over2}\times\cdots
\end{displaymath}
%We can flip it around and write the formula like this.
%\begin{displaymath}
%\pi=2\times{2\over\sqrt2}\times{2\over\sqrt{2+\sqrt2}}\times
%{2\over\sqrt{2+\sqrt{2+\sqrt2}}}\times\cdots
%\end{displaymath}
Let $a_0=0$ and $a_{n}=\sqrt{2+a_{n-1}}$.
Then we can write
\begin{displaymath}
{2\over\pi}={a_1\over2}\times{a_2\over2}\times
{a_3\over2}\times\cdots
\end{displaymath}
%
Solving for $\pi$ we have
\begin{displaymath}
\pi=2\times{2\over a_1}\times{2\over a_2}\times{2\over a_3}\times\cdots=2\prod_{k=1}^\infty
{2\over a_k}
\end{displaymath}
%
Let us now use Eigenmath to compute $\pi$ according to Vi\`ete's formula.
Of course, we cannot calculate all the way out to infinity, we have to stop somewhere.
It turns out that nine factors are just enough to get six digits of accuracy.
\medskip
\verb$a(n)=test(n=0,0,sqrt(2+a(n-1)))$
\verb$float(2*product(k,1,9,2/a(k)))$
$$3.14159$$
\medskip
\noindent
The function $a(n)$ calls itself $n$ times so overall there are
54 calls to $a(n)$.
By using a different algorithm with temporary variables, we can get the
answer in just nine steps.
\medskip
\verb$a=0$
\verb$b=2$
\verb$for(k,1,9,a=sqrt(2+a),b=b*2/a)$
\verb$float(b)$
$$3.14159$$