Gibbs phenomenon (source code)

= Gibbs phenomenon
{c}
{wiki}

The <Gibbs phenomenon> is the persistent overshoot near a <jump discontinuity> in ordinary truncated <Fourier series>. For this <square wave>, retain $M$ nonzero odd modes:
$$
Q_M(x)=\frac4\pi\sum_{k=0}^{M-1}\frac{\sin((2k+1)x)}{2k+1}.
$$
As $M$ grows, the first peak approaches the jump while its height tends to approximately $1.17897974$. This is an excess of about $0.17898$ above the upper level $1$, or $8.949\%$ of the jump size $2$. The narrower region does not imply a vanishing maximum error. At the jump itself every $Q_M(0)=0$. These observations are compatible with <pointwise convergence> and $L^2$ convergence but exclude <uniform convergence> to the discontinuous <square wave>. https://dlmf.nist.gov/6.16[NIST DLMF, section 6.16(i): square-wave overshoot and its limiting height]{ref}.

\Image[/square-wave-fourier-ringing.png]
{title=More Fourier harmonics narrow a transition while leaving a persistent overshoot}
{description=Left: the constructed <square wave> and sums of $3$, $10$ and $50$ nonzero odd <Fourier harmonics>. Right: the same sums near the jump at zero, with each first positive peak marked. The highest frequency retained is $2M-1$, so a count of $M$ nonzero terms differs from a cutoff at frequency $M$. The limiting peak is approximately $1.17898$, while the level above the jump is $1$.}

For this particular sum, its <derivative> is $Q_M'(x)=(2/\pi)\sin(2Mx)/\sin x$ away from multiples of $\pi$, so the first positive peak is exactly at $x=\pi/(2M)$. There,
$$
Q_M\!\left(\frac\pi{2M}\right)
=\frac2M\sum_{k=0}^{M-1}\frac{\sin(\pi u_k)}{\pi u_k},\qquad u_k=\frac{k+1/2}{M}.
$$
This is a midpoint <Riemann sum> tending to $2\operatorname{Si}(\pi)/\pi$, where $\operatorname{Si}$ is the <sine integral>. It gives a short explanation of the nonzero limiting excess.

The phenomenon matters whenever a sharp boundary is represented by a limited set of <Fourier harmonics>: a visible ripple can be a property of the approximation rather than an oscillation in the original profile. <Josiah Willard Gibbs> reported the phenomenon in his 1899 letter “Fourier's Series” in Nature, volume 59, page 606. This is a documented historical report, without a claim of first discovery. https://www.nature.com/articles/059606a0[Gibbs, Fourier's Series, 1899]{ref}.