Convergence and the Gibbs Phenomenon
Does a Fourier series actually converge to its function? For smooth functions, yes, and fast. At a jump, the partial sums overshoot by about 9 % of the jump, and the overshoot does not go away no matter how many terms you add; it only gets narrower. This is the Gibbs phenomenon, and it shows up as ringing in filtered signals and compressed images.
What converges, and how
- If is smooth (or just continuous and piecewise smooth), the partial sums converge to uniformly.
- At a jump discontinuity, converges to the midpoint of the jump, .
- For any with finite energy, the partial sums converge in the mean-square sense: .
The overshoot
For the square wave jumping from to (a jump of 2), the maximum of tends to , an overshoot of , or about 8.95 % of the jump.
import numpy as np
t = np.linspace(0, 0.25, 200001) # the first quarter period: just after the jump at t = 0
def S(K):
s = np.zeros_like(t)
for k in range(1, K + 1, 2):
s += 4 / np.pi * np.sin(2 * np.pi * k * t) / k
return s
for K in (9, 39, 159, 639):
s = S(K)
i = np.argmax(s)
print(f"K={K:4d}: max {s[i]:.4f} at t = {t[i]:.5f} value at the jump t=0: {s[0]:.1f}")K= 9: max 1.1823 at t = 0.05000 value at the jump t=0: 0.0
K= 39: max 1.1792 at t = 0.01250 value at the jump t=0: 0.0
K= 159: max 1.1790 at t = 0.00313 value at the jump t=0: 0.0
K= 639: max 1.1790 at t = 0.00078 value at the jump t=0: 0.0
The peak stays near 1.179 while its location moves toward the jump, roughly at . At the jump itself the sum is 0, the midpoint of and .
Taming Gibbs: smoothing the coefficients
Fejér noticed that averaging the partial sums (Cesàro means) removes the overshoot. Averaging is the same as multiplying the coefficients by a triangular taper, . Other tapers (Lanczos sigma factors, raised cosines) trade a little sharpness for no ringing. This is exactly the idea of window functions applied to coefficients.
import numpy as np
t = np.linspace(0, 0.5, 100001)
K = 99
plain = np.zeros_like(t)
fejer = np.zeros_like(t)
lanczos = np.zeros_like(t)
for k in range(1, K + 1, 2):
term = 4 / np.pi * np.sin(2 * np.pi * k * t) / k
plain += term
fejer += (1 - k / (K + 1)) * term
lanczos += np.sinc(k / (K + 1)) * term # np.sinc(x) = sin(pi x)/(pi x)
for name, s in (("plain", plain), ("Fejer", fejer), ("Lanczos", lanczos)):
rise = t[np.argmax(s >= 0.9)]
print(f"{name:8s} max {s.max():.4f} reaches 0.9 at t = {rise:.4f}")plain max 1.1790 reaches 0.9 at t = 0.0026
Fejer max 0.9936 reaches 0.9 at t = 0.0085
Lanczos max 1.0237 reaches 0.9 at t = 0.0050
Fejér removes the overshoot completely but rises slowly; Lanczos keeps a small overshoot (about 2.4 %) with a faster rise.
In software
- Ringing around sharp edges in JPEG images and "pre-echo" in compressed audio are Gibbs effects from discarding high-frequency coefficients.
- An ideal (brick-wall) low-pass filter rings for the same reason; practical filter design tapers the frequency response (FIR Filter Design).
Exercises
Exercise 1: Value at the jump
To what value does the sawtooth series ( on , repeated) converge at ?
Answer
.
Solution
The left limit at is 1 (end of the previous period) and the right limit is 0; the series converges to the midpoint .
Exercise 2: Overshoot size
A signal jumps from 0 to 5 V. Approximately how high does its truncated Fourier series overshoot?
Answer
To about 5.45 V.
Solution
The overshoot is about 8.95 % of the jump: V above 5 V.
Exercise 3: The Gibbs constant (code)
Compute , where , with a simple numerical integral.
Answer
About 1.178980.
Solution
import numpy as np
u = np.linspace(0, np.pi, 1000001)
integrand = np.sinc(u / np.pi) # sin(u)/u, equal to 1 at u = 0
Si = np.sum((integrand[1:] + integrand[:-1]) / 2) * (u[1] - u[0]) # trapezoid rule
print(round(2 / np.pi * Si, 6))1.17898
Test yourself
At a jump discontinuity, the Fourier series converges to…
- the left value
- the right value
- the midpoint of the jump
- it diverges
As more terms are added, the Gibbs overshoot…
- disappears
- stays about 9 % of the jump but gets narrower
- grows
- moves away from the jump
Fejér (Cesàro) summation removes the overshoot by…
- adding more harmonics
- tapering the coefficients with a triangular window
- removing the DC term
- doubling the period