OpenWorldLab

Loading interactive view…

Mathematics and sound

Fourier epicycles: any shape from circles

Put a circle on the rim of a circle on the rim of another circle, set them all turning, and the tip of the last one can be made to trace any closed shape you like. How big each circle must be, and where it must start, is a Fourier series. The same idea takes a sound apart into its harmonics.

From a drawing to circles

Walk round a closed shape at a steady pace and note where you are at each moment. Write each position as a complex number z=x+iyz = x + iy. Fourier’s claim, made for heat flow in 1807 and proved properly later, is that such a path can always be written as a sum of steady rotations:

z(t)=∑kck e2πiktz(t) = \sum_k c_k\, e^{2\pi i k t}

Each term is a circle. Its radius is ∣ck∣|c_k|, its starting angle is the angle of ckc_k, and k is how many times it turns per lap: positive anticlockwise, negative clockwise. The k = 0 term does not turn; it is the shape’s centre. Stack the circles end to end and the tip traces z(t).

To find the ckc_k, the page samples your shape at 512 evenly spaced points round its length and computes

ck=1N∑n=0N−1zn e−2πikn/Nc_k = \frac{1}{N} \sum_{n=0}^{N-1} z_n\, e^{-2\pi i k n / N}

the discrete Fourier transform. Each ckc_k measures how much of the shape turns at rate k. With all 512 circles the tip passes through every sampled point exactly.

Fewer circles, smoother shapes

The circles are sorted by size, and the Circles slider keeps the biggest. One circle gives the best-fitting circle. A handful give the shape’s broad outline. Smooth shapes, like the heart, need few circles, because their coefficients shrink quickly as k grows. Sharp corners need many, because a corner is a sudden change of direction, and building a sudden change from smooth rotations takes fast ones.

The spectrum chart shows the size of each circle by its frequency. Click a bar to switch that circle off and see what it was contributing. Symmetric shapes have tidy spectra: a five-pointed star traced once round uses only the frequencies 1, −4, 6, −9, 11 and so on, each a multiple of five away from the first.

The overshoot that never goes away

Take the square, and watch a corner as the number of circles rises. The traced line overshoots the corner, comes back and ripples. Adding circles makes the ripples narrower and pushes them into the corner, but the first overshoot never shrinks below about 9% of the jump. Josiah Willard Gibbs explained this in 1899, after Albert Michelson’s harmonic analyser, a machine of springs and levers that added up Fourier series, kept drawing it. It is called the Gibbs phenomenon.

Harmonics: a sound taken apart

A steady musical note is a repeating wave, and the same mathematics splits it into sine waves at whole multiples of its basic frequency: the harmonics. A violin and a flute playing the same note have the same first harmonic and different amounts of the others, and that difference is most of what lets you tell them apart.

Switch to Harmonics, where each slider sets one harmonic’s strength. A square wave has only odd harmonics, getting weaker as 1/m; a sawtooth has all of them as 1/m and sounds brighter; a triangle wave’s fall as 1/m21/m^2 and it sounds nearly as pure as a sine.

Then press Scramble the phases. Each harmonic slides forward by a random amount, and the wave on screen changes beyond recognition. To most ears the sound barely changes. Georg Ohm proposed in 1843, and Hermann von Helmholtz confirmed, that the ear responds mainly to how strong each harmonic is and largely ignores how they line up. It is not exactly true, but it is close, and it explains why your ear works as a sort of Fourier analyser.

Hearing a drawing

A drawing has two Fourier series, one for the x coordinate and one for y. Press Listen and the page plays x on the left channel and y on the right, at the pitch you choose, using the browser’s own Fourier-series oscillator. Feed those two channels to an old-fashioned oscilloscope in XY mode, where the left signal moves the dot sideways and the right one moves it up and down, and the dot redraws the picture. The scope on screen does exactly that with the sound as it plays. Musicians have composed whole pieces this way, called oscilloscope music, where the sound you hear is also the animation you see.

Muting circles or using fewer of them changes the sound too: that is the same smoothing, heard instead of seen.

Things to try

  • Draw your initials in one stroke and find the fewest circles that keep them readable.
  • Set Circles to 2 on the figure eight, then 4. Then try the heart with 4, and work out why the answers differ.
  • Mute the biggest circle of the star and see what is left.
  • In Harmonics, start from Sine and add harmonics one at a time while listening. When does it stop sounding like a single note?
  • Listen to the square drawing at 60 Hz, then at 300 Hz. The shape on the scope stays put.

References