Computing the area of a regular infinity-gon

This Old Post: from 2012 in my WordPress blogging era.

One of my favorite parts about calculus was learning about integrals. The mental leap I had when I realized you could compute the exact area under the curve if only you could use an infinitely small $dx$ in a Riemann sum is a particularly fond memory. That marks a major shift in my understanding of mathematics and, consequently, how I view the world around me (if you were wondering, probability theory, theory of computation, and JRPGs account for most of my other shifts). The following is a byproduct of post-calculus Nick.


If you're anything like me, occasionally you need to compute the area of a polygon. Sometimes it's for finding the barycentric coordinates of a point in a triangle; other times it's used to construct a function that selects uniformly random points from an irregularly-shaped polygon surface. The right area computation method depends on the circumstances. If it is known that a polygon will never deform, you can pre-compute the area before doing anything exciting with it. Otherwise, the area will have to be re-computed any time the polygon reports a significant deformation. If the polygon is convex (whether by construction, or verified to be so during runtime, or whatever), you can treat it like a triangle fan and find the sum of all the triangles in the fan. For n-sided regular polygons, this method should also work. Pick a vertex $v_0$ and find the area of the triangle between $v_i$ and $v_{i+1}$ for $i$ between 1 and $n - 2$. The triangle fans would look something like this:

Triangle fans all connected to a vertex on the perimter

Note the variety in triangle size. You have to compute all n triangle areas to get the proper sum. If you recognize that most triangles have a mirror on the other side of the fan, you can cut this down to about $n / 2$ area calculations. However, if you picked $v_0$ be the polygon's center and iterated over $i$ from 0 to $n$ (where $v_o =  v_n$), the fan would look like this:

Triangle fans all connected at the center.

Those triangles look much more uniform. If you know the area of a single triangle as $A$, the polygon's total area is $nA$, since there are $n$ such triangles in the regular polygon. One float multiplication can be much nicer than multiple float additions. You know, because these ideal polygon cases pop up all the time and you want your code to be efficient ;p

To find $A$, note that the triangles in the regular polygon's fan are isosceles. The two equal sides are of length $r$, the regular polygon's radius. The angle between these two sides is $2π / n  = θ$. A single triangle is shown below with labels:

Isosceles triangle in the regular polygon

The area for this triangle, and the total area of the regular polygon, are computed as such:

So in the gifs posted above, you'll notice that a regular polygon starts to look mighty circular when $n$ grows large. For a radius $r$ and center $c$, a circle is the set of points that are distance $r$ from $c$. This is an infinite set, so a circle has an infinite number of points. Since a regular polygon's points are equidistant from its center, it seems reasonable to think of circles as regular polygons with infinitely many sides. For an infinity-gon, the area formula above should evaluate to  $πr^2$. Except, you can't really substitute infinity for $n$, or you get infinity * 0, which is undefined. Like most cases when dealing with infinity, it's better to look at the limit as $n$ approaches infinity!

It's been a few years since I spoke fluent L'Hôpital's rule, so I turned to WolframAlpha for my limit-solving needs. You'll see that the limit of the area function as n approaches infinity evaluates to  $πr^2$, which is a pretty cool result to get. I was really excited, so I signed up for the free WolframAlpha Pro trial to download the step-by-step results to share here. Free users can see up to 3 step-by-step solutions per day, so you can check it out on the WolframAlpha page, too.

That's some damn fine limit substitution! So there it is. Considering circles as infinity-gons is cooler, and the math checks out, too. The rearrangement proof and triangle proof for finding the area of a circle, however, are still way cooler.