Bailey-Borwein-Plouffe formula
From Wikipedia, the free encyclopedia
In mathematics, the Bailey-Borwein-Plouffe formula (BBP formula) is a π summation formula discovered in 1995 by Simon Plouffe. The formula is named after David H. Bailey, Peter Borwein, and Plouffe. A great many formulae that sum to other fundamental irrational constants have since been discovered. They are of the form
where p and q are polynomials in integer coefficients. Formulae in this form are known as BBP-type formulae [1].
The original π summation is
[edit] BBP algorithm
The formula yields an algorithm for extracting hexadecimal digits of π. In order to perform digit extraction first we must rewrite the formula as
Now we would like to find hexadecimal digit n of π, so, taking the first sum we split the sum to infinity across the nth term
We now multiply by 16n so that the hexadecimal point (the divide between fractional and integer parts of the number) is in the right place.
Since we only care about the fractional part of the sum, we look at our two terms and realise that only the first sum is able to produce whole numbers whereas the second sum cannot produce whole numbers since the numerator can never be larger than the denominator for k > n. Therefore we need a trick to remove the whole numbers for the first sum. That trick is . Our sum for the first fractional part then becomes:
Notice how the modulo operator always guarantees that only the fractional sum will be kept. To calculate quickly and efficiently, use the binary exponentiation algorithm. When the running product becomes greater than one, take the modulo just as you do for the running total in each sum.
Now to complete the calculation you must apply this to each of the four sums in turn. Once this is done, taking the four summations and put them back into the sum to π.
Since only the fractional part is accurate, extracting the wanted digit requires that one removes the integer part of the final sum and multiplies by 16 to "skim off" the hexadecimal digit at this position (in theory the next few digits up to the accuracy of the calculations used would also be accurate).
[edit] Advantages of the BBP algorithm
This algorithm can be used on computers without creating custom data types with thousands or even millions of digits in order to try to compute π. Because of the method to remove the first n − 1 digits to get at the nth digit, computers with only small, but efficient, data types can be used. This increase in speed caused by using smaller data types makes the algorithm the fastest way to compute the nth digit (or a few digits in a neighborhood of the nth). Previous π-computing algorithms using the large data types remain faster when the goal is to compute all the digits from 1 to n.
[edit] External links
- Simon Plouffe - The story behind a formula for Pi - Newsgroup post to sci.math and sci.math.symbolic, June 23, 2003
- Weisstein, Eric W., BBP Formula at MathWorld.
- Python implementation of the BBP algorithm for π