next up previous contents
Next: Logarithmic Functions Up: Trigonometric Functions Previous: Arctan

Pi

The computation of $\pi$ has a long and colourful history (at least by mathematical standards), and has been much studied. The method chosen to implement an algorithm here is to use some identities due to the the mathematician John Machin in 1706. A fuller discussion of approaches to computing $\pi$ is available in [2].

Perhaps the simplest identity (by James Gregory and Gottfried Wilhelm Leibniz ) is:

\begin{displaymath}
\frac{\pi}{4} = \arctan(1)\end{displaymath}

However this identity is impractical because the sequence for arctan converges far too slowly with x=1 to be of value. Over 300 terms of the expansion of $\arctan$ given in section 5.4.1 would be required for two decimal places, and to achieve 100 correct digits would require a massive 1050 terms.

Machin's variation uses the tan double angle angle formula

\begin{displaymath}
\tan(2\theta) = \frac{2\tan(\theta)}{1-\tan^2(\theta)}\end{displaymath}

to derive

\begin{displaymath}
\frac{\pi}{4} = 4\arctan\Big(\frac{1}{5}\Big) - \arctan\Big(\frac{1}{239} \Big)\end{displaymath}

There are other similar identities. The one used in this implementation is:

\begin{displaymath}
\pi = 24 \arctan\Big ( \frac{1}{8} \Big ) + 8 \arctan\Big ( \frac{1}{57} \Big ) + 4 \arctan \Big ( \frac{1}{239} \Big )\end{displaymath}

These identities give a much faster of convergence because the sequence which approximates $\arctan$ is generated with inputs much closer to zero.

These identities are not the most effective method of computing $\pi$.In fact more recent approaches allow the computation of an arbitrary hexadecimal digit of $\pi$ without any computation of the preceding digits.


next up previous contents
Next: Logarithmic Functions Up: Trigonometric Functions Previous: Arctan
Martin Escardo
5/11/2000