Iterative algorithm for $\pi$

pireal-analysissequences-and-series

Let $a_0=3$ and $a_n=a_{n-1}+\sin a_{n-1}$. Then
$$\pi =\lim_{n\to\infty}a_n.$$

I encountered this algorithm a long time ago and don't remember where. It converges very quickly, which I found fascinating (digits agreeing with $\pi$ are in green):
$$\begin{align}a_1&\approx\color{green}{3.141}12,\\
a_2&\approx\color{green}{3.1415926535}722,\\
a_3&\approx \color{green}{3.14159265358979323846264338327950}19.\end{align}$$

Why does it compute $\pi$? And why is the convergence so fast?

Best Answer

You are iterating the function $f(x) = x + \sin(x)$. This is a nondecreasing function because $f'(x) = 1 + \cos(x) \ge 0$, and it has fixed points at multiples of $\pi$. If $x_0 < x_1 = f(x_1)$, we will have $x_i < x_{i+1}$ for all $i$. Since it is bounded above (by the next fixed point), it has a limit, and that limit can only be a fixed point. Similarly, if $x_i > x_{i+1}$ the sequence decreases to a limit at a fixed point. The fixed points for which $f'(x) = 0$ (namely the odd multiples of $\pi$) are stable. For $x$ near $k \pi$ where $k$ is odd, the Taylor series says $$ f(x) \approx k \pi + \frac{(x - k \pi)^3}{6}$$ so the "error" in the next iteration is approximately $1/6$ the cube of the error in this iteration. That makes it converge very rapidly.