This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

articleAINumerics

The Gibbs overshoot never shrinks

Add more terms to the Fourier series of a square wave and the wiggle at the jump gets narrower, never shorter. It overshoots by 8.95% of the jump however many terms you take, and the number comes from an integral.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Take the square wave that is on and on . Its Fourier series is : odd harmonics only, falling off like . Sum the first five and you get a wobbly approximation. Sum eighty and the wobble has all but gone — except right next to the jump, where a spike of the same height as ever has moved in toward and thinned.

Where the height comes from

The sum of the first odd harmonics has its first peak at exactly , where the derivative first vanishes. Evaluate the sum there and it is a Riemann sum, with panels, for . So the height of the first peak tends to a number that has nothing to do with : , against a wave of height 1. The overshoot is , which is of the jump from to .

Why more terms cannot help

The peak sits at and is about that wide, so as grows it carries less and less area. In the mean-square sense the series converges: the integral of the squared error goes to zero. But at the peak itself the error stays for every . That is the difference between convergence in and uniform convergence, and a square wave, being discontinuous, has the first without the second. A smoothing filter (Fejér, Lanczos) trades the spike for a slower approach to the wave; nothing that keeps the partial sums as they are removes it.

What the program checks

The program checks three things. The peak of a thousand harmonics, summed directly, matches the integral computed by Simpson's rule with 2000 panels to a millionth. The peaks of ten and of a hundred harmonics are both above , so adding terms does not lower the peak. And the overshoot is of the jump, to four places.

Printed

limit: 1.17898
peak_10: 1.17981
peak_100: 1.17899
peak_1000: 1.17898
overshoot: 0.0894899
overshoot_height: 0.17898
Square wave at the jump, partial sums m = 5 to 80
0.81.01.200.20.40.60.81.0xpartial sum

 

0.0 / 12.5 s

Tests 4 of 4 pass

  • the peak of a thousand harmonics matches the integral (2/pi) Si(pi) (passes)
  • ten harmonics already overshoot by nearly as much: more terms do not help (passes)
  • the peak rises 0.179 above the wave (passes)
  • the overshoot is 8.95% of the jump (passes)

Checked when the site was built: 4 of 4 tests passed, in under 0.1 s. Download 2026-09-21-gibbs-overshoot.viv