Epicycles

of 511

Error

0%

RMS distance from the outline, as a percentage of the shape’s size

10 s per turn
Show
Circle list
OrderTurns per cycleRadiusStart angle

Circles on circles

Walk once around a closed outline, with time t running from 0 to 1, and write each point as a complex number z = x + iy. Fourier’s idea, applied to this path, is that it can be written as a sum of steadily turning arrows:

z(t) =  Σk ck e2πikt

Each term is one circle. Its radius is |ck|, it turns k times for each trip around the outline (counterclockwise when k is positive, clockwise when it is negative), and it starts at the angle of ck. Set the circles end to end and the tip of the last one traces the path. The k = 0 term never turns: it is the average of all the points, and the chain starts there.

The name comes from ancient astronomy. In Ptolemy’s Almagest a planet moves on a small circle, the epicycle, whose center travels around a larger one, the deferent.

Finding the circles

A drawing is a list of points. The outline is resampled at N = 512 points spaced evenly along its length, and the discrete Fourier transform gives one coefficient for each frequency from −256 to 255:

ck = 1N N−1Σn=0 zn e−2πikn/N

With all 511 turning circles the chain passes exactly through every sample. The clef and the spiral are open lines, so their path runs out along the line and back again. A drawing that ends away from its starting point is closed with a straight line.

Why the error falls

The circles are sorted by radius, and the count you choose keeps the largest. The terms are orthogonal, so the mean squared distance between the traced curve and the samples is exactly the sum of |ck|2 over the circles left out (Parseval’s theorem). The error readout is the square root of that sum, the RMS distance, as a percentage of the shape’s width or height, whichever is larger. Each circle added takes its own |ck|2 off that sum, so keeping the largest circles gives the smallest error any choice of that many circles can reach.

A smooth, rounded outline needs only a few large circles. A corner needs many small, fast ones, and until they are added the trace rounds it off.

A square wave from odd harmonics

The same idea works on a line. A square wave that is +1 for the first half of each period and −1 for the second is a sum of sines at the odd multiples of its frequency:

f(x) = 4π (sin x + sin 3x3 + sin 5x5 + …)

4

Partial sum SN(x) at sample points
xSquare waveSN(x)

Each circle in the figure is one term, with radius 4/(πn), turning n times as fast as the first. The height of the last tip is the partial sum SN(x) of the first N odd harmonics.

At x = π/2 the series becomes (4/π)(1 − 1/3 + 1/5 − …), Leibniz’s series for π/4, so the sums swing above and below 1 and close in on it. At the jump, x = π, every term is zero, so each partial sum passes through 0, halfway between −1 and 1. Just before the jump the sum overshoots. Its highest peak, at x = π − π/(2N), moves closer to the jump as terms are added but does not fall to 1: it approaches about 1.179, an overshoot of about 9% of the jump from −1 to 1. This is the Gibbs phenomenon. It happens at every jump in a Fourier series, however many terms are added.

Keyboard

Space
Play or pause
← →
One circle fewer or more
Shift + ← →
Halve or double the circles
B
Build up from one circle
C A T O
Show or hide circles, arms, trace, outline
Esc
Cancel drawing