One way to approximate Ï€ is to find the areas of polygons inscribed inside a circle and polygons circumscribed outside the circle. The approximation improves as the number of sides in the polygons increases. This idea goes back at least as far as Archimedes (287â€“212 BC). Maybe youâ€™ve tried this. Itâ€™s a lot of work.

In 1667 James Gregory came up with a more efficient way to carry out Archimedesâ€™ approach. Tom Edgar and David Richeson cite Gregoryâ€™s theorem in [1] as follows.

Let

I_{k}andC_{k}denote the areas of regulark-gons inscribed in and circumscribed around a given circle. ThenI_{2n}is the geometric mean ofI_{n}andC_{k}, andC_{2n}is the harmonic mean ofI_{2n}andC_{n}; that is,

We can start with *n* = 4. Obviously the square circumscribed around the unit circle has vertices at (Â±1, Â±1) and area 4. A little thought finds that the inscribed square has vertices at (Â±âˆš2/2, Â±âˆš2/2) and area 2.

The following Python script finds Ï€ to six decimal places.

n = 4 I, C = 2, 4 # inscribed area, circumscribed area delta = 2 while delta > 1e-6: I = (I*C)**0.5 C = 2*C*I / (C + I) delta = C - I n *= 2 print(n, I, C, delta)

The script stops when *n* = 8192, meaning that the difference between the areas of an inscribed and circumscribed 8192-gon is less than 10^{âˆ’6}. The final output of the script is.

8192 3.1415923 3.1415928 4.620295e-07

If we average the upper and lower bound we get one more decimal place of accuracy.

Gregoryâ€™s algorithm isnâ€™t fast, though itâ€™s much faster than carrying out Archimedesâ€™ approach by computing each area from scratch.

Gregory gives an interesting recursion. It has an asymmetry that surprised me: you update *I*, then *C*. You donâ€™t update them simultaneously as you do when youâ€™re computing the arithmetic-geometric mean.

## Related posts

[1] Tom Edgar and David Richeson. A Visual Proof of Gregoryâ€™s Theorem. Mathematics Magazine, December 2019, Vol. 92, No. 5 (December 2019), pp. 384â€“386