---
title: Pointwise convergence of Fourier series
heading: The Dirichlet kernel, what happens at a jump, and why the overshoot never goes away
eyebrow: A14 · Lesson 41 · Pointwise convergence of Fourier series
xp: 40
---

::: hook
Lesson 40 showed that a Fourier series converges in the mean-square sense, the energy of the error going to zero. An engineer looking at a reconstructed square wave on a scope sees something more specific: the series settles to the right value at most points, hits the midpoint exactly at each jump, and overshoots by about 9% on either side of the jump no matter how many terms are kept. All three facts come from one function, the **Dirichlet kernel**, that every partial sum convolves the signal with.
:::

::: play
- The curve is the partial sum of the Fourier series of a ±1 square wave, using harmonics up to $N$. The dashed line is the limit of its overshoot, $\frac{2}{\pi}\text{Si}(\pi) = 1.179$.
- More terms squeeze the ripple closer to the jump, but its peak never drops below that line.
:::

```sim plot
view: graph
x: x = -1..4
y: y = -1.4..1.4
slider: N = 1..21 step 2 = 9
plot: (4/pi)*(sin(x) + step(N - 3)*sin(3*x)/3 + step(N - 5)*sin(5*x)/5 + step(N - 7)*sin(7*x)/7 + step(N - 9)*sin(9*x)/9 + step(N - 11)*sin(11*x)/11 + step(N - 13)*sin(13*x)/13 + step(N - 15)*sin(15*x)/15 + step(N - 17)*sin(17*x)/17 + step(N - 19)*sin(19*x)/19 + step(N - 21)*sin(21*x)/21) | samples: 800 | label: partial sum, harmonics up to N
plot: 1.179 + 0*x | dashed | label: Gibbs limit, 1.179
plot: sign(sin(x)) | dashed | color: ch3 | label: square wave
```

::: predict
## The Fourier series of a ±1 square wave is evaluated exactly at a jump, where the wave switches from −1 to +1. What value does the series converge to there?

- [x] 0, the average of the two sides
- [ ] +1
- [ ] −1
- [ ] It doesn't converge at the jump

::: reveal
0. At every jump of a piecewise smooth function, the Fourier series converges to the midpoint of the jump, $\frac12\left(f(x^+) + f(x^-)\right)$. For the square wave every partial sum is a sum of sines, which are all zero at the jump, so it's 0 exactly, not just in the limit.
:::
:::

::: nameit
## Partial sums as convolution

With $c_k = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)e^{-ikt}\,dt$, the partial sum $S_Nf(x) = \sum_{k=-N}^{N}c_ke^{ikx}$ can be rewritten as

$$S_Nf(x) = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x - t)\,D_N(t)\,dt \qquad D_N(t) = \sum_{k=-N}^{N}e^{ikt} = \frac{\sin\left((N + \frac12)t\right)}{\sin(t/2)}$$

The **Dirichlet kernel** $D_N$ has height $2N + 1$ at $t = 0$, area $2\pi$, and oscillating side lobes that take negative values. That last fact causes all the trouble.

## Dirichlet's theorem

If $f$ is piecewise smooth (finitely many jumps, with one-sided derivatives everywhere), then at every $x$

$$S_Nf(x) \to \frac{f(x^+) + f(x^-)}{2}$$

so to $f(x)$ where $f$ is continuous and to the midpoint at a jump. The proof splits the integral near $t = 0$, where the kernel's peak picks out the two one-sided values, and away from it, where the **Riemann-Lebesgue lemma**, that $\int g(t)\sin(Mt)\,dt \to 0$ as $M \to \infty$ for integrable $g$, kills the rest.

## The Gibbs phenomenon

Near a jump of size $J$, $S_N$ overshoots by about $0.0895J$ on each side, at a distance of about $\pi/N$ from the jump. The overshoot narrows as $N$ grows but its height approaches

$$\left(\frac{1}{\pi}\text{Si}(\pi) - \frac12\right)J = 0.0895J \qquad \text{Si}(\pi) = \int_0^\pi\frac{\sin t}{t}\,dt = 1.8519$$

So convergence near a jump isn't uniform: the maximum error never falls below 9% of the jump. Lesson 42's Fejér means, built from a kernel that's never negative, remove the overshoot.

## Continuity isn't enough

There are continuous functions whose Fourier series diverge at a point. Smoothness, not mere continuity, is what Dirichlet's theorem needs; the more derivatives $f$ has, the faster $c_k \to 0$ and the faster $S_Nf$ converges.
:::

::: example
## Show that the Dirichlet kernel has height $2N + 1$ at $t = 0$ and area $2\pi$ over one period.

::: solution
1. **Height at t = 0.** Every term $e^{ikt}$ is 1 there, and there are $2N + 1$ of them:
   $$D_N(0) = 2N + 1$$
2. **Integrate term by term.** Over $[-\pi, \pi]$, $\int e^{ikt}\,dt = 0$ for $k \ne 0$ and $2\pi$ for $k = 0$, so for every $N$
   $$\int_{-\pi}^{\pi}D_N(t)\,dt = 2\pi$$
3. **As N grows.** The kernel gets taller and narrower with the same area, but it never becomes positive everywhere: its side lobes swing negative by an amount that doesn't shrink relative to the peak.

**Answer:** $D_N(0) = 2N + 1$, and its area over one period is $2\pi$ for every N.
:::
:::

::: example
## A ±1 square wave's partial sums overshoot near the jump. What peak do they approach, and how far from the jump does it sit for $N = 50$?

::: solution
1. **Size of the overshoot.** The jump is $J = 2$, so the overshoot approaches
   $$0.0895 \times 2 = 0.179$$
2. **The peak.** That's a peak of 1.179, which is $\frac{2}{\pi}\text{Si}(\pi)$.
3. **Where it sits.** About $\pi/N$ from the jump:
   $$\frac{\pi}{50} = 0.063\ \text{rad}$$
   or 1% of a period.
4. **More terms.** A thousand terms move it ten times closer but leave it just as tall, which is why a band-limited square wave on a scope always shows those spikes.

**Answer:** the peak approaches 1.179, and for $N = 50$ it sits about 0.063 radians from the jump.
:::
:::

::: example
## The sawtooth $f(x) = x$ on $(-\pi, \pi)$, repeated, has $S_Nf(x) = 2\sum_{k=1}^{N}\frac{(-1)^{k+1}}{k}\sin kx$. What does the series give at $x = \pi$, and what is the peak of its partial sums near there for large $N$?

::: solution
1. **The value at π.** Every $\sin k\pi = 0$, so the series gives 0: the midpoint of the jump from $\pi$ down to $-\pi$.
2. **The overshoot.** The jump is $2\pi$, so the partial sums overshoot to about
   $$\pi + 0.0895(2\pi) = 3.704$$
   just inside the jump.
3. **Compare.** That's again about 9% of the jump above the function's largest value, $\pi$.

**Answer:** the series gives 0 at $x = \pi$, and the partial sums peak near 3.704 just inside the jump.
:::
:::

::: check
given: a = -2 | 0 | 1; b = 3 | 5
answer: (a + b)/2
tolerance: 0.5%

## A piecewise smooth function jumps from {a} to {b} at a point. What does its Fourier series converge to there?

::: right
Right. The series converges to the midpoint, $\frac12(\given{a} + \given{b})$ = {answer}.
:::

::: misses
- [b] That's the value just after the jump. The series splits the difference.
- [a] That's the value just before the jump.
- [any] Not yet. Dirichlet's theorem gives the average of the two one-sided values.
:::
:::

::: check
given: J = 1 | 2 | 10; top = 1 | 5
answer: top + 0.0895*J
tolerance: 0.2%

## A signal jumps by {J} at a point, its value just after the jump being {top}. Approximately what peak do its Fourier partial sums approach just after the jump, for large $N$?

::: right
Right. The Gibbs overshoot is about 8.95% of the jump: {top} + 0.0895 × {J} = {answer}.
:::

::: misses
- [top + 0.179*J] That's 17.9%, the overshoot of a ±1 square wave expressed as a fraction of its height, not its jump.
- [top] The overshoot doesn't vanish as $N$ grows; it only narrows.
- [any] Not yet. Add 8.95% of the jump to the value after it.
:::
:::

::: check
given: N = 5 | 20 | 100
answer: 2*N + 1
tolerance: 0.1

## What is the height of the Dirichlet kernel $D_{\given{N}}$ at $t = 0$?

::: right
Right. All $2N + 1$ exponentials equal 1 there: {answer}.
:::

::: misses
- [2*N] Count $k = 0$ too: the sum runs from $-N$ to $N$.
- [N + 1] The sum runs over negative $k$ as well.
- [any] Not yet. Count the terms from $-N$ to $N$.
:::
:::

::: check
kind: python
given: N = 50 | 200 | 800

## For the ±1 square wave's partial sum $S_N(x) = \frac{4}{\pi}\sum_{k\text{ odd} \le N}\frac{\sin kx}{k}$, evaluate it on `x = np.linspace(1e-4, 4 / N, 4000)` for `N` = {N} and set `peak` to its largest value and `where` to the $x$ where that happens. Set `ratio` to `where * N`, which should be close to $\pi$, and `gibbs` to $\frac{2}{\pi}\text{Si}(\pi)$, with $\text{Si}(\pi)$ by Simpson's rule on 2000 intervals.

```python starter
import numpy as np
x = np.linspace(1e-4, 4 / N, 4000)
peak = where = ratio = gibbs = 1
print(peak, where, gibbs)
```

```python solution
import numpy as np
x = np.linspace(1e-4, 4 / N, 4000)
k = np.arange(1, N + 1, 2)
S = 4 / np.pi * np.sin(np.outer(x, k)) @ (1 / k)
i = np.argmax(S)
peak, where = S[i], x[i]
ratio = where * N
t = np.linspace(0, np.pi, 2001)
g = np.where(t == 0, 1.0, np.sin(t) / np.where(t == 0, 1, t))
h = t[1] - t[0]
Si = h / 3 * (g[0] + g[-1] + 4 * g[1:-1:2].sum() + 2 * g[2:-1:2].sum())
gibbs = 2 / np.pi * Si
print(peak, where, gibbs)
```

```python tests
import numpy as np
assert abs(gibbs - 1.1789797) < 1e-6, "(2/π)·Si(π) is 1.17898."
assert abs(peak - gibbs) < 0.01, f"The partial sums' peak should be close to {gibbs:.4f} for large N."
assert 2.5 < ratio < 3.5, "The peak sits about π/N from the jump."
```

::: right
Right. The peak stays near 1.179 at every $N$ while its position moves in as $\pi/N$: non-uniform convergence you can see. Only the kernel's negative lobes allow a sum of a bounded function to overshoot it.
:::
:::

::: check
given: N = 5 | 20 | 100
answer: 2*pi/(2*N + 1)
tolerance: 0.5%

## Where is the first zero of the Dirichlet kernel $D_{\given{N}}(t) = \sin((N + \frac12)t)/\sin(t/2)$ to the right of $t = 0$?

::: right
Right. The numerator first vanishes at $(N + \frac12)t = \pi$, so $t = 2\pi/(2N + 1)$ = {answer}: the main lobe narrows as $1/N$ while its height grows as $2N + 1$, keeping the area at $2\pi$.
:::

::: misses
- [pi/(2*N + 1)] The numerator is $\sin((N + \frac12)t)$, zero when $(N + \frac12)t = \pi$.
- [2*pi] That's where $\sin(t/2)$ vanishes, the kernel's next peak, not a zero.
- [any] Not yet. Solve $(N + \frac12)t = \pi$.
:::
:::

::: check
kind: choice

## Why do Fourier partial sums overshoot a jump while Fejér means (averages of the partial sums) don't?

- [x] The Dirichlet kernel takes negative values, so convolving a step with it can exceed the step; Fejér's kernel is never negative
- [ ] Fejér means use more terms
- [ ] The Dirichlet kernel's area is larger than $2\pi$
- [ ] Partial sums don't converge at all near a jump

::: right
Right. A weighted average with nonnegative weights of total 1 can't exceed the largest value averaged. The Dirichlet kernel's negative lobes break that, which is where the 9% comes from.
:::

::: misses
- [2] Fejér's mean of $S_0, \ldots, S_N$ uses the same harmonics, just weighted to taper.
- [3] Both kernels have area exactly $2\pi$.
- [4] They converge at every point; just not uniformly near the jump.
:::
:::

::: explain
## A band-limited reconstruction of a square wave always shows spikes near each edge, and adding bandwidth makes them narrower but not shorter. Explain why, using the kernel.

::: model
Keeping harmonics up to $N$ is the same as convolving the square wave with the Dirichlet kernel $D_N$, a peak with oscillating side lobes, some negative. Near an edge the convolution integrates the kernel against a step, so its value is the area of the kernel up to some point, a running integral that overshoots its final value because the first negative lobe comes after the first positive one. Making $N$ larger squeezes the kernel horizontally while keeping its shape, so the overshoot moves closer to the edge but its height, set by the kernel's shape, stays at about 9% of the jump. Only changing the weights, as Fejér's or another taper does, removes it.
:::
:::

::: practice

::: check
given: N = 5 | 10 | 20 | 50 | 100 | 1000
answer: pi/N
tolerance: 0.5%

## About how far from a jump does the Gibbs overshoot peak, for harmonics up to $N$ = {N}?

::: misses
- [1/N] The peak is at about $\pi/N$.
- [any] About $\pi/N$ radians.
:::
:::

::: check
given: A = 1..12 int
answer: A*2/pi*1.8519
tolerance: 0.5%

## A square wave switches between ±{A}. What peak do its Fourier partial sums approach?

::: misses
- [A] The partial sums overshoot: $\frac{2}{\pi}\text{Si}(\pi) \approx 1.179$ times $A$.
- [any] $\frac{2}{\pi}\text{Si}(\pi)A \approx 1.179A$.
:::
:::
:::
