Working out digits of Pi. [closed]

I have always wondered how the digits of π are calculated. How do they do it? Thanks.

closed as not a real question by Emily, Asaf Karagila♦, Andrés E. Caicedo, Old John, MicahDec 19 '12 at 1:01

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

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.

• One thing I'm not sure about: the mpmath source says that each term adds roughly 14 digits, but it's not clear if it's 14 more digits of $\pi$ or 14 more digits of $\frac{1}{\pi}$. – asmeurer Dec 18 '12 at 21:24
• I'm not sure, but I would go with $\frac{1}{\pi}$ since the terms of the series are being implicitly referred to. – 000 Dec 18 '12 at 21:55

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.

• where to put the n in formula – Shivam Patel Oct 20 '13 at 9:58
• Are you sure this works on base 16? I just implemented a script that calculates this series and it plainly gives me a pretty good PI approximation in base 10 – Loupax Oct 7 '14 at 7:31

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)}.$$

• Which mathematician? – asmeurer Dec 18 '12 at 23:18
• @asmeurer Ramanujan. :-) – 000 Dec 19 '12 at 0:23

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.

• This is an insanely inefficient way to calculate $\pi$. Even if you have a calculator and only want to calculate 10 digits or so, it will take you forever. – asmeurer Dec 18 '12 at 21:21
• I make no claims as to its efficiency; indeed, it takes about $700$ terms before you can accurately claim that the expansion begins $3.14\ldots$ I mention it strictly for its simplicity. – Benjamin Dickman Dec 18 '12 at 21:26
• I took the liberty of editing your answer to give the series explicitly, and to point out how slow it is. – asmeurer Dec 18 '12 at 21:29
• Suit yourself, but do take a read of math.stackexchange.com/faq#editing. – asmeurer Dec 20 '12 at 19:58