Gauss-Legendre algorithm

The Gauss-Legendre algorithm is an algorithm to compute the digits of \(\pi\). Successive iterations of the algorithm produce better approximations of the circle constant, \(\pi\). The algorithm is based on an understanding of the arithmetic-geometric mean and is notable for being rapidly convergent, quadratically so, with only 25 iterations producing 45 million correct digits of \(\pi\).

The code cell below allows the user to choose the number of iterations of the Gauss-Legendre algorithm to calculate and plots the number of significant figures to which the calculated approximation agrees with the value of \(\pi\) built in to Python's numpy module.

Notice that at the precision level of 64-bit floating point numbers the algorithm stabilises after only 3 iterations, which means we max out the accuracy we can possibly get using this data type very quickly.

If we want to use this method to calculate \(\pi\) to a greater number of decimal places we could use the Python's in-built decimal library, which you can read more about here.

Approximating $\pi$ by fractions and polygons

Dinosaur Comics - Pi Approximation Day
Dinosaur Comics - Pi Approximation Day

Following on from discussion in the comic above, we highlight some interesting sources discussing approximations of Pi throughout history. Another approximation to \(\pi\) by a fraction is \(\frac{355}{113}\), which is the best rational approximation of \(\pi\) with a denominator of four digits or fewer, being accurate to 6 decimal places.

This approximation was known to Chinese mathematicians in the 5th Century as 密率, improving on an accuracy of two decimal places achieved by the Ancient Greeks before the beginning of the Common Era (BCE) with \(\frac{22}{7}\approx3.14285714286\), and was found by Chinese mathematician and astronomer, Zǔ Chōngzhī (祖沖之), who used an algorithm of the 3rd Century mathematician Liu Hui which approximates the area of a (unit) circle from below by inscribed regular polygons and also provides upper bounds by enclosing polygons.

Interestingly, this remained the most accurate approximation to \(\pi\) found in historical manuscripts for several centuries to follow, being independently rediscovered by Dutch mathematician Adriaan Anthonisz only in 1585.

Moreover, this is even more impressive when considering that the necessary calculation of the area of a 24,576-sided regular polygon was made purportedly using only arrangements of wooden sticks known as counting rods.

The Chinese abacus, also known as the suanpan (算盤), is likely to have been extant in some early form during the 5th Century, though (my) knowledge of the extent of its usage and its capabilities at the time is limited.