How it works
From a circle to a dragonfly
Twenty-four short steps, from a single point on a circle to the method that drew the dragonfly above and the numbers that encode it. You need school maths: coordinates, graphs of functions and Pythagoras. Each step has a live demo, a Try this, a quick check and, for the curious, Show the math.
Part ICircles make waves
1A point on a circle
Draw a circle of radius 1 around the origin of a coordinate grid. Pick an angle θ (the Greek letter theta), measured anticlockwise from the positive x-axis, and walk out in that direction until you reach the circle. Your horizontal distance from the centre is called the cosine of θ, written cos θ, and your height is the sine, sin θ. So the point on the circle is simply (cos θ, sin θ).
The radius and the two distances form a right triangle whose longest side is 1. Pythagoras then gives the most useful identity in trigonometry: cos²θ + sin²θ = 1.
Try this Set θ to 0°, 90°, 180° and 270° and read the coordinates. Then compare 30° with 60°: the two numbers swap places.
Check What are cos θ and sin θ at θ = 180°?
cos 180° = −1 and sin 180° = 0: the point is at the left end of the circle, (−1, 0). Left of the y-axis the cosine is negative; below the x-axis the sine is.
Show the math
For a circle of radius R the point at angle θ is (R cos θ, R sin θ). In the right triangle, the side next to the angle is R cos θ and the side opposite is R sin θ, which is the school definition “adjacent over hypotenuse”. Pythagoras:
2Radians: measuring angles by distance
Degrees are an arbitrary choice: someone decided that a full turn is 360. There is a more natural unit. Walk along the circle of radius 1 and measure how far you walked. That distance is the angle, in radians.
A full turn is the whole circumference, 2π ≈ 6.28, so 360° = 2π, 180° = π and 90° = π/2. One radian, the angle you get by walking exactly one radius, is about 57.3°. From here on all angles and times are in radians: when an arrow below has turned by t, its tip has walked the distance t along a circle of radius 1.
Try this Set the distance to 3.14 and check that you are exactly halfway round. Then find a quarter turn.
Check How many radians is 45°?
A quarter of π: π/4 ≈ 0.785. In general, radians = degrees × π / 180.
Show the math
On a circle of radius R, an angle of θ radians cuts off an arc of length s = Rθ. With R = 1 the arc length and the angle are the same number. Converting:
Radians keep later formulas clean: a point that turns at one radian per second moves along the unit circle at speed exactly 1.
3Sine is a wave
Now let the point go round and round at a steady pace, one radian per second, and draw its height against time. The graph is the sine curve, y = sin t. It repeats every 2π, because after a full lap the point is back where it started: sin(t + 2π) = sin t. Functions that repeat like this are called periodic, and 2π is the period.
The horizontal position draws cos t: the same curve, shifted a quarter lap to the left.
Try this Watch where the height crosses zero: at 0, π and 2π. Turn on the cosine and check that it peaks exactly where the sine crosses zero.
Check What is sin(π/2), and where is the point at that moment?
sin(π/2) = 1. After a quarter lap the point is at the top of the circle, (0, 1).
Show the math
The last identity says the cosine is the sine with a head start of a quarter lap.
4Size, speed and starting point
Three knobs change a spinning arrow. A longer arrow, radius R, makes taller waves: the amplitude. Spinning k times per lap squeezes k waves into the time of one: the frequency. Starting the arrow at an angle φ (phi) slides the wave sideways: the phase. Together they give R cos(kt − φ).
Every such wave can also be written as a mix of a plain cosine and a plain sine of the same speed, a cos kt + b sin kt. The two numbers a and b are all we need to remember about one circle, and the rest of this page is about finding them.
Try this Set the speed to 3 and count the bumps. Then change only the phase and watch the wave slide without changing shape.
Check A circle with R = 2 and k = 3: how high does the wave go, and how many full waves fit into one lap?
It swings between −2 and 2, and three full waves fit into each lap of 2π.
Show the math
This is the angle-difference formula cos(α − β) = cos α cos β + sin α sin β with α = kt and β = φ. Going back, , and φ is the angle of the point (a, b).
Part IIAdding things up
5Adding waves
To add two functions, add their values at every moment: (f + g)(t) = f(t) + g(t). On a graph you stack one wave on top of the other. The cursor below does exactly that: the teal bar is f at that moment, the yellow bar is g stacked on it, and the sum is where the yellow bar ends.
Waves of different speeds add up to shapes that are no longer simple waves: a slow wave plus a small fast one already looks a little square.
Try this Give g speed 3 and height 0.35, then speed 5. Then make both speeds equal: the sum is a plain wave again.
Check At some moment f = 0.6 and g = −0.8. What is f + g there?
−0.2. A negative value pulls the sum down.
Show the math
Two waves of the same speed always add up to one wave of that speed:
Waves of different speeds never merge like this, which is why every speed needs its own circle.
6Arrows add tip to tail
An arrow from the origin to the point (x, y) is called a vector. To add two arrows, put the tail of the second on the tip of the first. The sum runs from the start of the first to the tip of the second. In coordinates it is even simpler: add the x parts and add the y parts.
This is the whole idea behind chains of circles: every circle is an arrow, and the chain adds them up.
Try this Point a and b in opposite directions with equal lengths: the sum vanishes. Then make the sum point straight up.
Check (3, 1) + (−1, 2) = ?
(2, 3). Add the x parts, 3 + (−1) = 2, and the y parts, 1 + 2 = 3.
Show the math
An arrow of length R at angle θ has the coordinates (R cos θ, R sin θ), as in step 1.
7Circles on circles
Now let each arrow spin at its own speed and chain them tip to tail. The first arrow turns once per lap. The second sits on its tip and turns at its own speed, the third sits on the second. At every moment the last tip is the sum of all three arrows, and it traces a closed curve: after one lap every arrow is back where it started, because all the speeds are whole numbers. A negative speed turns the arrow the other way.
Writing long sums gets tedious, so mathematicians use the Greek capital sigma: means arrow₁ + arrow₂ + arrow₃.
Try this Set arrow 3 to length 0 and arrow 2 to speed −1: an ellipse. Now give arrow 2 speed 2.5: the pen ends half a turn off and the curve no longer closes. Finally set the speeds to 2, 4 and −6: they share the factor 2, and the pen goes round the same curve twice per lap.
Check What does mean, and what is it?
1 + 2 + 3 + 4 = 10. The k under the Σ counts from 1 up to the number on top.
Show the math
With arrow lengths , speeds and start angles , the tip is at
Each coordinate is a sum of waves, so the curve repeats with period 2π whenever every is a whole number.
8Building a square wave
Chains can build shapes no single circle can. Here the circles have speeds 1, 3, 5, 7 … and radii shrinking as 1, 1/3, 1/5 …, and we follow only the height of the last tip. The sum becomes a square wave: flat at +1, a jump, flat at −1. More circles make the corners sharper, but a small overshoot next to each jump never goes away.
Try this Go from 1 to 25 circles and watch the corners sharpen. Look at the little horn next to each jump: it gets narrower, but not lower.
Check Why are only the odd speeds 1, 3, 5 … used?
The square wave looks the same if you shift it by half a lap and turn it upside down. Odd-speed sines share that property and even-speed ones do not, so the even ones are measured as zero (step 14 shows how such measuring works).
Show the math
This is the Fourier series of the square wave. Near each jump the partial sums overshoot by about 9 % of the jump height however many terms you add; the overshoot only gets narrower. This is the Gibbs phenomenon, and it is why sharp corners in a drawing need many circles.
Part IIIDrawings are two waves
9A curve is two functions
One function gives one number at each moment. A point in the plane needs two, an x and a y. So give each its own function of time, x(t) and y(t), and send a pen to (x(t), y(t)). As t runs, the pen draws a curve. The pair (cos t, sin t) draws the unit circle; two sine waves with different speeds draw the looping Lissajous figures known from oscilloscopes.
Try this a = 1, b = 2, δ = 90° draws a figure of eight. a = 1, b = 1, δ = 90° draws a circle. Then try a = 3, b = 2.
Check Which x(t) and y(t) draw a circle of radius 2?
x(t) = 2 cos t and y(t) = 2 sin t.
Show the math
A curve given this way is called a parametric curve, t ↦ (x(t), y(t)). It is closed when both functions repeat with period 2π. The demo draws
10Any drawing is two waves
Turn this around. Trace any closed outline at a steady pace and record where the pen is. Its horizontal position x(t) and its vertical position y(t) are two separate signals, and after one lap both are back where they started. Step 7 showed that chains of circles produce exactly such repeating signals. So one chain makes x(t), another makes y(t), and together they steer the pen.
That is the picture at the top of the page: the teal chain drives x, the yellow chain drives y, and the dashed lines carry each value to the pen.
Try this Follow the teal x(t) curve while the pen goes round the left half of the heart, then the right half.
Check After the pen has gone exactly once round, what are x(2π) and y(2π)?
The same as x(0) and y(0): the pen is back at its start, so both functions repeat with period 2π.
Show the math
Each coordinate is a -periodic function, so each has its own Fourier series: coefficients for x and for y, exactly the two sums shown in the playground.
11What a chain stores
Put the last two steps together. A drawing is two waves, x(t) and y(t), and each wave is made by its own chain of circles. Every circle in a chain is the spinning arrow of step 4, and in the equation it is one term, R·cos(k·t − φ). Each of its three numbers has one job:
- Radius R, the number in front: the arrow’s length. This term can never move the pen further than R in either direction.
- Speed k, the number multiplying t. During one lap of the pen, time t runs from 0 to 2π, so k·t runs from 0 to k·2π: the angle grows k times as fast, and the arrow turns k times while the pen goes round once. With 1·t it turns once, with 2·t twice, with 3·t three times.
- Phase φ, the number subtracted inside the cosine: it shifts the angle the arrow starts at, so the circles do not all begin pointing the same way.
Only R and φ are stored as numbers. The speed is never written down, because the terms always come in the same order: the first has 1·t, the second 2·t, the third 3·t, so a term’s place in the list is its speed. Add the centre of the drawing and the whole heart is: a centre, plus one (R, φ) pair for every circle in each chain. The equations under the tables are exactly that list written out; click any term, row or circle to read its three numbers in words.
The playground’s shape. At the top of the page the same sums are written as . That is the same term in a different shape (step 4): expanding gives and (for the y-chain the playground calls them and ). Going back, and is the angle of the point . So a circle can be stored as (R, φ) or as (a, b): two numbers either way. The tables show both, the switch under them writes the equations in either shape, and the card works the conversion out for the selected term.
Why exactly 1, 2, 3 …? Two things decide it. First, whole speeds are what make the curve close: after one lap an arrow at speed k has made k turns, which lands exactly on its start only when k is whole. That suits the gallery, whose outlines are all closed loops; the next step shows what the circles do with an open stroke. Second, none of the whole speeds can be left out: a drawing traced once per lap can have some size at every speed, and dropping one changes the shape (the next step lets you try). A list like 2, 4, 6 … is no real alternative either: it is 1, 2, 3 … in disguise, with the pen going round the shape twice per lap. So the list holds every whole speed, a shape that does not need one simply gets radius 0 there, and the only free choice is the unit: speed 1 means one turn per lap of the pen.
The same pattern sets the notes of a guitar string, which can only vibrate at whole multiples of its lowest frequency because each wave must fit the string exactly. Musicians call those multiples harmonics, which is why the playground counts its circles as harmonics too.
Two questions remain: how to find these numbers for any drawing (Part IV), and how to pack both chains into one tidy list (Parts V and VI).
Try this Click the speed-3 term of the x-chain and watch its circle (drawn in white): it goes round three times while the pen draws the heart once. Then move the slider and watch new terms appear at the end of both equations.
Check How many numbers describe the heart with 5 circles per chain?
22. Each circle stores a radius and a phase; the speeds 1 … 5 are implied. That is 2 chains × 5 circles × 2 numbers = 20, plus 2 for the centre.
Check Could a chain use the speeds 1, 1.5, 2, 2.5 …?
Not for a drawing traced once per lap. After one lap the arrow at speed 1.5 has made one and a half turns and points the opposite way, so the pen is not back at its start and the curve does not close. It would close only after two laps, and then each lap draws a different part of the curve.
Show the math
With and (step 4) the first sum is the playground’s , and likewise for y. The numbers in this demo use y pointing up.
Closing after one lap means for every t. For one term,
which equals for every t exactly when is a whole number of turns, that is when k is a whole number. If every speed is a multiple of d, then already : the curve repeats d times per lap.
12Breaking the rules
The last two steps made three claims: whole speeds close the curve, a drawing traced once per lap needs its whole list of speeds, and the speeds must be exactly whole. A fourth question is what the different speeds are for at all. Here you can break each rule and watch both the drawing and its numbers; the tables and equations under the demo work as in step 11.
- Open stroke. The letter C has two separate ends. Ask the circles to draw it in one lap, from the top tip round to the bottom tip, and they cannot stop there: whole speeds bring every arrow, and so the pen, back to its start at the end of each lap. With no time left, the circles make a fast dash from the bottom tip back up to the top, and the C becomes a D. The double ring shows where the pen should be: when it jumps back to the top, the circles’ pen has to race after it, overshooting at both ends of the dash (step 8). Drawn there and back instead, the pen walks back along the C and really does end where it started, so no jump is needed. The gallery uses this trick to join separate strokes (step 24).
- Leave speeds out. The heart with 8 circles per chain; choose what to leave out. Nothing is the reference heart; the other choices strike rows out of the tables and terms out of the equations. Leave out the odd speeds, so only 2, 4, 6, 8 remain, and every arrow is back after half a lap: the pen goes round twice, and each point it draws is the average of a heart point and the point half a lap later. Leave out the even speeds and the second half of each lap is the first half turned 180° around the centre. Leave out speed 1 and the heart loses its overall shape.
- Speeds off whole numbers. Multiply every speed by 1.05: the speed column and the equations now read 1.05, 2.1, 3.15 … After one lap speed 1 has made 1.05 turns and speed 2 has made 2.1; none of the arrows is back where it started, so the pen misses its start and every lap draws a different, distorted heart.
- Same speed for all. Give every circle the same speed. Arrows that turn together keep their angles to each other, so a whole chain moves like one rigid arrow: it is really a single circle, its arrows added tip to tail (step 6). Two single circles, one per chain, can only draw an ellipse, whatever the radii and phases. Different speeds are what make any other shape.
Try this In Open stroke, keep 6 circles and switch between Once and There and back: watch the yellow dash appear and disappear, and compare the two tables. In Leave speeds out, start from Nothing, then leave out the odd speeds and see which rows are struck out and which terms vanish. In Speeds off whole numbers, click a term: the card says how many turns that arrow makes per lap.
Check Drawn once, where does the curve cross the gap between the two tips of the C?
Halfway. A sum of circles cannot jump instantly, so at a jump it passes the average of the two sides. Fourier series always do this at a jump, and the wobbles next to it are step 8’s overshoot.
Check With the odd speeds left out, the pen draws something else, twice. Could the even speeds alone draw the real heart?
Yes, if the heart were traced twice per lap. Speeds 2, 4, 6 … carrying the heart’s numbers for 1, 2, 3 … draw the full heart in half a lap and then again. They fail here only because these numbers were measured for a heart traced once per lap.
Check With every circle at speed 1, how many numbers does the drawing really need?
Six: the centre (2 numbers) plus one radius and one phase for each chain (2 + 2). However many circles the table lists, at a common speed they add up to a single circle per chain.
Show the math
because : adding the copy half a lap later cancels the odd speeds, subtracting it cancels the even ones. At a jump the partial sums tend to the midpoint of the two sides. Drawing a stroke there and back makes it symmetric in time, so only cosines are needed; measured against the stroke alone their speeds are . That is the idea behind the cosine transform used by JPEG. With every speed scaled by s, one lap turns arrow k by , a whole number of turns for every k only when s is whole.
At a common speed the terms merge: with , the arrows added tip to tail. One such wave for x and one for y trace an ellipse.
Part IVFinding the circles
13Averages over one lap
We still need a way to find out which waves are hidden in a signal. The tool is the average over one lap. Think of the graph as a landscape: area above the axis counts as plus, area below as minus, and the average is the net area divided by the length of the lap, 2π.
A plain sine has exactly as much area above as below, so it averages to 0. Its square, sin² t, is never negative and averages exactly ½.
Try this Compare sin t · sin 3t (two different speeds) with sin 2t · sin 2t (the same speed twice).
Check What is the average of cos t + ½ over one lap?
½. The cos t part averages to 0 and the constant ½ stays.
Show the math
The area under f between 0 and 2π is written as an integral, , so the average over one lap is
Why sin² averages to ½: sin² t + cos² t = 1 (step 1), and over a full lap sin² and cos² are the same curve shifted, so each takes half of the 1.
14The wave detector
Here is the key trick. Multiply the signal by a test wave, say sin 3t, and average. Every part of the signal with a different speed gives a product that averages to zero, just like sin t · sin 3t in the previous step. Only the part with the same speed and the same kind survives, and it averages to half its height. So twice the average is exactly the amount of that wave in the signal.
The signal below is secretly 0.8 cos t + 0.5 sin 3t + 0.3 cos 5t. The detector finds each of the three numbers.
Try this Find all three hidden numbers. Then test sin 2t and cos 3t: both read 0, because those waves are not in the signal.
Check If the signal were just 0.7 sin 2t, what would the test wave cos 2t detect?
0. A cosine and a sine of the same speed are a quarter lap apart, and their product averages to zero too.
Show the math
For whole numbers j, k ≥ 1:
These follow from product-to-sum formulas such as , because a cosine with a nonzero speed averages to 0. Hence
15From averages to the formulas
Run the detector at every speed and you have all the circles: the a’s and b’s for x(t), the c’s and d’s for y(t). Written with integrals, “twice the average” becomes the textbook Fourier formulas below.
A computer cannot average a smooth curve exactly, so it looks at the curve at many evenly spaced moments (here 32 768 of them) and averages those numbers instead: a sum. The chart shows the circle sizes found this way for the shape you picked in the playground, on a logarithmic scale. Most of the size sits at low speeds; the fine detail lives in the long tail.
Try this Pick the heart in the playground, then the dragonfly, and compare how fast the bars shrink as the speed grows.
Check The app samples 32 768 points. Roughly how many speeds per direction could it detect at most?
About half of that, 16 384: a wave needs at least two samples per bump to be seen at all. The playground stops at 8192 to stay well inside that limit.
Show the math
The app samples every outline at evenly spaced points. It writes each point (xj, yj) as one complex number : not a third coordinate, just both coordinates carried together (steps 16 and 17 explain the i and the e). It then computes all coefficients at once with the discrete Fourier transform, evaluated by a fast Fourier transform in steps:
Part VComplex numbers: one chain
16Complex numbers are arrows
We keep carrying points around as pairs (x, y). Complex numbers pack such a pair into one number, z = x + iy, where i is a new number with i² = −1. That sounds strange until you read z as the arrow to (x, y). It is not a third axis: we are still in the flat plane, with the real part as x and the imaginary part as y. The letter z simply names the whole point at once.
Adding complex numbers adds arrows tip to tail, exactly as in step 6. Multiplying is where it gets interesting: the lengths multiply and the angles add. Multiplying by i (length 1, angle 90°) turns any arrow a quarter turn anticlockwise. Do it twice and you have turned halfway round, which is the same as multiplying by −1. That is all i² = −1 means.
Try this Press Set w = i and turn z around: z·i is always z turned by 90°. Then give w length 0.5 and watch the product shrink.
Check What is i · (2 + i)?
2i + i² = 2i − 1 = −1 + 2i. The arrow (2, 1) turned a quarter turn is (−1, 2).
Show the math
In polar form, a number with length r and angle θ is . Multiplying at by at gives at : the angle-addition formulas of step 4 in disguise.
17The spinning arrow
The point at angle θ on the unit circle is cos θ + i sin θ. Mathematicians write it as eiθ (Euler’s formula). For us it is a convenient name: eiθ is the arrow of length 1 at angle θ. The power notation fits because multiplying two such arrows adds their angles, just as multiplying powers adds exponents.
Now one circle of a chain is a single expression: c·eikt is an arrow whose length and starting angle are those of c, turning k times per lap, backwards when k is negative.
Try this Switch the speed between −1 and +1. The teal dot (real part) moves as a cosine wave, the yellow dot (imaginary part) as a sine wave.
Check What is eiπ?
The arrow of length 1 at angle π, halfway round: the number −1. That is the famous eiπ + 1 = 0.
Show the math
where is the angle of c. Why e? The power series with splits exactly into the series of and .
18Two chains or one
Chain a circle that turns forward with an equal circle that turns backward and the tip stays on a straight line: the sideways motions cancel and the motion along the line adds up. So every real wave is a pair of circles, one at speed +k and one at −k. Write the pen position as one complex number z = x + iy and the two chains merge into a single chain with speeds from −N to N. Switch the playground to One complex chain to watch it draw the same curve.
Try this Watch the two arrows: whenever one points up, the other points down by the same amount, so the tip never leaves the line.
Check How many circles does the one-chain view need for N speeds per axis?
2N: for each speed 1 … N, one circle turning forward and one turning backward.
Show the math
Hence N real harmonics per axis use exactly the complex terms with , and both views draw the same curve:
Part VIFrom any shape to its equation
19One circle, three numbers
Everything the epicycles need is a list of circles, and each circle is fully described by three numbers: its speed k (whole turns per lap, negative for clockwise), its radius r, and its start angle φ, the direction its arrow points at t = 0. Complex numbers pack the last two into one: ck = r·eiφ is an arrow whose length is the radius and whose direction is the start angle (step 17).
The speed is not even stored. The circles are kept in a fixed order, … −2, −1, 0, 1, 2 …, so a circle’s place in the list is its speed. The circle with speed 0 never turns: c0 is simply the centre of the drawing. The demo shows the selected shape’s eight largest circles at work, a table of their numbers, and the beginning of the shape’s actual equation.
Try this Pick the heart in the playground: its biggest circles all have small speeds. Then pick the nautilus or the dragonfly and look at the speeds of their largest circles.
Check A circle has radius 0.3, speed −2 and start angle 90°. Where does its arrow point at t = 0, and after a quarter lap?
At t = 0 it points straight up (90°). Speed −2 turns it clockwise twice per lap, so a quarter lap later it has turned by −180° and points straight down.
Show the math
One term is : an arrow of length at angle . It adds to x(t) and to y(t), which is how the written-out equation is built. The numbers on this page use y pointing up, as in steps 16 and 17.
20Build an equation by hand
Here is the whole recipe at a size you can follow. Take eight points around a shape, numbered in the order the pen should visit them, and decide that the pen reaches point j at time tj = 2πj/8. As complex numbers they are z0 … z7. Now run the wave detector of step 14 for every speed k from −4 to 3: turn each point back by the angle ktj that circle k would have turned by then, and average the eight results. That average is ck.
Eight points give exactly eight circles, and the curve they draw passes through every point at exactly its time. Between the points they draw a smooth closed curve made only of slow circles, which is why it can bulge a little between the dots. Drag the dots and watch the circles and the numbers follow.
Try this Drag one dot far out and watch the table: every circle changes a little, because every point takes part in every average. Then pull the roof (dot 5) down until the house becomes a box.
Check Why exactly eight circles for eight points?
Eight points are 16 real numbers, and eight circles are 8 complex numbers, also 16 real numbers. It is the same information, written as positions or as circles. With more circles than points the circles would not be pinned down; with fewer they could not pass through every point.
Show the math
Multiplying by turns point j back by the angle circle k turns by time ; averaging keeps only what turns in step with circle k. Going back is the same kind of sum: . For a gallery drawing the app does exactly this with points, and the FFT computes all the averages at once.
21What the numbers remember
A good way to understand an encoding is to change the picture and watch the numbers. Each button changes the selected shape, and the table highlights the numbers that moved:
- Move: only the centre c0 changes. The position lives in one number.
- Scale: every radius is multiplied by the same factor.
- Rotate: every start angle grows by the same angle.
- Start later: circle k turns by k times the delay, so fast circles change most. The picture stays the same; only the pen’s starting point (yellow) moves.
- Reverse: speeds +k and −k swap their numbers, and the yellow arrow flips.
So the radii hold the shape’s proportions, the angles hold how it is turned and where the tracing starts, and c0 holds where it sits.
Try this Press Rotate 30° three times and check that every start angle went up by 90°. Then press Start ⅛ lap later and compare how far speeds 1, 2 and 3 turned.
Check Which numbers change if you mirror the shape left to right?
All of them, but nothing is lost: mirroring swaps speed +k with −k (the drawing now goes round the other way) and mirrors every start angle, φ becomes 180° − φ. Every radius survives, just at the swapped speed.
Show the math
Each follows from in one line, for example .
22How many numbers is a drawing?
Imagine writing a drawing down so that someone else can rebuild it from your list alone. Step 19 showed what that takes: two numbers for the centre, and for every circle its speed, its radius and its start angle. The question is how to write such a list with as few numbers as possible. There are two ways.
List A, in speed order. You and the reader agree on a fixed order for the rows: speed 1, then −1, then 2, −2, 3, −3, and so on. Now the reader knows each row’s speed from its position in the list, so you only write the radius and the start angle: two numbers per circle. Speeds up to N cost 2 + 4N numbers. The catch is that the order cannot have gaps: a tiny circle in the middle of the list still costs its two numbers, or every later row would be read at the wrong speed.
List B, largest first. You keep only the biggest circles, wherever they are. Their speeds no longer follow the agreed order, so every row must also write its speed down: three numbers per circle, 2 + 3K for K circles. In exchange, no numbers are spent on tiny circles.
To rebuild, the reader turns every row into one term, r·ei(k·t + φ), and adds them to the centre; the only difference is where k comes from. The demo gives both lists the same budget of numbers and shows exactly what is written down and the equation rebuilt from it. For the gallery drawings List A usually wins: their circles shrink fairly steadily with speed, so speed order is already almost size order, and writing speeds down wastes numbers. List B wins when a few fast circles carry a lot and the speeds in between are nearly empty, as in the 12-petal flower.
Written out completely, a drawing in speed order saves nothing: the dragonfly at N = 8192 takes 65 538 numbers, about as many as its 32 768 traced points at two numbers each. The circles are the same information sorted by speed instead of by time; the saving comes only from leaving circles out.
Try this Start with the heart at 20 numbers: read both lists row by row and compare their speed columns, greyed out in List A and written down in List B. Then switch to the flower and see which speeds List B picks.
Check List A with speeds up to 4: how many rows, and how many numbers?
8 rows, for speeds 1, −1, 2, −2, 3, −3, 4, −4. Each row stores a radius and a start angle, so 16 numbers, plus 2 for the centre: 18.
Check For the heart, the largest circles are almost exactly its first speeds. What does that tell you about the heart?
That it is smooth: all its detail sits at low speeds, so both lists keep nearly the same circles, and List A gets them without paying for speeds. A drawing with sharp corners or fine detail spreads its size over many speeds, and choosing by size pays off.
Show the math
Keeping a set S of circles leaves the error
so for a fixed number of circles the largest are always the best choice (Parseval’s theorem, step 23). For a fixed number of stored numbers it depends on how the sizes are spread. Real compressors get the best of both: JPEG and MP3 round most coefficients to exactly zero and then store long runs of zeros in a few bits, so the positions of the kept ones cost almost nothing.
The flower is with proportional to . Multiplying out with leaves only the speeds .
Part VIIHow good is it?
23Why more circles mean less error
To grade an approximation, measure the distance between the true outline and the drawn curve at many moments. Some distances are small, some large. Square them, average the squares and take the square root: that gives one typical distance, the root mean square (RMS). Divided by the RMS size of the shape itself, it is the error percentage in the playground.
Every circle you leave out removes a little of the drawing. Smooth shapes like the heart converge quickly; drawings with sharp corners and fine detail, like the dragonfly, need thousands of circles. The plot compares all six shapes; the dot marks the current N.
Try this Pick the heart and then the dragonfly in the playground. How many circles does each need to get under 1 %?
Check Why square the distances before averaging, instead of averaging them directly?
Squares are never negative, and they punish big misses more than small ones. They also make the arithmetic exact: Parseval’s theorem below turns the average squared distance into a sum of the left-out circles’ squared sizes.
Show the math
The second equality is Parseval’s theorem: the energy of the dropped coefficients equals the mean squared distance between the curve and its approximation. The constant term is only the drawing’s position, so it is left out and moving the shape does not change the error.
24One line from many strokes
The circles can only draw one closed line, but the dragonfly is 29 separate strokes: wings, legs, eyes and body segments. Before any Fourier work the strokes are joined into a single tour. The order is chosen greedily, always continuing with the nearest unvisited stroke, and then improved by reversing stretches of the order where that shortens the jumps (2-opt). Wherever strokes touch, the pen travels between them by retracing lines it has already drawn. Only where they do not touch does it hop across, and those hops stay visible in the drawing.
Try this Pick the treble clef in the playground: its inner loops never touch the outline, so the joins show up as short straight lines.
Check Why must the whole drawing be one closed line?
The chain’s tip moves continuously and is back at its start after every lap, so it can only draw a single closed curve. Separate strokes have to be joined.
Show the math
With strokes in tour order, each running from a start point to an end point , the straight jumps cost
2-opt reverses a stretch of the order, each stroke drawn backwards, whenever that lowers :
Each remaining jump is then replaced by the cheapest path through the drawing: walking along a stroke costs its length, and a straight hop between two points less than 1 % of the drawing’s diagonal apart costs four times its length. A jump keeps its straight line only when no cheaper path exists.
NextWhere this idea goes
The same idea runs through much of modern technology. MP3 and AAC store sound as the amount of each frequency. JPEG stores small blocks of an image as amounts of two-dimensional wave patterns and drops the small ones, exactly like leaving out the small circles here. A radio picks one station with a detector much like the one in step 14. For signals that never repeat, the circles become a continuous range of speeds: the Fourier transform.
Good next stops are 3Blue1Brown’s videos But what is a Fourier series? and But what is the Fourier transform?, and any first course on signals and systems.