TExcelTAD
Home › Fourier Analysis & Signals › Convergence and the Gibbs Phenomenon

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 ff is smooth (or just continuous and piecewise smooth), the partial sums SKfS_K f converge to ff uniformly.
  • At a jump discontinuity, SKf(t0)S_K f(t_0) converges to the midpoint of the jump, 12(f(t0−)+f(t0+))\frac{1}{2}(f(t_0^-) + f(t_0^+)).
  • For any ff with finite energy, the partial sums converge in the mean-square sense: ∫∣f−SKf∣2→0\int \lvert f - S_K f \rvert^2 \to 0.

The overshoot

For the square wave jumping from −1-1 to +1+1 (a jump of 2), the maximum of SKS_K tends to 2πSi⁡(π)≈1.1790\frac{2}{\pi}\operatorname{Si}(\pi) \approx 1.1790, an overshoot of 0.1790.179, or about 8.95 % of the jump.

python · try it yourself
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 t≈1/(2(K+1))t \approx 1/(2(K+1)). At the jump itself the sum is 0, the midpoint of −1-1 and 11.

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, 1−∣k∣/(K+1)1 - \lvert k \rvert/(K+1). 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.

python · try it yourself
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 (tt on [0,1)[0, 1), repeated) converge at t=0t = 0?

Answer

1/21/2.

Solution

The left limit at t=0t = 0 is 1 (end of the previous period) and the right limit is 0; the series converges to the midpoint 1/21/2.

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: 0.0895⋅5≈0.450.0895 \cdot 5 \approx 0.45 V above 5 V.

Exercise 3: The Gibbs constant (code)

Compute 2πSi⁡(π)\frac{2}{\pi}\operatorname{Si}(\pi), where Si⁡(x)=∫0xsin⁡uu du\operatorname{Si}(x) = \int_0^x \frac{\sin u}{u}\,du, with a simple numerical integral.

Answer

About 1.178980.

Solution
python · try it yourself
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…

  1. the left value
  2. the right value
  3. the midpoint of the jump
  4. it diverges

As more terms are added, the Gibbs overshoot…

  1. disappears
  2. stays about 9 % of the jump but gets narrower
  3. grows
  4. moves away from the jump

Fejér (Cesàro) summation removes the overshoot by…

  1. adding more harmonics
  2. tapering the coefficients with a triangular window
  3. removing the DC term
  4. doubling the period