Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Pi records


share|cite|improve this question

closed as not a real question by Arkamis, Asaf Karagila, Andrés Caicedo, Old John, Micah Dec 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.

Perhaps you should ask a question. – alex.jordan Dec 18 '12 at 21:05
If you had read beyond the (ignored) copyright license of the image you show and linked the source, you'd have immediately found Daryl's suggested link with detailled information (and a few others) – Hagen von Eitzen Dec 18 '12 at 21:09
Here is Daryl's link for non-mobile browsers: – Arkamis Dec 18 '12 at 21:16
up vote 3 down vote accepted

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.

share|cite|improve this answer
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.

share|cite|improve this answer
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)}. $$

share|cite|improve this answer
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.

share|cite|improve this answer
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 – asmeurer Dec 20 '12 at 19:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.