# Working out digits of Pi. [closed]

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

Thanks.

-

5
Perhaps you should ask a question. – alex.jordan Dec 18 '12 at 21:05

1
– Daryl Dec 18 '12 at 21:05

3
– Hagen von Eitzen Dec 18 '12 at 21:09

1
:(..................... – fosho Dec 18 '12 at 21:11
– Arkamis Dec 18 '12 at 21:16

## closed as not a real question by Arkamis, Asaf Karagila, Andres Caicedo, John Wordsworth, 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, see the FAQ.

## 4 Answers

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

-

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.

-

2
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

2
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. – B.D 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
Better just to leave a comment instead of "taking the liberty" to edit my answer. Thanks. – B.D Dec 20 '12 at 12:00
– asmeurer Dec 20 '12 at 19:58
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 17, "mathjax_display_tex": 11, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9287489056587219, "perplexity_flag": "middle"}