π in python on a Pi
People have tried to calculate π, the ratio of a circle's circumference to diameter, for millenia. The well-known and still-useful approximation of 22/7 was calculated by Archimedes as an upper bound in around 250BC, along with a less memorable lower bound of 223/71.
There are many different algorithms which converge to π. Those described here are divided as:
- Infinite summations
- Infinite products
- Continued fractions
- Iterative methods, including π to 60 figures
- Random sampling
Methods can vary enormously in the rate at which they converge. The best above, one of the iterative methods, doubles the number of correct digits after each step. Most add a constant number of correct digits per step, or need a constant number of steps to add a correct decimal digit. Some need a factor of ten more terms to produce another correct digit. Some double the number of correct digits at each iteration.