The Gibbs overshoot of a square wave

A thousand sines still overshoot the corner by 9%. The jump from −1 to +1 is 2; the sum peaks at 1.179, 0.179 above the plateau, which is 8.95% of the jump. Drag the cut along the harmonics:

peak 1.182

Only odd harmonics appear, with bn=4/(nπ). More terms squeeze the ringing towards the jump, but the first peak keeps its height: the tail the cut throws away is still large near the corner.

The sum and its terms

Each term is a sine standing at its own frequency. From the front they add up to the sum; from the side each is a bar of its amplitude, the spectrum above. Drag the figure to turn it, and the dot on the frequency axis to keep more terms:

4 terms · peak 1.184

More terms

Count x in half-widths π/k and the ringing holds its place. Play adds terms, up to a thousand, or drag the terms along their axis:

1000 terms: peak 1.179

Derivation

Differentiate the k-term sum: the cosines add up in closed form.

Sk′(x)=4π∑j=1kcos⁡((2j−1)x)=2πsin⁡2kxsin⁡x

The first zero, the peak, is at x=π/2k. Put t=2kx and use sin⁡x≈x for small x:

Sk(π2k)→2π∫0πsin⁡ttdt=2πSi(π)

That is 1.179. More terms move the peak towards the jump and its height towards this nonzero limit.

    Check yourself

    From 99 to 999 terms, what happens to the first peak beside the jump?

    RightWrong

    Its height tends to 1.179 as terms are added; its place, π/2k, moves ten times closer.

    The overshoot does not vanish. In what sense does the series still converge to the square wave?
    Show answer

    At every fixed point away from the jump the sum converges, since the peak moves past it. At the jump itself it gives the midpoint, 0. The convergence is not uniform: arbitrarily close to the jump, any finite sum is near 0 while the wave is ±1, an error approaching half the jump. Separately, the excess above the plateau tends to 8.9% of the jump.

    A sawtooth jumps from −π to π and has the same 1/n fall-off. Does its limiting overshoot have the same share?

    RightWrong

    The overshoot depends on the jump, not on the wave. For this sawtooth too, the overshoot tends to 8.9% of the jump.

    Formula sheet

    RuleFormula
    Series, period 2πf(x)=a02+∑n≥1(ancos⁡nx+bnsin⁡nx)
    Coefficientsan=1π∫−ππfcos⁡nxdx,bn=1π∫−ππfsin⁡nxdx
    Odd fan=0
    Even fbn=0
    Square wave, ±1bn=4nπ for odd n, 0 for even n
    Value at a jump12(f(x+)+f(x−))
    Peak of the k-term sumat x=π2k, height →2πSi(π)=1.179
    Overshoot0.0895× jump, as k→∞

    Every number above is computed from the square-wave series, summed term by term; Si(π) = 1.852 is integrated numerically and agrees with Wikipedia's "Gibbs phenomenon", which gives the overshoot as 0.0895 of the jump.