Smooth spinning arrows, one riding on another, draw a wave with flat tops. Watch the wave beside the arrows as each new arrow joins.
Eight spinning arrows draw a square wave
Watch the wave build itself.
Describe this picture
A chain of spinning arrows, each riding on the tip of the one before, and beside it the wave traced by the height of the chain’s tip, over a dashed outline of the square wave it is heading for. Arrows join one at a time, each shorter and faster than the last; the readout “Arrows” counts them, up to 8. A “Hear it” button plays the wave on screen, and a transport plays and pauses the clip.
Smooth arrows, flat tops
I want to start with something that bothered me the first time I saw it. Think of the buzz of a cheap synthesiser, or an old doorbell. Its wave is as unsmooth as a wave gets: it sits flat on top, jumps straight down, sits flat on the bottom, and jumps straight back up. This is called a square wave, and it repeats forever.
The picture at the top of the page builds that wave out of nothing but spinning arrows. You met them in the page Complex exponentials & phasors (3.4): an arrow turning at a steady rate, where the height of its tip, followed over time, is a smooth sine wave. Here, each new arrow rides on the tip of the one before it, and each is shorter and faster than the last.
Every arrow is perfectly smooth, but with each one that joins, the top gets flatter and the corners get steeper. By the eighth arrow the curve is nearly the square wave. The little spikes at the corners do not go away as you add arrows; the page Convergence and the Gibbs phenomenon (7.3) explains why.
That is the whole claim of this chapter: almost any repeating signal you will meet, however angular, can be built from smooth sinusoids. The rest of this page takes the animation apart, one piece at a time.
One arrow, one sine wave
Start with a single arrow. Let it turn at a steady rate, and let the dashed line carry the tip’s height across to the wave.
One spinning arrow traces a sine
The dot follows the height of the arrow’s tip.
The dot stays level with the tip of the arrow, so it rises and falls as the arrow turns.
Describe this picture
One arrow turning at a steady rate, a dashed line carrying the height of its tip across to a dot on the wave, and the wave the dot draws. When the arrow finishes one lap, a bracket over the first repeat is labelled T. The caption says “The dot stays level with the tip of the arrow, so it rises and falls as the arrow turns.”, then “One lap of the arrow draws one period T of the wave.”
Watch the dot while the arrow turns. The dashed line carries the height of the tip to the wave, so the dot rises when the tip rises and falls when the tip falls. Then watch for the bracket: when the arrow finishes one full lap, the wave has drawn exactly one repeat, and the bracket marks that repeat as T, the period.
So one lap of the arrow is one period. If one lap takes seconds, the arrow turns at
and it makes laps every second. I’ll call the fundamental angular frequency ( is the fundamental frequency in Hz): it belongs to the slowest arrow, and it sets the frequency you hear as the note. With for the angle this first arrow has turned by time , the dot’s height is .
A second arrow, three times as fast
Now ride a second arrow on the tip of the first. I’ll make it turn three times as fast, so it does three laps for every lap of the first, and I’ll make it a third as long.
A second, faster arrow
Three times as fast, a third as long.
A second arrow grows on the tip of the first. The dot slides down with it.
Describe this picture
A second arrow grows on the tip of the first, three times as fast and a third as long, and the dot follows the height of the tip of the whole chain. The caption ends on “The top is flatter than a plain sine, with a small dip in the middle: a step toward a flat top.”
Watch the dot while the new arrow grows. The dashed line now carries the height of the tip of the whole chain, so the dot’s height is the first arrow’s height plus the second’s. As the second arrow grows, the top of the wave gets flatter than a plain sine, with a dip in the middle of each top.
You met the word in the page Decomposing signals (2.3): an arrow that turns a whole number of times as fast as the fundamental is a harmonic. This one turns at , so it is the 3rd harmonic. The th harmonic turns at and adds a term , where is the arrow’s signed length. A negative means the arrow points the opposite way.
Every harmonic fits a whole number of laps into one period , so after seconds each arrow is exactly back where it started. The sum is therefore back where it started too. Any sum of harmonics of repeats with period , however many arrows you add.
Notice that the first arrow is longer than the height of the flat top. Its length is , so on its own it rises above the dashed square wave. That is on purpose. The later arrows pull the top back down, and the next section gives all the lengths.
How long each arrow must be
So how long should each arrow be? Here is the recipe; the page Fourier series coefficients (7.2) shows where it comes from. For the square wave, the arrows at are as long as the first. The even ones, , have length zero. The first arrow has length . Written out, the length of arrow is
For now, I want you to see that it works. The wave here swings between and , so the flat top should sit at height 1.
Here each arrow is drawn a new way, as a bar whose height shows its length. Watch the readout called “Height at the cursor”, the height of the curve at the middle of a flat top, as each bar joins.
Eight arrow lengths as bars
One bar per arrow; the readout is the curve’s height at the cursor.
Each new bar is one more arrow. The readout is the curve’s height at the cursor, at the middle of a flat top.
Describe this picture
The wave, with a cursor at the middle of a flat top, and below it one bar per arrow along an axis labelled “harmonic number k”. A second row above the bars, “length ÷ first arrow”, shows each bar as a fraction of the first: . The first arrow itself is long, but the bars are drawn relative to it, which is why its bar reads . As each bar joins, the readout “Height at the cursor” goes 1.273, 0.849, 1.103, 0.922, 1.063, 0.947, 1.045, 0.960; the readouts “Flat top (the target)” and “Arrows” sit beside it. When the clip has finished, the cursor can be dragged along the wave, and the caption follows it: on a flat top it says “gets close to the flat top, +1.” or “gets close to the flat bottom, −1.”; at a jump it says “at a jump the arrows settle on 0, halfway.”
The height lands above 1, then below, then above, and each new arrow moves it by less than the one before. When the animation has finished, drag the cursor along the wave to read the height anywhere.
With the cursor at the middle of a flat top, the height is
with one term for each arrow. The terms alternate in sign, so the sum overshoots and undershoots. With every term included, the bracket adds up to exactly . This is a known result, the Leibniz series; take it on trust here. The height then approaches .
Before we go on, a limit on what this page covers. This square wave is odd, as in the page Decomposing signals (2.3): its left-to-right mirror image is its upside-down copy. It also averages to zero over a period. For waves like that, sines alone are enough, and that is all I use here. A wave that does not average to zero needs a constant added. A wave without the odd symmetry needs cosines too. The page Fourier series coefficients (7.2) brings in both.
Same frequency, different recipe
If the first arrow decides the frequency, what do the other arrows do? Let’s listen, to a sine, a square, a sawtooth and a triangle. The sawtooth here is a falling slope that snaps back up, going from down to . Press a wave button, then watch the first bar.
Four waves, one frequency
The first bar fixes the frequency; the other bars colour the sound.
The first bar alone: a pure sine at 220 Hz. Watch the other bars rise.
Describe this picture
Bars along the same “harmonic number k” axis as before, one per arrow, and four “Wave” buttons: Sine, Square, Sawtooth and Triangle, with Sawtooth chosen to begin with. Each wave starts as a pure sine, the first bar alone; after about 2 seconds the other bars rise, and by 6 seconds the recipe is complete. The readout “Frequency” reads 220 Hz. A “Hear it” button plays the recipe on screen; it starts only when you click.
The first bar never moves, so the “Frequency” readout stays at 220 Hz whatever you choose. What changes is the other bars. The sine has the first bar only. The square adds the odd bars, and the sound becomes thinner. The sawtooth has every bar, falling off as , and the sound becomes sharper, with a buzz. The triangle has only odd bars, but they shrink as , so the sound stays gentle and close to the sine. In the triangle, bars 3, 7 and 11 hang below zero. Their signed lengths are negative, so those arrows point the opposite way, and that turns a flat top into a pointed one. Press Hear it on each wave in turn and compare.
That is why a flute and a violin can play the same note and still sound different. They share the frequency, which is the first arrow, and they differ in how long the other arrows are. The mix of harmonic lengths is a large part of the timbre, the colour of a sound. How a note starts and fades matters too.
At 220 Hz the period is ms, and the harmonics sit at Hz for .
Why each arrow can be measured on its own
Here is the question I could not stop asking: if someone hands me a wave, how would I find the length of one arrow in it, with all the others mixed in? The answer is a small trick, and it rests on one fact about multiplying waves.
Take two waves, multiply them point by point, and average the result over one period. You met the average of a signal on the page How big is a signal (1.3) as add up and divide. For a wave that runs continuously, the average over one period is the area from to divided by :
Here stands for whatever you are averaging. It is the same add-up-and-divide, done with the running area from the pages Impulse, step and ramp (3.1) and Continuous-time convolution (5.3). When the two waves are the same harmonic, the product is never negative, so the average is positive. When they are different harmonics, the product has equal patches above and below the axis, and they cancel.
Here are four pairs, , , , and finally the square wave times . The first three use odd harmonics only, as the square wave does. Watch the shaded patches and the “average so far”: the area collected so far divided by the time elapsed so far, exactly as on the page How big is a signal (1.3).
Multiply, then average
Four pairs of waves, multiplied point by point.
Multiply the two waves point by point. Here they are the same wave, so the product never dips below zero.
Describe this picture
Each pair of waves, their product with its area shaded above and below the axis, and a line labelled “average so far”, over one period: the axis reads “time, as θ = ω₀t”, with ticks at , and . The readout “Average so far” moves while the patches build. For the first pair it shows at halfway and ends at ; for the second it already reads a quarter of the way through. Each pair’s final average joins a list under the plot. For the fourth pair the caption ends “Doubled, 0.212 becomes 0.424: the length of the third arrow.” A transport plays and pauses the clip.
At the end of the period the average so far equals the period average. The first pair is the same wave twice, so the product is never negative, and the average ends at . In the next two pairs the harmonics differ, and the patches above and below the axis are equal. The average ends at .
The fourth pair is the one we wanted. The square wave is a sum of odd arrows. Multiplying by makes arrows 1, 5, 7, and so on cancel, as in the pairs before.
Only the third arrow survives, and the average ends at . Like the first pair, it averages to half the arrow’s length, so double it: 0.424, the length of the third arrow. The worked example below does the same sum by hand.
The algebra below writes each sine as two spinning arrows, as on the page Complex exponentials & phasors (3.4). Why, then, do the arrow animations at the top of this page use one arrow per harmonic? They read only the tip’s height, and one arrow’s height is already a real sine. The pair is a tool for the algebra only.
Why do the pairs cancel? Write , and recall . Multiplying out and collecting pairs into cosines,
If you have met the product-to-sum identity, this is it. So . Both cosines complete whole laps in one period, so each averages to zero. For the identity gives , which averages to .
In general, for whole numbers ,
Now use the trick. Suppose , and multiply it by and average. Every term with averages to zero. Only the term survives, and it contributes : the arrow’s signed length times the average of , which is the from the first pair. That is why we double at the end. So
To measure one arrow, multiply by its harmonic, average, and double. The other arrows contribute nothing, so you can find them one at a time without disturbing each other. Try it on the square wave in the worked example below.
The maths behind it · dot products
Multiplying two waves and averaging works like measuring how much two arrows in space point the same way. Harmonics with different whole-number frequencies do not point the same way at all: their product averages to zero. The length of arrow is how far reaches along the direction of harmonic . Linear algebra calls this a dot product. It calls writing a wave as a sum of harmonics a change of basis.
Worked example
- Arrow lengths. For the square wave, for odd . So , , , , .
- Four arrows at a flat top. With at : , a little below 1.
- Measuring the 1st arrow. The square wave is on and on . The average of is Doubling gives .
- Pencil and paper: the 3rd arrow. First the area under one hump of : since . Over the wave sits below the axis: since . Check: the whole period gives , as a full number of laps must.
- The 3rd arrow, finished. The on the second half flips the to , so the average of is Doubling gives , matching the recipe.
- The 2nd arrow. The average of is , so , as the recipe says.
Where you’ll meet this
Every synthesiser that builds a sound by adding sine waves is using this idea. So is every spectrum display that shows how much of each frequency a sound contains. Sound compression keeps the components you can hear and drops the ones you cannot. The next page, Fourier series coefficients (7.2), turns the multiply-and-average trick into the Fourier series formula, with exact values for any reasonable repeating wave.
The maths behind it · uncorrelated signals
The average of the product of two signals that each average to zero tells you how much they rise and fall together. Harmonics at different frequencies do not do that at all, so their powers add. The power of a wave will turn out to be the sum of the power in each harmonic, on the page Fourier series coefficients (7.2). Statistics calls that average of products the covariance, and calls two signals whose covariance is zero uncorrelated.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Fundamental | , | one lap of arrow 1 per period |
| Harmonic | frequency , angular | is the fundamental |
| Sum of harmonics (odd, zero-mean waves) | repeats with period ; the general case adds a constant and cosines (see Fourier series coefficients (7.2)) | |
| Square wave () | ( odd), ( even) | made exact in Fourier series coefficients (7.2) |
| Sawtooth (falling, ) | , all | lengths in the ratio |
| Triangle (peak ) | for odd , for even | lengths in the ratio ; , , |
| Orthogonality | if , if | |
| Measuring one length | multiply by the harmonic, average, double |