Ahoy-hoy! Today happens to be Pi day, so I thought this would be a fun break from all the C++ talk. And probably quite a bit more accessible. So think of this as a mental palette cleanser. Plus, it’ll be good to finally have some facts about π proven to you, instead of just taking them on faith. Make sure you’re sitting comfortably and have a nice cup of tea, and then we’re good to go.

**Pi: it’s easy if you tri**

The circle. Simple, inoffensive, modest. Yet it somehow exhibits an abstract, concrete perfection. Its value can be practical (the wheel), symbolic (from wedding rings to séances) or immutable and natural (celestial cycles). Now I’m gonna say something absurdly simple, try not to laugh:

All circles have the same shape. They are *similar*.

Yeah, yeah, ‘no shit, Sherlock’ etc. But think about it. Not all quadrilaterals are similar. Not all triangles are similar. For a given number of sides, there’s an infinite number of ways to be an irregular polygon, and only one way to be a *regular* polygon. Circles don’t have exceptions. If they did, they… wouldn’t be circles. So, what’s the implication here? What’s Springer’s Final Thought**™**?

For any circle, the ratio of circumference to diameter is the same. We give this constant the name π.

**Math: it’s not just for sq****uares**

Fair enough, you say, but given that, where does the whole “area = pi r squared” dealio fit in? It’s tricky to work out the area of a circle. It’s basically a polygon with an infinite number of sides! Where the hell do you start? Well, we can start by roughly approximating it, by pretending it has a finite number of sides. We’ll do this by first inscribing, say, a regular pentagon inside the circle:

(If you’re doing this at home, it’s penta*gon, *not penta*gram*. Don’t awaken something you’re not prepared for). Anyway, a pentagon can be seen as 5 triangles. Each of these triangles has two equal sides which are the same as the circle radius, r. The length of the base of the triangle is ‘b’, and the height from vertex to base is ‘h’. The area of this (or any) triangle is ½bh. Quick visual proof:

This means that the area of the polygon is 5 (number of triangles) * ½bh (area of triangle). It’s also obvious that the perimeter (our proxy for circumference) is 5b. So we can rearrange it to say that area = ½h * perimeter. Now check out what happens as we add more sides to the polygon:

- Clearly, the area of the polygon will approach the area of the circle as the number of sides, n, increases.
- The limit of h will approach the radius, r!
- The limit of the perimeter will approach the circumference, C!

- Meaning: the area is the limit of ½h * the limit of the perimeter.
- Or: ½r * C. Which is the same as saying rC/2
- Since C is 2πr, this becomes r(2πr)/2, or
- 2πr²/2, or just πr²
- Bam!

**Naysayers re-pent!**

Fine, fine, you say, bring out the big guns: how do you work out the value of π then? Well, since π = C/d, we can just approximate it ever more closely. Since we inscribe regular polygons of ever more sides into the same circle, d is gonna be the same each time. It doesn’t matter what size circle we choose as they are all similar, but we’ll say radius 1 (diameter 2) to keep the numbers from getting silly. So really, if we want to work out π, all we need to do is get a closer and closer approximation of C (the perimeter). We’ll start with an inscribed square, but before we do that, here’s an elegant visual proof of Pythagoras’ theorem, which we’ll be making much use of:

“In any right-angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.”

And if you still don’t believe me:

Right. First approximation:

Not that great a start. We’ll double the number of sides and see how much better the approximation is.

**Further hex-trapolation**

Now what we’re essentially doing is trying to find out how the perimeter of a polygon relates to the perimeter of a polygon with twice the number of sides. Here’s a closeup of one of the triangles from the inscribed square, showing how for each ‘a’ we previously had, we have 2 ‘b’ instead. Attend:

That should all make sense. That (1-x) appears because the green and yellow line goes from centre to circumference, so it has a length of 1 (the radius). Thus x and (1-x). First we find x:

Now we know what (1-x) is. So we can find out what b is (which is what we’re ultimately interested in, here) by applying pythagoras to the triangle with sides (1-x), (a/2), and ‘b’. (We’ll keep ‘x’ in the equation, and we’ll replace it at the end, otherwise it’ll look horrible).

Now we put ‘x’ in the appropriate places, and tidy the equation up (almost there):

We now have a *and* b! ‘a’ is just the square root of two (worked out from inscribing the square). Let’s put ‘a’ into ‘b’:

Remember, for circumference/perimeter, where we had four sides of length ‘a’ before, we now have twice as many sides of length ‘b’. So instead of 4a, we now have 8b. Our diameter is still 2:

**Acc-hept-able results**

We can keep approximating. Initially, we started with an ‘a’ for each side of our perimeter. When we doubled the number of sides, for each ‘a’ there was instead 2 ‘b’. Now the previous ‘b’ is playing the role of ‘a’ and there’ll be twice as many new ‘b’. Since we worked out the relationship between b and a:

Where we had 8 ‘a’, we now have 16 ‘b’ for circumference/perimeter. Diameter still 2:

You can clearly see the pattern:

Continue as many times as you want, to get better and better approximations!

**Oct and appalled (by unrelenting punnery)**

And this is how well it converges (red line is the true value of pi):

Amazing! That’s not the only approximation for pi (there is an entire freaking page of them here), but this was the easiest I could prove. Anyway, ’till next time…