Working out digits of Pi. [closed]

I don't know how we do nowadays, but there is a formula due David Bailey, Peter Borwein, and Simon Plouffe in 1995 which it can be used to calculate the $i^{th}$ digit of $\pi$ in base 16:

$$\pi=\sum ^{\infty} _i\frac {1}{16^i}\big(\frac 4 {8i+1}-\frac {2}{8i+4}-\frac {1}{8i+5}-\frac {1}{8i+6}\big)$$

What I find interesting is we don't need to know the previous digits to find the $i^{th}$ digit of $\pi$. Nowadays there are a lot of variations of that formula, but it was a surprise when this formula was discovered, because until that time, the mathematicians thought be impossible to find the $i^{th}$ digit of $\pi$ without knowing the previous ones.


From one of my favorite mathematicians,

$$ \frac{1}{\pi}=\frac{2\sqrt{2}}{9801}\sum_{k \ge 0} \frac{(4n)!(1103+26390n)}{(n!)^4396^{4n}}. $$

Looking here, we see some many formulae. Some of particular interest are:

$$ \pi=\sum_{k \ge 0}\frac{3^k-1}{4^k}\zeta(k+1),\quad \zeta(s)=\sum_{k\ge 0}k^{-s}. $$

$$ \frac{1}{6}\pi^2=\sum_{k \ge 1}\frac{1}{k^2} \quad \text{via the Basel problem}. $$

$$ \pi =\frac{3}{4}\sqrt{3}+24\int_0^{\frac{1}{4}}\sqrt{x-x^2}dx. $$

$$ \frac{\pi}{5\sqrt{\phi+2}}=\frac{1}{2}\sum_{k \ge 0}\frac{(k!)^2}{\phi^{2k+1}(2k+1)!},\quad \text{where } \phi \text{ is the golden ratio.} $$

$$ \pi=\frac{22}{7}-\int_{0}^{1}\frac{x^4(1-x)^4}{1+x^2}dx. $$

$$ \pi=4\sum_{1 \le k \le n}\frac{(-1)^{j+1}}{2j-1}+\frac{(-1)^n}{(2n-1)!}\sum_{i \ge 0}\frac{1}{16^i}\left( \frac{8}{(8i+1)_{2n}}-\frac{4}{(8i+3)_{2n}}-\frac{4}{(8i+4)_{2n}}-\frac{2}{(8i+5)_{2n}}+\frac{1}{(8i+7)_{2n}}+\frac{1}{(8i+8)_{2n}} \right),\quad \text{where } n \in \mathbb{Z}_{>0}, \text{ and } (x)_{n} \text{ represents the Pochhammer symbol.} $$

$$ \pi = 2\left[\prod_{n \ge 0}\left(1+\frac{\sin\left(\frac{1}{2}p_n\right)}{p_n}\right) \right]^{-1},\quad p_n \text{ is the } n\text{th} \text{ prime number}. $$

$$ \frac{2}{\pi}=\sqrt{\frac{1}{2}}\sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}}}\sqrt{\frac{1}{2}+ \frac{1}{2}\sqrt{\frac{1}{2}+\frac{1}{2}\sqrt{\frac{1}{2}}}}\cdots $$

$$ \frac{\pi}{2}=\prod_{n \ge 1}\frac{(2n)^2}{(2n-1)(2n+1)}. $$


The Chudnovsky algorithm, which just uses the very rapidly converging series $$\frac{1}{\pi} = 12 \sum^\infty_{k=0} \frac{(-1)^k (6k)! (13591409 + 545140134k)}{(3k)!(k!)^3 640320^{3k + 3/2}},$$ was used by the Chudnovsky brothers, who are some of the points on your graph.

It is also the algorithm used by at least one arbitrary precision numerical library, mpmath, to compute arbitrarily many digits of $\pi$. Here is the relevant part of the mpmath source code discussing why this series is used, and giving a bit more detail on how it is implemented (and if you want, you can look right below that to see exactly how it is implemented). It actually uses a method called binary splitting to evaluate the series faster.


Here is one simple way to compute digits of $\pi$:

Recall that $\tan(\pi/4) = 1$.

Thus, we have $\arctan(1) = \pi/4$.

And, in particular, $4 \cdot \arctan(1) = \pi$.

You can now take the Taylor series expansion for $4 \cdot \arctan(x)$ and consider what happens when you evaluate it at $1$. Since the corresponding series (see, e.g., here) is an alternating series decreasing in absolute value, you can evaluate however many terms you want, and then take an evaluation of the next term as a (somewhat crude) bound for your error.