Machin's Arctangent Series for Pi in JavaScript  


Click "View: Page Source" to see the Javascript source code

In 1706 John Machin discovered the trigonometric identity

      PI = 16 arctan(1/5) - 4 arctan(1/239)
and used it to calculate the first one hundred digits of Pi.   He combined his formula with the Taylor series expansion for the inverse tangent of x.  (Brook Taylor was Machin's contemporary in Cambridge.)   The arctangent series is
                      3      5      7             n 2n+1
     arctan(x) = x - x /3 + x /5 - x /7 +...+ (-1) x    /(2n+1) +..
Machin's formula remained the primary tool of Pi-hunters for centuries.   As late as 1973, Guilloud and Bouyer used a variation of it to compute one million digits of Pi on a CDC 7600.

This program uses arrays of multiple precision digits for the two series terms, for their sum, and for the series.   Each 'digit' is a modulo 10000 integer.   The number base is 10,000.

In the end, John Machin was never cured.


AUTHOR:  John Bohr email me
Last updated: 1 October 1998