$$ \def\ud{\mathrm{d}} \def\Money{\mathrm{Mon\vec{e_{\displaystyle{y}}}}} $$
In the study of ancient astronomy:
... the epicycle is made to move in longitude in the order of the signs in a circle concentric with the Zodiac [i.e., from west to east], while the planet moves on the epicycle at a velocity which is the same as that of the anomaly; on that part of the epicycle farthest from the earth the motion is direct.
The main objective of this article is to explain how to create epicycles moving in a certain shape. For example, a motion could be as complicated as which is represented below:
Let us represent a motion in points with complex numbers. For example, $(x, y)$ correspond to $x+iy$, where $i$ is $\sqrt{-1}$.
Remeber the addition of two complex numbers in a complex plane is similar to the addition two 2-dimension vectors, i.e. $$z = z_1 + z_2 $$ has a similar effect to $$\vec r = \vec{r_1} + \vec{r_2}$$
Besides, a circular motion can be represented by $$\vec r = (r \cos (\frac{2\pi t}{P}+\varphi), \, r \sin (\frac{2\pi t}{P}+\varphi)) $$ where $r$ is radius, $P$ is period, and $\varphi$ is the phase angle.
And the combination of several epicycle movement could be shown as $$\vec r = \vec{r_1} + \vec{r_2} + \ldots + \vec{r_N}$$
Or, more briefly, as $e^{ix} = \cos x + i\sin x$(where $e=2.718281\ldots$ is the base of natual logrithm), let us write $$z=r e^{i (\frac{2\pi t}{P} + \varphi)}$$
Now, we can describe a series of epicycles as $$s_N(t) = r_1 e^{i (\frac{2\pi \omega_1 t}{P} + \varphi_1)} + r_2 e^{i (\frac{2\pi \omega_2 t}{P} + \varphi_2)} + \ldots + r_N e^{i (\frac{2\pi \omega_N t}{P} + \varphi_N)} = \sum_{n=1}^N r_n e^{i (\frac{2\pi \omega_n t}{P} + \varphi_n)}$$
Consider the motion given by a $\mathbb{R} \rightarrow \mathbb{C}$ function $f(t)$.
As Norwood Russel Hanson pointed out in his essay The Mathematical Power of Epicycle Astronomy, the distance between corresponding two orbits can be less than any positive number $\epsilon$. Thus, we can use the epicycles to represent any plane motion.
Remember the Fourier Series given by the following equation: $$c_n = \frac{1}{P}\int_0^P f(t) \cdot e^{-i \frac{2\pi n t}{P}} \ud t$$
The inversed transform is defined as follows:$$s_N(t) = \sum_{n=-N}^N c_n \cdot e^{i \frac{2\pi n t}{P}} $$which is already quite similar to the above equation.
What's more, $r e^{i (\frac{2\pi n t}{P}+\varphi)}$ equals to $c e^{i \frac{2 \pi n t}{P}}$, where $c \in \mathbb{C}$ and $c = r\cos\varphi + i r\sin\varphi$. To calculate the real number $r$ and $\varphi$, we have $r = |c|$ and $\varphi = \mathrm{atan2}(\mathfrak{Im}\{c\},\, \mathfrak{Re}\{c\})$
In this way, we can explain any periodic plane motion by the epicycle-on-deferent theory.
The above method is mathematically correct, however, when computing using a computer, the accurate computation with a huge amout of integral is not efficient. It is neither unrealistic to calculate an arbitrary motion originally on a piece of paper. Therefore, we need another approach to solve this problem.
Remember the Discrete Fourier Transeform, which is defined as$$y_k = \sum_{n=0}^{N-1} x_n \cdot e^{-i \frac{2\pi k n}{N}}$$
This can be done in a really fast speed using Fast Fourier Transform(fft), an algorithm within the time limit of $\Theta(n \log_2 n)$.
To convert the integration part into a fft calculation, let us write $$c_n = \frac{1}{P}\int_0^P f(t) \cdot e^{-i \frac{2\pi n t}{P}} \ud t = \frac{1}{P} \cdot \lim_{N \to +\infty}\sum_{k=0}^{N-1} f(\frac{k P}{N}) \cdot e^{-i \frac{2\pi n}{P} \cdot \frac{k P}{N}} \cdot \frac{P}{N} $$
Shall we choose a large number $N$. In order to satisfy the algorithm of fft, we may choose some of these powers of 2(e.g. 1024), and $f(\frac{k P}{N})$ could be a pre-prepared complex-varible sample array $\{a_1, \, a_2, \, \ldots, \, a_k\}$. Now, we have $$c_n = \frac{1}{N}\sum_{k=0}^{N-1} a_k \cdot e^{-i \frac{2\pi k n}{N}}$$ which exactly matches the formula of the Discrete Fourier Transform.
While the Inversed Discrete Fourier Transform is defined as$$x_n = \frac{1}{N}\sum_{k=0}^{N-1} y_k \cdot e^{-i \frac{2\pi k n}{N}}$$
It is not difficult to relate this equation to the movement of epicycles:$$s_N(t) = \sum_{n=0}^{N-1} c_n \cdot e^{-i \frac{2\pi n}{N} \cdot \frac{N t}{P}} = \sum_{n=0}^{N-1} c_n \cdot e^{-i \frac{2\pi n t}{P}}$$
The above method is also mathematically correct. However, some coefficients with large modules are likely to appear at the end of the fft output array. In this way, although all sample points are passed by the last epicycle, the $s_N(t)$ curve cannot match the original motion. But there is a simple solution.
From the Discrete Fourier Transform equation we find that the iterater $n$ values from $0$ to $N$, which is not necessary. Since $e^{\frac{2\pi k}{N}} = e^{\frac{2\pi k}{N}} / e^{\frac{2\pi N}{N}} = e^{\frac{2\pi (N-k)}{N}}$, the frequency of epicycles can be reduced. Thus we have $$s_N'(t)=\sum_{n=-N'}^{N'-1} c'_n \cdot e^{-i \frac{2\pi n t}{P}}$$ where $N'=N/2$, $c'_n = c_n \textrm{ for } n \geq 0$, and $c'_n = c_{n+N} \textrm{ for } n < 0$.
Although our conclusions are based on a plane periodic motion, it should be pointed out that any motion -perodic or not, closed or open- can be represented by infinite epicycles. Besides, according to Norwood Hanson's essay, with the improvements of graphical techniques, it is possible to represent epicycles in a more complicated way, beyond the limits of the plane.
There is a program written in python which I made to convey the elegance of epicycle astronomy. It is available here: https://github.com/sclereid/epicycles
Thank you for reading.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
By sclereid in Apr 2017, as a present for someone known as $\Money$