The Bailey–Borwein–Plouffe formula (BBP formula) is a formula for . It was discovered in 1995 by Simon Plouffe and is named after the authors of the article in which it was published, David H. Bailey, Peter Borwein, and Plouffe.[1] Before that, it had been published by Plouffe on his own site.[2] The formula is:
\pi=
infty | ||
\sum | \left[ | |
k=0 |
1 | \left( | |
16k |
4 | - | |
8k+1 |
2 | - | |
8k+4 |
1 | - | |
8k+5 |
1 | |
8k+6 |
\right)\right]
Since its discovery, formulas of the general form:
\alpha=
infty | |
\sum | |
k=0 |
\left[
1 | |
bk |
p(k) | |
q(k) |
\right]
\alpha
p(k)
q(k)
b\geq2
\alpha
p(k)
q(k)
b
A specialization of the general formula that has produced many results is:
P(s,b,m,A)=
infty | ||
\sum | \left[ | |
k=0 |
1 | |
bk |
m | |
\sum | |
j=1 |
aj | |
(mk+j)s |
\right],
A=(a1,a2,...,am)
\pi=
infty | ||
\sum | \left[ | |
k=0 |
1 | \left( | |
16k |
4 | - | |
8k+1 |
2 | - | |
8k+4 |
1 | - | |
8k+5 |
1 | |
8k+6 |
\right)\right]
\pi=Pl(1,16,8,(4,0,0,-2,-1,-1,0,0)r).
Some of the simplest formulae of this type that were well known before BBP and for which the P function leads to a compact notation, are:
\begin{align} ln
10 | |
9 |
&=
1 | |
10 |
+
1 | |
200 |
+
1 | |
3 000 |
+
1 | |
40000 |
+
1 | |
500000 |
+ … \\ &=
infty | |
\sum | |
k=1 |
1 | |
10k ⋅ k |
=
1 | |
10 |
infty | |
\sum | |
k=0 |
\left[
1 | |
10k |
\left(
1 | |
k+1 |
\right)\right]\\ &=
1 | |
10 |
Pl(1,10,1,(1)r), \end{align}
\begin{align} ln2&=
1 | |
2 |
+
1 | |
2 ⋅ 22 |
+
1 | |
3 ⋅ 23 |
+
1 | |
4 ⋅ 24 |
+
1 | |
5 ⋅ 25 |
+ … \\ &=
infty | |
\sum | |
k=1 |
1 | |
2k ⋅ k |
=
1 | |
2 |
infty | |
\sum | |
k=0 |
\left[
1 | |
2k |
\left(
1 | |
k+1 |
\right)\right]\\ &=
1 | |
2 |
Pl(1,2,1,(1)r). \end{align}
(In fact, this identity holds true for a > 1:
ln | a |
a-1 |
=
infty | |
\sum | |
k=1 |
1 | |
ak ⋅ k |
Plouffe was also inspired by the arctan power series of the form (the P notation can be also generalized to the case where b is not an integer):
\begin{align} \arctan
1 | |
b |
&=
1 | |
b |
-
1 | |
b33 |
+
1 | |
b55 |
-
1 | |
b77 |
+
1 | |
b99 |
+ … \\ &=
infty | |
\sum | |
k=1 |
\left[
1 | |
bk |
| ||||
k |
\right] =
1 | |
b |
infty | |
\sum | |
k=0 |
\left[
1 | |
b4k |
\left(
1 | |
4k+1 |
+
-b-2 | |
4k+3 |
\right)\right]\\ &=
1 | |
b |
P\left(1,b4,4,\left(1,0,-b-2,0\right)\right). \end{align}
Using the P function mentioned above, the simplest known formula for is for s = 1, but m > 1. Many now-discovered formulae are known for b as an exponent of 2 or 3 and m as an exponent of 2 or it some other factor-rich value, but where several of the terms of sequence A are zero. The discovery of these formulae involves a computer search for such linear combinations after computing the individual sums. The search procedure consists of choosing a range of parameter values for s, b, and m, evaluating the sums out to many digits, and then using an integer relation-finding algorithm (typically Helaman Ferguson's PSLQ algorithm) to find a sequence A that adds up those intermediate sums to a well-known constant or perhaps to zero.
The original BBP summation formula was found in 1995 by Plouffe using PSLQ. It is also representable using the P function:
\begin{align} \pi&=
infty | |
\sum | |
k=0 |
\left[
1 | |
16k |
\left(
4 | |
8k+1 |
-
2 | |
8k+4 |
-
1 | |
8k+5 |
-
1 | |
8k+6 |
\right)\right]\\ &=Pl(1,16,8,(4,0,0,-2,-1,-1,0,0)r), \end{align}
\pi=
infty | |
\sum | |
k=0 |
\left[
1 | |
16k |
\left(
120k2+151k+47 | |
512k4+1024k3+712k2+194k+15 |
\right)\right].
This formula has been shown through a fairly simple proof to equal .[5]
We would like to define a formula that returns the (
n+1
n\geq0
We must first rewrite the formula as:
\pi=4
infty | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+1) |
-2
infty | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+4) |
-
infty | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+5) |
-
infty | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+6) |
.
Now, for a particular value of n and taking the first sum, we split the sum to infinity across the nth term:
infty | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+1) |
=
n | |
\sum | |
k=0 |
1 | |
\left(16k\right)(8k+1) |
+
infty | |
\sum | |
k=n+1 |
1 | |
\left(16k\right)(8k+1) |
.
We now multiply by 16n, so that the hexadecimal point (the divide between fractional and integer parts of the number) shifts (or remains, if n = 0) to the left of the (n+1)-th fractional digit:
infty | |
\sum | |
k=0 |
16n-k | |
8k+1 |
=
n | |
\sum | |
k=0 |
16n-k | |
8k+1 |
+
infty | |
\sum | |
k=n+1 |
16n-k | |
8k+1 |
.
Since we only care about the fractional part of the sum, we look at our two terms and realise that only the first sum contains terms with an integer part; conversely, the second sum doesn't contain terms with an integer part, since the numerator can never be larger than the denominator for k > n. Therefore, we need a trick to remove the integer parts, that we don't need, from the terms of the first sum, in order to speed up and increase the precision of the calculations. That trick is to reduce modulo 8k + 1. Our first sum (out of four) to compute the fractional part then becomes:
n | |
\sum | |
k=0 |
16n-k\bmod(8k+1) | |
8k+1 |
+
infty | |
\sum | |
k=n+1 |
16n-k | |
8k+1 |
.
Notice how the modulus operator always guarantees that only the fractional parts of the terms of the first sum will be kept. To calculate 16n−k mod (8k + 1) quickly and efficiently, the modular exponentiation algorithm is done at the same loop level, not nested. When its running 16x product becomes greater than one, the modulus is taken, just as for the running total in each sum.
Now to complete the calculation, this must be applied to each of the four sums in turn. Once this is done, the four summations are put back into the sum to :
4\Sigma1-2\Sigma2-\Sigma3-\Sigma4.
Since only the fractional part is accurate, extracting the wanted digit requires that one removes the integer part of the final sum, multiplies it by 16 and keeps the integer part to "skim off" the hexadecimal digit at the desired position (in theory, the next few digits up to the accuracy of the calculations used would also be accurate).
This process is similar to performing long multiplication, but only having to perform the summation of some middle columns. While there are some carries that are not counted, computers usually perform arithmetic for many bits (32 or 64) and round, and we are only interested in the most significant digit(s). There is a possibility that a particular computation will be akin to failing to add a small number (e.g. 1) to the number 999999999999999, and that the error will propagate to the most significant digit.
This algorithm computes without requiring custom data types having thousands or even millions of digits. The method calculates the nth digit without calculating the first n − 1 digits and can use small, efficient data types. Fabrice Bellard found a variant of BBP, Bellard's formula, which is faster.
Though the BBP formula can directly calculate the value of any given digit of with less computational effort than formulas that must calculate all intervening digits, BBP remains linearithmic (
O(nlogn)
D. J. Broadhurst provides a generalization of the BBP algorithm that may be used to compute a number of other constants in nearly linear time and logarithmic space.[7] Explicit results are given for Catalan's constant,
\pi3
\pi4
\zeta(3)
\zeta(5)
\zeta(x)
log32
log42
log52
\pi
log2