In the days of antiquity, most astronomers worked under (the rather selfish) assumption that the Earth lay in the center of the universe. Given the predictable nature of the sun and moon, this assumption must have seemed obvious at first, but astronomers noticed some strange behavior amongst other celestial bodies. As some planets orbited the Earth, they would slow, stop, reverse direction, and then reverse direction again shortly after. This retrograde motion didn’t fit the model that all bodies simply travelled in circular paths around Earth. To address this issue, the ancient Greek astronomers Apollonius and Hipparchus developed the theory of *epicycles *around 200 BC.

They theorized that the planets had smaller “suborbits”, that is, they orbited a point which meanwhile orbited Earth (well not quite Earth, but a point near Earth called the eccentric). In the diagram below, the larger orbit is know as the *deferent*, while the smaller orbit is know as an *epicycle*. The model was extended to include multiple epicycles, where each epicycle recursively orbits around the previous one (see some of the gifs below).

This model of multiple epicycles works well in the sense that any observed planet’s orbit could be approximated with epicycles. Unfortunately this model works* too* well: a classical theorem of Fourier analysis states that any periodic function (or orbit in this case) can be approximated with such epicycles. I’ll show you what I mean.

First, we’ll need some math. Let’s represent the plane as the set of complex numbers . A circle is parametrized by which has a period of for in the interval . We visualize moving from 0 to by the red dot traveling along the larger circle in the gif below. The second circle can also be parameterized, this time by the rule . Notice that the red dot on the smaller circle is rotating in the opposite direction to the larger once, hence the minus sign in our parameterization. The movement of the red dot orbiting the smaller circle is therefore given by .

Generalizing this, we can consider any periodic curve of the form

for some natural number and complex coefficients . An epicycle corresponds to a summand in the above formula. Note that we can express a complex number where is a non-negative real number and is an angle between and and hence the coefficients determine both the radius and starting point of the red dot in the epicycle.

Now let’s say we’re astronomers in 2nd century BC and we want to come up with the epicycles that describe the orbit we observe of some planet. How can pick an appropriate and ‘s? They key is to understand two critical properties about the exponentials . The first important property is that they form a *dense *subset of the set of continuous periodic functions

This fact is not obvious (and is actually more general), but it ensures that any orbit we observe in the sky can actually be arbitrarily well approximated by finite combinations of these exponentials. The second important property is that they form an *orthonormal set*. Recall that in linear algebra, whenever we express a vector, say , we are implicitly choosing a some basis to express it. In other words, is really

.

where the are the orthonormal basis vectors. Another way to express this is via the inner product , so that

.

In the same way, the serve as coordinates in terms of the basis . Hence we could (though we won’t in the future) express our orbit as a vector with infinity many coordinates

.

By the analogy with , if we had an inner product on (a function space), then we would hope given some that

is a good approximation for . Indeed it is, if we take the inner product in to be the continuous and complex analog of the inner product in , i.e. for we define

.

As we take to infinity, we get a better and better approximation of by exponentials, which in fact converges uniformly. Now let’s see some examples.

Our function above is a piecewise continuous function whose image in the plane looks like a triangle. We approximate it with five epicycles and see that it does a pretty decent job. It only has trouble with the sharp corners, which has to do with the smoothness of the functions , so we’ll need a much larger to make it more precise.

Here’s an example of various levels of precision when approximating the blue path below:

Above we have (roughly) the same curve approximated with five, fifteen, and thirty-one epicycles.

As we can see, if one models the orbits of plants with epicycles, there’s no reason why some of the above curves couldn’t be the paths of planets near Earth. It was only until Kepler did these theories fall out of favor and become replaced with his model of elliptical orbits. All of the above gifs were made (by me) in Processing, a language geared towards visual arts. Some (very hacked together) code is available on my github.