Gibbs phenomenon — Fourier partial sums of a square wave
Fourier partial sums S_5, S_15 and S_45 of the square wave sign(sin x) plotted against the wave itself, showing the overshoot narrowing but never shrinking below 8.949% of the jump — the standard figure for non-uniform convergence and filter ripple.
Make it your own.
title: Gibbs phenomenon at a jump discontinuity
subtitle: Fourier partial sums of a square wave; odd harmonics only
x: x
y: S_N(x)
x limits: -0.4 .. 3.6
grid: both
legend: bottom
line "square wave f(x)" colour: black
-0.4, -1
0, -1
0, 1
3.14159265, 1
3.14159265, -1
3.6, -1
plot "S_5 (3 harmonics)" y = (4/pi)*(sin(x) + sin(3*x)/3 + sin(5*x)/5) for x in [-0.4, 3.6] samples: 900
plot "S_15 (8 harmonics)" y = (4/pi)*(sin(x) + sin(3*x)/3 + sin(5*x)/5 + sin(7*x)/7 + sin(9*x)/9 + sin(11*x)/11 + sin(13*x)/13 + sin(15*x)/15) for x in [-0.4, 3.6] samples: 1200
plot "S_45 (23 harmonics)" y = (4/pi)*(sin(x) + sin(3*x)/3 + sin(5*x)/5 + sin(7*x)/7 + sin(9*x)/9 + sin(11*x)/11 + sin(13*x)/13 + sin(15*x)/15 + sin(17*x)/17 + sin(19*x)/19 + sin(21*x)/21 + sin(23*x)/23 + sin(25*x)/25 + sin(27*x)/27 + sin(29*x)/29 + sin(31*x)/31 + sin(33*x)/33 + sin(35*x)/35 + sin(37*x)/37 + sin(39*x)/39 + sin(41*x)/41 + sin(43*x)/43 + sin(45*x)/45) for x in [-0.4, 3.6] samples: 1800
caption: Peak of S_45 is 1.17914 at x = pi/46 = 0.06830; peak of S_15 is 1.18028; peak of S_5 is 1.18836.
note: The overshoot does not shrink. As N grows the ripple narrows and moves toward the jump, but its height tends to (2/pi)*Si(pi) = 1.1789797 — 8.9490% of the jump height above the limit value. Adding harmonics fixes the width and never the height.
note: Convergence is pointwise but not uniform, which is what this figure is drawn to show: sup|S_N - f| does not tend to 0. A filter designed by truncating a Fourier series therefore has an irreducible passband ripple, and windowing, not more terms, is the fix.
note: Sampled at 900 to 1800 points per curve so the first lobe of S_45, which is 0.14 wide, is resolved rather than skipped.