|Contrary to popular belief and what most mathematicians will tell you, all of the digits in the decimal expansion of π are known! They are: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. It is the order that they appear that is not known.|
The arctan(x) series converges for x ≤ 1 and is particularly easy to compute for x = 1/q, where q is an integer. We compute it term by term adding or subtracting the new term to the partial sum. Let a particular "partial" term contain just the powers of q; that is, as an example the third "partial" term:
Each step to obtain a term then consists of two "long division" processes each by a relatively small integer (by small we mean under 1,000,000 which can be represented by a single variable—not an array of digits).
Finally, to compute a large number of digits of π we need to maintain explicitly large arrays of digits that contain partial terms, terms, sums, and, eventually, the value of π. The necessary arithmetic functions then consist of the three processes:
Several formulae involving arctan series that use arctan(1/q) can be shown to give π:
|8||π =||16·arctan(1/5)||−||4·arctan(1/239)||Machin Formula—derivation|
The first formula comes from tan 1 = π/4. While it does converge, it converges much too slowly to be of any great use taking 5,000,000,000 terms just to compute 10 decimal digits!
Essentially if we wish to compute 1000 digits of π, then we need to compute sufficient terms of each of the series so that the last term in each series is < 10−1000. The larger the value of q in the arctan(1/q) expression, the faster the series converges.
Number of terms
The time spent in computing each series for Formula 11, as an example, is best illustrated using, of course, a Pi Chart!
To ensure that "round-off" error in the last digit does not affect any of the desired digits, simply add an extra 20 or so digits to be thrown away when the computation is complete as potentially being in error. It would take on the order of 1020 operations for any erroneous value (roundoff could be as large as 0.5 in the last digit) in the last place to accumulate to affect the 20-th digit from the end. For a modern computer performing 1 billion operations per second, it would take over 3000 years to perform 1020 operations!
And, always keep in mind that the time to complete the computation is proportional to the square of the number of digits; that is, to compute an approximation to π with double the number of digits will take 4 times as long. This is because it will take twice as many terms to reach convergence and each arithmetic function is acting on twice as many digits.