Fourier Analysis

Fourier Epicycles: Any Piecewise-Smooth Closed Curve Is a Sum of Rotating Circles

Fourier epicycles are the picture you get when you draw a complex Fourier series instead of plotting it. Write a closed curve in the plane as a complex-valued function z(t), 2π-periodic in t, and expand it as z(t) = ∑n∈ℤ cn eint. Each term is a circle: it has radius |cn|, it turns n times per lap (backwards when n is negative), and it starts at the angle arg cn. Join the arms tip to tail and the pen on the end of the last one retraces the curve.

The sum is exact in the limit, and it converges uniformly whenever z is continuous and piecewise C¹ — then ∑|cn| is finite, so the chain of circles has finite total length and the trace closes onto the target. Continuity alone is not enough: du Bois-Reymond built a continuous function in 1876 whose Fourier series diverges at a point. Truncate the sum and you get an honest, measurable shortfall: for the seven-cornered lightning bolt in the video, one circle misses by 29% of the figure's height, four circles by 10%, sixteen by 3.4%.

  • Statementz(t) = &sum;<sub>n&isin;&#8484;</sub> c<sub>n</sub> e<sup>int</sup>
  • One termCircle of radius |c<sub>n</sub>|, n turns per lap, start angle arg c<sub>n</sub>
  • Coefficientc<sub>n</sub> = (1/2&pi;) &int;<sub>0</sub><sup>2&pi;</sup> z(t) e<sup>&minus;int</sup> dt
  • Uniform convergenceGuaranteed if z is continuous and piecewise C&sup1; (then &sum;|c<sub>n</sub>| &lt; &infin;)
  • Decay rateA corner gives |c<sub>n</sub>| = O(n<sup>&minus;2</sup>); an analytic curve decays exponentially
  • Enclosed areaA = &pi; &sum; n|c<sub>n</sub>|&sup2; &mdash; Hurwitz's 1901 route to the isoperimetric inequality

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

What an epicycle actually is

An epicycle is a circle whose centre rides on another circle. In complex notation a single uniform circular motion is the map t ↦ c eint, where c is a complex number and n an integer. That one expression carries three independent pieces of information: |c| is the radius of the circle, n is how many turns it makes per lap of the parameter t through [0, 2π], and arg c is the angle the arm points at t = 0. The sign of n is the direction: positive n turns anticlockwise, negative n clockwise.

Chain them by adding. If the hub sits at c0, the first arm ends at c0 + c1eit, the second arm starts there and ends at c0 + c1eit + c2e2it, and so on. The pen on the end of the last arm is at the partial sum. Because addition commutes, the order of the terms changes the picture of the chain but never the path of the pen; the conventional choice, and the one used in the video, is largest radius first.

The classical astronomical epicycle is exactly the two-term case: a large circle (the deferent) carrying a small one, so the planet's position is c1eiω1t + c2eiω2t. The Fourier picture is that same construction with no cap on the number of circles and with the frequencies locked to integer multiples of one fundamental.

The complex Fourier series, term by term

Parametrise a closed curve as a 2π-periodic function z: ℝ → ℂ, so that z(t + 2π) = z(t). Any parametrisation will do; unit speed (constant |z′|, i.e. arc length rescaled to [0, 2π]) is the standard choice because it makes the coefficients depend on the shape rather than on how you chose to hurry along it.

The functions eint, n ∈ ℤ, are orthonormal for the inner product ⟨f, g⟩ = (1/2π)∫02π f̅g dt. Projecting z onto them gives

cn = (1/2π) ∫02π z(t) e−int dt,  z(t) = ∑n∈ℤ cn eint.

Two coefficients have an immediate meaning. c0 is the time-average of z, the centroid of the parametrised curve: it is the fixed hub the whole chain hangs from, and it is 0 exactly when you have already centred the curve. c1 is the term that goes round once, in step with the parameter, so a curve traversed anticlockwise once has a dominant c1; the video's bolt has |c1| = 0.5034 out of a total ∑|cn| = 1.2834, or 39% of all the radius there is.

Nothing here is a new series. It is the ordinary sine-and-cosine Fourier series of the two real coordinate functions x(t) and y(t), bundled into one complex equation. For a real function f the coefficients satisfy c−n = c̅n, and the pair collapses to a single real oscillation: cneint + c−ne−int = 2|cn| cos(nt + arg cn). Two circles of equal size turning opposite ways have their transverse components cancel and slide back and forth along a line. For a genuinely complex curve cn and c−n are independent, and that is the whole reason the epicycles can turn in both directions.

The second beat of the video is the cleanest special case: a forward and a backward circle of unequal size. c1eit + c−1e−it traces an ellipse with semi-axes |c1| + |c−1| and ||c1| − |c−1||, its major axis at angle (arg c1 + arg c−1)/2. For the bolt those radii are 0.5034 and 0.1978, giving semi-axes 0.7012 and 0.3057, with the major axis 83° from horizontal — the tall, near-vertical ellipse on screen.

Reading the picture: radius, speed, direction, phase

Once you know that one circle is one term, the animation becomes readable as data:

  • Circle size = |cn|. The bar chart in the video is the amplitude spectrum with the bars sorted by height, so the tallest bar and the biggest circle are the same object seen twice.
  • Circle speed = |n| turns per lap. A circle that whirls fast is a high harmonic; it is contributing detail, not gross shape.
  • Circle direction = sign of n. The video colours forward terms cyan and backward terms violet; the bolt needs both, and its second-largest term is n = −1, a backward circle.
  • Starting angle = arg cn. Phases carry no energy but all of the alignment. Randomise them and |cn| is unchanged while the drawing dissolves into noise — which is why an amplitude spectrum alone never determines a shape.

The ratio of |c1| to everything else is a crude roundness score. A circle traversed once has |c1| = 1 and all other coefficients 0. The bolt puts only 39% of its total radius into c1; a shape needing many comparable circles is a shape far from a circle, and the isoperimetric ratio 4πA/L² records the same fact numerically — 1 for a disc, 0.3104 for this bolt.

How many circles do you need? A measured example

The answer is set by how fast |cn| decays, and that is set by the smoothness of the curve. Integrating the coefficient formula by parts gives cn(z′) = in·cn(z): every derivative you can take buys one more power of 1/n. A curve with corners has a unit-speed velocity z′ that is piecewise constant in direction and jumps at each corner, so cn(z′) = O(1/n) and therefore |cn| = O(n−2). A curve that is analytic decays like e−a|n| and is finished in a handful of terms.

The video's target is a seven-vertex lightning bolt, sampled at 8192 equally spaced arc-length stations and transformed with an FFT. Normalised so the farthest point from the centroid is at radius 1, its perimeter is L = 5.295, its height 1.726 and its signed area 0.6926. The nine largest coefficients are

|c1| = 0.5034,  |c−1| = 0.1978,  |c3| = 0.1114,  |c−3| = 0.0894,  |c5| = 0.0428,  |c−2| = 0.0415,  |c−5| = 0.0406,  |c−4| = 0.0389,  |c2| = 0.0294,

and n²|cn| never exceeds 1.15 out to |n| = 41, which is the O(n−2) law showing up as a ceiling on the product. It is only a ceiling: O(n−2) bounds the coefficients from above and promises nothing from below, and individual terms duly fall far under it when the bolt's geometry makes the corner contributions cancel — n²|cn| dips to 0.089 at n = 4 and 0.045 at n = −39. The comparison table above gives the worst gap at 1, 2, 4, 8 and 16 circles.

One caveat worth stating plainly. The video adds circles in order of decreasing radius, which is a greedy, non-linear approximation; the classical theorems are about the symmetric partial sums SN = ∑|n|≤N cneint. On this curve the two behave almost identically at matched circle counts: eight circles greedily chosen miss by 5.7% of the height, while S4 (also eight circles, since c0 = 0) misses by 9.7%; sixteen greedy circles give 3.4% against 4.0% for S8. Greedy wins slightly here, but not as a matter of law: what greedy provably minimises is the mean-square error, because by Parseval the squared error of any chosen set is the sum of the dropped |cn|² and keeping the largest is therefore optimal. The table measures the worst gap, a sup-norm quantity that L²-optimality does not control, so on another curve the symmetric sum could perfectly well come out ahead.

Where the picture is a proof, and where it is only an illustration

Watching a trace settle onto a target is evidence about one curve, not a theorem. The theorems are these.

Absolute convergence. If z is continuous and piecewise C¹, then z′ ∈ L², and Cauchy–Schwarz with Parseval gives ∑n≠0|cn| = ∑|cn(z′)|/|n| ≤ (∑ 1/n²)1/2(∑|cn(z′)|²)1/2 < ∞. The series then converges absolutely and uniformly, so the chain of circles has finite total length and the epicycle picture is literally correct. Every polygon, every spline, every SVG path you are likely to feed it satisfies this.

Continuity is not enough. Paul du Bois-Reymond exhibited a continuous 2π-periodic function in 1876 whose Fourier series diverges at a point. Andrey Kolmogorov went further in 1926 with an L¹ function whose Fourier series diverges everywhere. Dirichlet's 1829 criterion and Jordan's 1881 strengthening supply the standard positive result: bounded variation plus continuity gives uniform convergence. Lennart Carleson proved in 1966 that for z ∈ L² the series converges almost everywhere, and Richard Hunt extended it to Lp, p > 1, in 1968.

Gibbs, and where it does and does not appear. The 9% overshoot familiar from square waves — the Wilbraham–Gibbs constant, (2/π)Si(π) − 1 = 0.17898, i.e. 8.949% of the jump, found by Henry Wilbraham in 1848 and rediscovered by J. Willard Gibbs in 1899 — happens at a jump discontinuity. A closed curve has none: its position is continuous, so with bounded variation the partial sums converge uniformly and the trace shows no ringing. The overshoot moves one derivative up. The velocity z′ really does jump at each corner, so the partial sums of the velocity overshoot by 8.949%, and that is visible as a slight hesitation of the pen as it rounds a corner rather than as a bulge in the drawn line.

So: the animation is an illustration of a convergence guaranteed by the hypotheses on that particular curve. It shows the mechanism honestly and the measured gaps are real; it proves nothing about curves that violate the hypotheses.

Ptolemy, Fourier, and the epicycle myth

The construction is ancient. Apollonius of Perga introduced the deferent-and-epicycle device around 200 BC, Hipparchus used it about 150 BC, and Claudius Ptolemy systematised it in the Almagest around AD 150. Joseph Fourier's trigonometric series arrived far later: his prize memoir on heat conduction went to the Paris Academy in 1807, took the prize in 1811 over Lagrange's objections about convergence, and became the Théorie analytique de la chaleur in 1822.

The formal link was made explicit by Norwood Russell Hanson in The Mathematical Power of Epicyclical Astronomy (Isis 51, 1960, pp. 150–158): a chain of uniform circular motions is a truncated Fourier series, so with enough circles it can fit any closed periodic orbit to arbitrary accuracy.

That result is often misquoted into a myth. The picture of medieval astronomers piling epicycles upon epicycles until the sky fitted is not what the Almagest contains. Ptolemy's planetary models use one epicycle per planet, carried on an eccentric deferent, with the deferent's rotation uniform not about its own centre but about a third point, the equant. That is a handful of circles, not a tower of them. It also means Ptolemy's system is not literally a Fourier series: the equant makes the deferent's angular rate non-uniform, and a Fourier term is by definition a uniform rotation. The sharpest way to say it is that epicycles have the expressive power of Fourier series, that Ptolemy did not exploit that power, and that the Copernican argument against him was never about the arithmetic being unable to fit.

From epicycles to the FFT: drawing your own curve

The recipe is short and entirely mechanical.

  1. Get a closed path. One loop, first point equal to last. An SVG outline, a traced silhouette, a polygon.
  2. Resample at equal arc length. Take N points (N = 4096 is plenty) spaced evenly along the perimeter and read them as complex numbers zk = xk + iyk. Equal spacing is what makes the coefficient decay reflect the shape rather than your sampling.
  3. Run one FFT. cn = (1/N)∑k zk e−2πink/N, which is exactly numpy's fft(z)/N. The N outputs cover frequencies −N/2 … N/2 − 1; anything faster aliases, which is the discrete sampling theorem doing its usual job.
  4. Sort by |cn|, keep the top K, and draw. Place circle n at the running partial sum, radius |cn|, angle arg cn + nt.

Step 3 is the reason this is a toy rather than a computation. The naive sum is O(N²): at N = 4096 that is 16,777,216 complex multiplications. The Cooley–Tukey algorithm, published as An Algorithm for the Machine Calculation of Complex Fourier Series (Math. Comp. 19, 1965, pp. 297–301), does it in (N/2)log2N = 24,576 — a factor of 683 at this size, and growing. Gauss had the same radix-2 idea in 1805 for interpolating asteroid orbits, in a note published only posthumously in his collected works in 1866.

Two properties are worth checking on your own coefficients, because they catch bugs immediately. Parseval: (1/2π)∫|z|² dt = ∑|cn|² — 0.321581 on both sides for the bolt. And the signed area of the curve is A = π ∑ n|cn|², which returns 0.692562 against a shoelace area of 0.692562. That second identity is not a curiosity: combined with (L/2π)² = ∑ n²|cn|² for a unit-speed curve, and n ≤ n², it gives A ≤ L²/4π at once — Adolf Hurwitz's 1901 proof of the isoperimetric inequality, in two lines, from the same coefficients that drew the picture.

Truncating the epicycle chain on the video's lightning bolt (7 corners, unit-speed parametrisation, scaled so the farthest point from the centroid sits at radius 1; height 1.726, &sum;|c<sub>n</sub>| = 1.2834). The gap is the largest distance between the partial trace and the true curve over a full lap, measured at 8000 sample phases.
Circles kept (largest |c_n| first)Share of the total radius &sum;|c_n|Worst gap, % of the bolt's heightWhat the trace actually looks like
1 &nbsp;(n = 1)39.2%29.3%A plain circle &mdash; the curve's average rotation, nothing else
2 &nbsp;(n = 1, &minus;1)54.6%19.8%An ellipse, semi-axes |c<sub>1</sub>|+|c<sub>&minus;1</sub>| and ||c<sub>1</sub>|&minus;|c<sub>&minus;1</sub>||; still no corners
4 &nbsp;(adds n = 3, &minus;3)70.3%10.4%A lopsided S &mdash; the zigzag is hinted at, every corner is rounded off
8 &nbsp;(adds n = 5, &minus;2, &minus;5, &minus;4)83.0%5.7%Recognisably the bolt; corners present but blunt
16 &nbsp;(adds n = 2, &pm;7, &pm;9, &minus;8, &minus;6, 6)91.1%3.4%Sits on the target; the residual is visible only at the sharpest corner

Frequently asked questions

Can a chain of rotating circles really draw any shape?

Any <em>closed</em> curve, and with a qualification. The circles produce the Fourier series of the parametrisation, and that series converges uniformly to the curve whenever the curve is continuous and piecewise C&sup1; &mdash; which covers polygons, splines and every practical SVG path. Continuity by itself is not sufficient: du Bois-Reymond constructed a continuous function in 1876 whose Fourier series diverges at a point. Open curves and curves you want traversed once and abandoned do not qualify; you have to close them into a loop first, and the loop is what gets drawn.

How many circles do I need?

It depends entirely on smoothness, not on how complicated the shape looks. Corners make |c<sub>n</sub>| decay like 1/n&sup2;, so the error falls roughly like 1/K in the number of circles K; an analytic curve decays exponentially and is done in a dozen terms. For the seven-cornered bolt in the video, measured as the worst distance from the true curve over a full lap: 1 circle misses by 29% of the figure's height, 2 by 20%, 4 by 10%, 8 by 5.7%, 16 by 3.4%, 64 by 0.8%. Roughly speaking, quadrupling the circles cuts the error by a factor of three or so &mdash; consistent with the 1/K law, and a good deal better than merely halving it.

What does a negative n mean?

The circle turns clockwise instead of anticlockwise, at |n| turns per lap. Positive and negative frequencies are genuinely independent for a complex-valued curve, which is why real drawings need both; the bolt's second-largest term is n = &minus;1. For a real-valued signal they are not independent &mdash; c<sub>&minus;n</sub> = c&#773;<sub>n</sub> &mdash; and each conjugate pair of counter-rotating circles collapses to a single back-and-forth oscillation 2|c<sub>n</sub>|cos(nt + arg c<sub>n</sub>) along a line.

Is this the same as the sine-and-cosine Fourier series?

Yes, rewritten. Splitting z(t) into x(t) and y(t) and expanding each in sines and cosines gives exactly the same information; the complex exponential just packages a cosine and a sine of the same frequency into one rotating vector, via e<sup>i&theta;</sup> = cos&theta; + i sin&theta;. The conversion is a<sub>n</sub> = c<sub>n</sub> + c<sub>&minus;n</sub> and b<sub>n</sub> = i(c<sub>n</sub> &minus; c<sub>&minus;n</sub>). The exponential form is preferred here because one term is then one circle, which is what makes the picture readable.

Does the Gibbs phenomenon spoil the drawing at corners?

Not in the position, and this trips people up. The Gibbs overshoot &mdash; 8.949% of the jump, the Wilbraham&ndash;Gibbs constant from 1848 and 1899 &mdash; occurs at a jump discontinuity. A closed curve's position is continuous, so if it also has bounded variation the partial sums converge uniformly and the trace has no ringing; you can see this in the measured gaps, which fall monotonically. The discontinuity has moved to the velocity, which really does jump at each corner, so the ringing shows up as a slight hesitation of the pen rounding a corner rather than as a bulge in the drawn line.

Did Ptolemy's astronomy stack epicycles on epicycles?

No. The <em>Almagest</em> (c. AD 150) uses one epicycle per planet, carried on an eccentric deferent whose rotation is uniform about a separate point, the equant &mdash; a handful of circles, not a tower. The tower is a modern caricature. There is a real mathematical point underneath it, made precisely by N. R. Hanson in 1960: chains of uniform circular motions are truncated Fourier series and so can fit any closed orbit. But Ptolemy never used that power, and the equant actually takes his model outside the Fourier family, because a Fourier term is a uniform rotation and the equant makes the deferent's rate non-uniform.