Will the bump at the corner of a square wave shrink to nothing as arrows are added? Decide, then watch.
Stop after a few arrows
The ±1 square wave next to its jump; one more arrow every half second.
Two arrows. There is already a bump above the top: 1.200.
Describe this picture
The ±1 square wave next to its jump, with the target dashed and a key reading “square wave”, “sum of the arrows” and “earlier sums”. A ring on the bump is labelled “tallest point”, and the readouts “Arrows” and “Tallest point” follow it. The count steps from 2 to 20 arrows, one more every half second, and the earlier sums fade behind the current one; the clip reaches 20 arrows at 9 seconds and holds to 10.5 seconds. The captions read “Two arrows. There is already a bump above the top: 1.200.”, with the tallest point at ; then “Ten arrows: the bump has moved toward the jump and got narrower. Its top: 1.180.”, with the tallest point at ; and at the end “Twenty arrows: a thin bump right at the jump, still 1.179 high. At the jump itself the curve is exactly 0, the middle of −1 and 1: every sine is 0 there.” A second ring at the jump, labelled “0”, marks that value.
Stopping after a few arrows
On the page Signals as sums of sinusoids (7.1) the square wave was built from spinning arrows, and every arrow that joined made the curve closer to the target. I also said that the little spikes at the corners do not go away. This page says exactly what happens when you stop after a given number of arrows, what shrinks, what refuses to, and why.
The wave is 7.1’s square wave between and . Its arrows are the odd harmonics , with lengths . I call the sum of the arrows you keep a partial sum. I count arrows in words, “ten arrows”, and I name a partial sum by the highest harmonic it keeps, . For the square wave, ten arrows reach harmonic 19, so . In general is twice the number of arrows, minus 1.
Go back to the picture at the top of the page. With two arrows the tallest point is , at . With ten it is , at , and with twenty it is still . At the jump itself the curve is exactly 0. So the answer to my question is no. The bump moves towards the jump and gets narrower, but its top stays near .
The value at the jump comes from 7.1. Each arrow’s height is , and every is 0 at . So every partial sum is exactly 0 there, the middle of the jump from to . This holds for all arrow counts, including infinitely many. At a jump the series converges to the midpoint of the jump, and the bump sits next to it, not on it.
An old audio file that was compressed hard shows this as “ringing”: a ripple that follows every sharp click.
The bump keeps its height
Why does the bump narrow? Its top is at , so doubling the arrows roughly halves how far from the jump it sits. Its width follows the same rule. Suppose I zoom the horizontal axis in step with the number of arrows. Then the bump should look the same every time, because the narrowing is exactly undone by the zoom.
The picture below does this, like a stronger and stronger magnifying glass on the same crack. Watch the top of the bump against the dotted ruler as the count climbs from 5 to 80 arrows.
The same bump, however many arrows
The view zooms in as fast as the arrows are added.
Five arrows. The ruler marks 1.179.
Describe this picture
The square wave near its jump, with a dotted ruler labelled “1.179”. Over 10 seconds the count climbs from 5 to 80 arrows while the window shrinks in proportion; the readouts are “Arrows” and “Tallest point”. Then two brackets appear: one on the jump, from to , labelled “2”, and a small one on the overshoot, labelled “0.179”. The clip holds until 11.5 seconds. In between, the caption gives the count and the tallest point. The three key captions are “Five arrows. The ruler marks 1.179.”, with the tallest point on the ruler; “Twenty arrows, zoomed in four times to keep the bump the same size. Its top hasn’t moved.”; and “Eighty arrows. The bump is still 0.179 tall: about 9% of the jump from −1 to 1.”
The top of the bump stays on the ruler. A 16-fold increase in arrows has not lowered the bump at all. The reason is that near the jump the partial sum is, to a good approximation, one fixed curve that depends only on . More arrows do not change the curve. They only squeeze it. I do not derive that curve here. Its top is a known constant, , defined on the reference card, and this is the limit of the bump’s height as .
The overshoot is above the top at 1. It is of the jump, which is 2 high. This is the Gibbs phenomenon. Be careful with the percentage: it is of the height of the top, but about of the jump, and of the jump is the number that does not depend on how the wave is scaled.
A taller bump, a smaller error
If the bump never shrinks, does the partial sum ever become a good approximation? Yes, in a different sense, and the difference is the point of this page. Measure the error as 7.2’s power, the average of a square.
At each instant take the gap between the target and the partial sum , square it, and average over one period. Call that the mean-square error:
The integral is an area, so is the area under the squared gap divided by , as on the page How big is a signal (1.3). It is also what is left in the power tank of the page Fourier series coefficients (7.2). The gap contains exactly the arrows you dropped, and by Parseval’s relation their powers add. For the square wave, the total power is 1, because , and harmonic carries . So
For one to five arrows () this gives , , , and .
The bump is tall but thin. It is like a thin spike on a long road: it is high, but it hardly affects the road. As the bump narrows in step with , the area under its squared gap narrows too, even though its height stays the same.
Watch two curves grow as arrows are added: the height of the bump, and the error, the average of the shaded squared gap.
Taller does not mean more error
The squared gap between the wave and the sum of the arrows, and its average.
Two arrows: the bump is 1.200 high and the leftover error is 0.0994.
Describe this picture
Four panels. The first shows one period of the target and the sum of the arrows. The second, “squared gap”, is shaded as an area, with a dashed level at its average, labelled for example “average 0.0994”; that level is . The last two, “tallest point” and “error”, grow against “arrows” as the count runs from 2 to 40, one more arrow every quarter second; 20 arrows are on screen at about 4.5 seconds, and the clip holds until 11 seconds. The readouts are “Arrows”, “Tallest point” and “Error”. The captions read “Two arrows: the bump is 1.200 high and the leftover error is 0.0994.”, then “Twenty arrows: the bump is no lower, but the shaded error has shrunk to 0.0101.”, and last “Forty arrows: the height has not moved, and the error has halved again.”
The tallest point stays flat near , and the error keeps falling. Notice that one curve is flat and the other falls. Doubling the arrows halves the error. For ten arrows , for twenty , and for forty . You can see why from the sum: the terms dropped are the odd , and they are close together, so their sum is about half the area under from on. That area is , so . With equal to twice the number of arrows, this is divided by the number of arrows.
The error goes to zero, while the height of the bump does not. These are two different statements about “getting closer”. The error tells you that the power in the gap vanishes. The bump tells you that the curve does not settle to the target near the jump.
The maths behind it · projections
The partial sum is the projection of onto the span of the harmonics up to . It is the closest approximation to in the mean-square sense. The error shrinks because projections onto bigger and bigger subspaces keep more of the length. That statement is about the length of the gap, not about the gap at each instant, and Gibbs is the lesson that these differ.
Smoother waves need fewer arrows
The square wave needs many arrows because its arrows shrink slowly: arrow has length proportional to . The cause is the jump. The page Signals as sums of sinusoids (7.1) also showed the triangle wave, which has sharp corners but no jumps, and whose arrows are long. They fall as .
To compare the two I measure each arrow relative to arrow 1, in decibels, as on the page How big is a signal (1.3): a ratio of lengths is dB. Squaring a ratio doubles its dB value. So the triangle’s bars, which are the square of the square wave’s ratios, sit exactly twice as far down.
Watch the bars arrive in pairs, square and triangle, and compare how far down each one sits.
Jumps against corners
How fast the arrows shrink for the square wave and the triangle wave.
Jumps, and corners. Arrow 1 of each is the measuring stick.
Describe this picture
The two waves, labelled “square wave: jumps” and “triangle wave: corners”, and a bar chart of their arrow lengths relative to arrow 1. The vertical axis reads “length relative to arrow 1 (dB)”, with ticks at 0, −20, −40 and −60, and the horizontal axis reads “harmonic k”, from 1 to 31 on a plain linear scale. The key shows “square” as a filled bar and “triangle” as an open bar. Bars appear in pairs for , one pair every 0.625 seconds, with the decibel values beside the newest pair; the clip holds until 11.5 seconds. At the start both bars are at 0 dB, and the caption says “Jumps, and corners. Arrow 1 of each is the measuring stick.” At it says “Arrow 15: 1/15 of the first for the square wave, 1/225 for the triangle. Twice as many dB down.” At the end it reads “Arrow 31: −29.8 dB with jumps, −59.7 dB with corners. The smoother wave needs far fewer arrows.”
At the two lengths are and , which is and dB. At they are and dB. Notice that at every the triangle’s bar is twice as far down in dB as the square wave’s.
This is also why the triangle wave sounds mellower than the square wave: its high harmonics are far quieter. A wave that is smoother still has arrows that fall faster still. The page Properties of the Fourier transform (8.2) explains why.
Which waves the series works for
So which waves can you rebuild from arrows? In one sentence: any repeating wave you can draw with a pen, with finitely many jumps and finitely many peaks and dips in each period. The reference card lists these as the Dirichlet conditions. For such a wave the arrows add up to the wave at every point where it is continuous, and to the midpoint of the jump at each jump.
More weakly, the mean-square error goes to zero for any wave with finite power. That is the statement the power tank of 7.2 supports. It does not promise that the curve settles at every point, which the bump of this page has just shown.
The maths behind it · regression with basis functions
Fitting a sharp edge with more and more smooth terms is regression with a fixed set of basis functions. The fit ripples next to the edge however many terms you add, as a high-degree polynomial does. A smooth target needs few terms, with low bias and no ripple.
Worked example
- Bump height against the number of arrows (square wave between and ; the first bump’s top is at ). One arrow, : , but this is the edge of the window, not a bump. Two arrows: . Then for three, for four and for five. Ten arrows give , twenty and eighty . The limit is .
- The overshoot. . That is of the jump of 2, and of the height of the top.
- Error power. . For 1 to 5 arrows: , , , , . For 10, 20, 40 and 80 arrows: , , , .
- The value at the jump. Every term is , so every partial sum is at . That is the average of and .
- Decay rates relative to arrow 1. At the square wave is ( dB) and the triangle ( dB). At : ( dB) and ( dB). The triangle’s dB is twice the square wave’s at every .
Where you’ll meet this
The ringing next to a sharp edge appears wherever you cut off the high harmonics of something with an edge. It is the ripple you see in a heavily compressed image, next to a sharp line or letter, and the ripple in the output of a sharp low-pass filter given a step. The page Window-method FIR design (19.1) meets the same ringing in filter design.
There is a remedy: do not cut the arrows off suddenly, but taper them. That is a window function, the subject of Window functions compared (15.2). The next page is Fourier series and LTI systems (7.4), where each passes through a system on its own.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Partial sum | keeps harmonics up to ; for the square wave, ten arrows reach ( is twice the arrows, minus 1) | |
| Gibbs constant | , | overshoot of the jump, for a jump 2 high |
| Bump position | for highest harmonic | moves to the jump; width shrinks like |
| At a jump | series converges to | the midpoint |
| Mean-square error | what is left of the power tank; any with finite power | |
| Dirichlet conditions | finite area (), finitely many jumps and extremes per period | the series then converges to wherever is continuous, and to the midpoint at each jump |
| Decay and smoothness | jump: ; corner, no jump: | the triangle is twice as many dB down as the square wave; smoother still, faster still (8.2) |