Iterative algorithm for $\pi$?

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.


You're solving $\sin x=0$ which has a root at $\pi$. The fixed point iteration converges cubically due to $x+\sin x$ having the first two derivatives at the root, hence the rapid convergence.

Now the bad news. You don't have the value of the sine function for free. The function is transcendental, and its calculation requires an unbounded number of arithmetic operations as you seek greater accuracy. Therefore the efficiency of this method is lost if you seek $\pi$ to millions or more decimal places where mathematicians are working with that constant. To maintain efficiency in high-accuracy computations requires a more subtle approach.