TITLE: Simple numerical methods for calculating the digits of $\pi$
QUESTION [34 upvotes]: Are there any simple methods for calculating the digits of $\pi$? Computers are able to calculate billions of digits, so there must be an algorithm for computing them. Is there a simple algorithm that can be computed by hand in order to compute the first few digits?

REPLY [5 votes]: The first method that I applied successfully with function calculator was approximation of circle by $2^k$-polygon with approximating sides with one point on the circle and corners outside the circle. I started with unit circle that was approximated by square and the equation $\tan(2^{-k} \pi/4) \approx 2^{-k} \pi/4$, that gives $\pi \approx \frac{8}{2} = 4$ for $k=0$. I iterated the formula of tangent of half angle, that I solved applying the formula of the solution of second order equation, that was applied to the sum formula of tangent. I obtained the sequence $\pi \approx 8 \cdot 2^k \tan(2^{-k} \pi /4)/2$.
The problem is that the solution formula of the second order equation has square root, that is difficult to calculate by hand. That's why I kept on searching a simple approximation method that applies addition, substraction, multiplication and division of integers. I ended up to the following calculation. This method applies Machin-like formula and was first published by C. Hutton.
\begin{eqnarray}
\pi & = & 4 \frac{\pi}{4} = 4 \arctan(1) = 4 \arctan\Bigg(\frac{\frac{5}{6}}{\frac{5}{6}}\Bigg) = 4 \arctan\Bigg(\frac{\frac{1}{2}+\frac{1}{3}}{1-\frac{1}{2}\frac{1}{3}}\Bigg) \\
& = & 4 \arctan\Bigg(\frac{\tan(\arctan(\frac{1}{2}))+\tan(\arctan(\frac{1}{3}))}{1-\tan(\arctan(\frac{1}{2}))\tan(\arctan(\frac{1}{3}))}\Bigg) \\
& = & 4 \arctan\Big(\tan\Big(\arctan\Big(\frac{1}{2}\Big)+\arctan\Big(\frac{1}{3}\Big)\Big)\Big) \\
& = & 4 \Big(\arctan\Big(\frac{1}{2}\Big)+\arctan\Big(\frac{1}{3}\Big)\Big) \\
& = & 4 \Big(\Big\vert_0^\frac{1}{2} \arctan(x) + \Big\vert_0^\frac{1}{3} \arctan(x)\Big) \\
& = & 4 \bigg(\int_0^\frac{1}{2} \frac{1}{1+x^2} dx + \int_0^\frac{1}{3} \frac{1}{1+x^2} dx\bigg) \\
& = & 4 \bigg(\int_0^\frac{1}{2} \sum_{k=0}^\infty (-x^2)^k dx + \int_0^\frac{1}{3} \sum_{k=0}^\infty (-x^2)^k dx \bigg) \\
& = & 4 \bigg(\sum_{k=0}^\infty \int_0^\frac{1}{2} (-x^2)^k dx + \sum_{k=0}^\infty \int_0^\frac{1}{3} (-x^2)^k dx \bigg) \\
& = & 4 \bigg(\sum_{k=0}^\infty \int_0^\frac{1}{2} (-1)^k x^{2k} dx + \sum_{k=0}^\infty \int_0^\frac{1}{3} (-1)^k x^{2k} dx \bigg) \\
& = & 4 \bigg(\sum_{k=0}^\infty \bigg\vert_0^\frac{1}{2} \frac{(-1)^k}{2k+1} x^{2k+1} + \sum_{k=0}^\infty \bigg\vert_0^\frac{1}{3} \frac{(-1)^k}{2k+1} x^{2k+1} \bigg) \\
& = & 4 \bigg(\sum_{k=0}^\infty \frac{(-1)^k}{2k+1} \frac{1}{2^{2k+1}} + \sum_{k=0}^\infty \frac{(-1)^k}{2k+1} \frac{1}{3^{2k+1}} \bigg) \\
& = & 4 \sum_{k=0}^\infty \frac{(-1)^k}{2k+1} \bigg(\frac{1}{2^{2k+1}} + \frac{1}{3^{2k+1}}\bigg) \\
& = & \sum_{k=0}^\infty \frac{4(-1)^k}{2k+1} \bigg(\frac{1}{2^{2k+1}} + \frac{1}{3^{2k+1}}\bigg).
\end{eqnarray}
It is the most beautiful in practice numerically applicable method I have found so far.