The computation of 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 is available in .
Perhaps the simplest identity (by James Gregory and Gottfried Wilhelm Leibniz ) is:
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 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
There are other similar identities. The one used in this implementation is:
These identities give a much faster of convergence because the sequence which approximates is generated with inputs much closer to zero.
These identities are not the most effective method of computing .In fact more recent approaches allow the computation of an arbitrary hexadecimal digit of without any computation of the preceding digits.