9

I have come upon the following formula to extract the nth digit of pi in base 10: $$\pi + 3 = \sum_{n=1}^{\infty} \frac{n 2^n n!^2}{(2n)!} $$ But this just seems to be a formula for pi. How can I use this formula to extract the nth digit of pi?

Nico A
  • 4,934
  • 4
  • 23
  • 49

1 Answers1

4

It is easier to find the $n$-th digit in base $d$ if you have a formula of the form

$$\sum_k \frac{\textbf{maybe large}}{\textbf{small} \times d^k},$$

like BBP formula for $d=16$. Just multiply the formula by $d^n$ and simplify the first $n$ summands as

$$\frac{(\textbf{maybe large} \times d^{n-k}) \text{ mod } \textbf{small}}{\textbf{small}}.$$

Then you need to sum up $n$ real numbers between $0$ and $1$ and several of the next terms (until the rest of series is small enough), see an example for $\ln 2$.

For BBP formula or $\ln 2$ example, the complexity of each step is $O(\log k)$, so the overall complexity is $O(n \log n)$. Your formula is used by Plouffe (difficult to read) with complexity $O(n^3 \log^3 n)$ -- but in any base. The version by Goudon is even more sophisticated, with complexity less than $O(n^2)$ in any base, but Proposition 1 from there shows that the idea is as in the answer.

evgeny
  • 3,781