---
title: Fejér summation and approximate identities
heading: Averaging partial sums to tame the Gibbs overshoot
eyebrow: A14 · Lesson 42 · Fejér summation
xp: 40
---

::: hook
Lesson 40 showed that the partial sums of a Fourier series overshoot near a jump by about 9%, however many terms you keep, and there are even continuous functions whose Fourier series diverge at a point. Fejér found a simple cure: average the first N partial sums. The averages converge uniformly to every continuous periodic function, and they never overshoot. In signal processing this is the triangular (Bartlett) window: tapering the high coefficients instead of chopping them off. The idea behind it, convolving with a positive kernel that concentrates at a point, is called an **approximate identity**.
:::

::: play
- The square wave is ±1. The first curve is its Fourier partial sum through harmonic N; the second is the Fejér mean, which multiplies harmonic k by $1 - \frac{k}{N + 1}$.
- The partial sum overshoots to about 1.18 (9% of the jump of 2) next to the jump, however large N gets. The Fejér mean stays below 1.
- The price: near the jump the Fejér mean rises more slowly. Tapering trades sharpness for freedom from ringing, the same trade as windowing in spectral analysis.
:::

```sim plot
view: graph
x: x = 0..3.1416
y: y = -0.2..1.3
slider: N = 3..15 step 2 = 9
plot: (4/pi)*(sin(x) + step(N - 2.5)*sin(3*x)/3 + step(N - 4.5)*sin(5*x)/5 + step(N - 6.5)*sin(7*x)/7 + step(N - 8.5)*sin(9*x)/9 + step(N - 10.5)*sin(11*x)/11 + step(N - 12.5)*sin(13*x)/13 + step(N - 14.5)*sin(15*x)/15) | label: partial sum | samples: 800
plot: (4/pi)*((1 - 1/(N + 1))*sin(x) + step(N - 2.5)*(1 - 3/(N + 1))*sin(3*x)/3 + step(N - 4.5)*(1 - 5/(N + 1))*sin(5*x)/5 + step(N - 6.5)*(1 - 7/(N + 1))*sin(7*x)/7 + step(N - 8.5)*(1 - 9/(N + 1))*sin(9*x)/9 + step(N - 10.5)*(1 - 11/(N + 1))*sin(11*x)/11 + step(N - 12.5)*(1 - 13/(N + 1))*sin(13*x)/13 + step(N - 14.5)*(1 - 15/(N + 1))*sin(15*x)/15) | label: Fejér mean | color: ch3 | samples: 800
plot: 1 | dashed
```

::: predict
## The Fejér mean of a function that stays between −1 and 1: can it ever exceed 1?

- [ ] Yes, by about 9% near jumps
- [x] No: it's an average of the function with nonnegative weights
- [ ] Yes, but only for small N
- [ ] Only if the function is discontinuous

::: reveal
No. The Fejér mean is the convolution of f with the Fejér kernel, which is nonnegative and integrates to 1, so it's a weighted average of f's values and stays within f's range. The Dirichlet kernel behind the plain partial sums has negative lobes, which is what allows the overshoot.
:::
:::

::: nameit
## Partial sums as convolutions

The N-th Fourier partial sum is $S_Nf = f * D_N$ with the **Dirichlet kernel** $D_N(x) = \sum_{\lvert k\rvert\le N}e^{jkx} = \frac{\sin(N + \frac12)x}{\sin\frac x2}$. It has height $2N + 1$ at 0 and oscillating side lobes of both signs. Its absolute integral, the **Lebesgue constant** $L_N = \frac{1}{2\pi}\int\lvert D_N\rvert$, grows like $\frac{4}{\pi^2}\ln N$: that unbounded growth is why partial sums can misbehave.

## Fejér means

Average the first N partial sums: $\sigma_N = \frac{S_0 + \cdots + S_{N-1}}{N}$. Then $\sigma_Nf = f * F_N$ with the **Fejér kernel**

$$F_N(x) = \frac1N\left(\frac{\sin(Nx/2)}{\sin(x/2)}\right)^2 \ge 0,$$

which integrates to 1 (over a period, divided by 2π), has height N at 0, and concentrates near 0 as N grows. In terms of coefficients, $\sigma_N$ multiplies harmonic k by $1 - \frac{\lvert k\rvert}{N}$: a triangular taper.

**Fejér's theorem:** for continuous periodic f, $\sigma_Nf \to f$ uniformly.

## Approximate identities

A family of kernels $K_n \ge 0$ with $\int K_n = 1$ whose mass concentrates near 0 (for each δ, $\int_{\lvert x\rvert>\delta}K_n \to 0$) gives $K_n * f \to f$ at every point of continuity, uniformly for uniformly continuous f. Fejér kernels, Gaussians of shrinking width (the heat kernel), and the Poisson kernel are all approximate identities. They're how smooth functions approximate rough ones, and how a sampling or measurement process blurs a signal.
:::

::: example
## Compare the largest values of the partial sum and the Fejér mean of the ±1 square wave, using harmonics up to 49 and 50 respectively.

::: solution
1. **The partial sum.** Through harmonic 49 it peaks at 1.179 just right of the jump: the Gibbs overshoot, 9% of the jump of 2.
2. **The Fejér mean.** $\sigma_{50}$ weights harmonic k by $1 - \frac{k}{50}$. It peaks at 0.987 and never exceeds 1.
3. **The price.** At the jump itself, the Fejér mean rises from −1 to 1 over a width of about $\frac{2\pi}{N}$, roughly twice as slowly as the partial sum.
4. **In spectrum analysis.** The same taper suppresses side lobes at the cost of a wider main lobe.

**Answer:** the partial sum peaks at 1.179, and the Fejér mean at 0.987.
:::
:::

::: example
## Compute the Lebesgue constants $L_1$, $L_{10}$ and $L_{100}$.

::: solution
1. **Integrate numerically.** Integrating $\lvert D_N\rvert$ gives 1.436, 2.223 and 3.139.
2. **Compare with the growth law.** They grow like
   $$\frac{4}{\pi^2}\ln N + 1.27$$
   which gives 2.20 and 3.14 for N = 10 and 100.
3. **What $L_N$ measures.** $L_N$ is the operator norm of $S_N$ on continuous functions with the sup norm (lesson 38): a partial sum can be up to $L_N$ times larger than the function.
4. **The consequence.** Since $L_N \to \infty$, the uniform boundedness principle implies that some continuous function has a Fourier series that diverges at a point.
5. **Fejér's operator.** It has norm exactly 1, because its kernel is positive.

**Answer:** $L_1 = 1.436$, $L_{10} = 2.223$ and $L_{100} = 3.139$.
:::
:::

::: example
## A signal's spectrum is estimated from its first five harmonics. What weights does the Fejér (triangular) taper apply?

::: solution
1. **The weights.** With N = 5, harmonic k gets $1 - \frac k5$: 1, 0.8, 0.6, 0.4, 0.2 for k = 0 to 4, and harmonics from 5 on get 0.
2. **Compare with the abrupt cutoff.** Against the abrupt cutoff (all weights 1, then 0), the taper reduces the ripple near sharp features in the reconstruction.
3. **Its name and transform.** It's the Bartlett window of spectral analysis, and the Fejér kernel is its transform: positive everywhere, with side lobes falling as $\frac{1}{x^2}$ instead of $\frac1x$.

**Answer:** the weights are 1, 0.8, 0.6, 0.4 and 0.2 for harmonics 0 to 4, and 0 from harmonic 5 on.
:::
:::

::: check
given: k = 1 | 3 | 7; N = 10 | 20
answer: 1 - k/N
tolerance: 0.5%

## The Fejér mean $\sigma_{\given{N}}$ multiplies harmonic k = {k} by what factor?

::: right
Right. $1 - \frac{\lvert k\rvert}{N}$, a triangular taper.
:::

::: misses
- [1] That's the plain partial sum's weight.
- [any] $1 - \frac kN$.
:::
:::

::: check
kind: parts
given: N = 5 | 20 | 100

## The kernels at x = 0, for N = {N}.

::: part
answer: 2*N + 1
tolerance: 0

### What is $D_N(0)$?

::: misses
- [N] Count the terms $e^{jk\cdot0} = 1$ for $\lvert k\rvert \le N$.
- [any] $2N + 1$.
:::
:::

::: part
answer: N
tolerance: 0

### What is $F_N(0)$?

::: misses
- [any] The average of $D_0(0), \ldots, D_{N-1}(0)$, that is, of $1, 3, \ldots, 2N - 1$.
:::
:::
:::

::: check
given: N = 10 | 100 | 1000
answer: 4/pi^2*ln(N) + 1.27
tolerance: 2%

## Estimate the Lebesgue constant $L_N$ for N = {N}.

::: right
Right. About $\frac{4}{\pi^2}\ln N + 1.27$: slow but unbounded growth.
:::

::: misses
- [4/pi^2*log(N) + 1.27] Use the natural logarithm.
- [any] $\frac{4}{\pi^2}\ln N + 1.27$.
:::
:::

::: check
given: k = 2 | 3; N = 5 | 10; x = 0 | 0.5
answer: (1 - k/N)*cos(k*x)
tolerance: 0.5%

## f(x) = cos({k}x). What is $\sigma_{\given{N}}f$ at x = {x}?

::: right
Right. A single harmonic is just scaled by $1 - \frac kN$.
:::

::: misses
- [cos(k*x)] The Fejér mean shrinks every harmonic except the constant.
- [any] $\left(1 - \frac kN\right)\cos kx$.
:::
:::

::: check
given: s = 0.2 | 0.5; x = 1 | 2
answer: x^2 + s^2
tolerance: 0.5%

## Convolve $f(x) = x^2$ with a Gaussian of standard deviation {s}. What is the result at x = {x}?

::: right
Right. $x^2 + s^2$: the blur adds the kernel's variance, and the error shrinks as the kernel narrows.
:::

::: misses
- [x^2] Blurring a curved function changes it: by $s^2$ here.
- [any] $\int(x - y)^2g(y)\,dy = x^2 + s^2$.
:::
:::

::: check
kind: choice

## Why does the Fejér mean never overshoot the range of the function?

- [ ] Because it uses fewer harmonics
- [x] Because its kernel is nonnegative and integrates to 1, so it's a weighted average of the function
- [ ] Because it converges faster than the partial sums
- [ ] Because it only applies to continuous functions

::: right
Right. A weighted average with nonnegative weights stays between the function's smallest and largest values.
:::

::: misses
- [1] It uses the same harmonics, just weighted.
- [3] Near jumps it converges more slowly.
- [4] It applies to integrable functions too; it just converges uniformly for continuous ones.
:::
:::

::: check
kind: derivation
vars: x = -2..2, s = 0.05..1

## Convolve with a Gaussian approximate identity $g_s$ of standard deviation s.

::: step
answer: x^2 + s^2

### What is $(g_s * x^2)(x)$?
:::

::: step
answer: x^4 + 6*x^2*s^2 + 3*s^4

### And $(g_s * x^4)(x)$? (A Gaussian's fourth moment is $3s^4$.)
:::

::: right
Right. As $s \to 0$ both converge to the function: an approximate identity at work.
:::
:::

::: check
kind: python

## Compute the Lebesgue constant $L_{10} = \frac1\pi\int_0^\pi\left\lvert\frac{\sin 10.5x}{\sin(x/2)}\right\rvert dx$ with a Riemann sum on 400 001 points of $[10^{-6}, \pi]$. Set `L10`.

```python starter
import numpy as np

L10 = 1.0
print(L10)
```

```python solution
import numpy as np

x = np.linspace(1e-6, np.pi, 400001)
D = np.sin(10.5 * x) / np.sin(x / 2)
L10 = np.sum(np.abs(D)) * (x[1] - x[0]) / np.pi
print(L10)
```

```python tests
import math
assert abs(L10 - 2.2234) < 2e-3, f"L_10 is about 2.223; got {L10}."
assert abs(L10 - (4 / math.pi**2 * math.log(10) + 1.27)) < 0.05, "It should be close to the asymptotic formula."
```

::: right
Right. 2.223: the partial sum $S_{10}$ can amplify a function's sup norm by that much, while the Fejér mean never amplifies at all.
:::
:::

::: explain
## Why does averaging the partial sums of a Fourier series fix convergence?

::: model
Each partial sum convolves the function with the Dirichlet kernel, which has large negative side lobes; their total absolute area grows like ln N, so the partial sums can amplify features and overshoot near jumps. Averaging the first N partial sums averages their kernels, and the oscillating lobes largely cancel, leaving the Fejér kernel, which is the square of a sine ratio and therefore never negative. A nonnegative kernel that integrates to 1 and concentrates near 0 produces local weighted averages of the function, which converge to it wherever it's continuous and can't stray outside its range.
:::
:::

::: practice

::: check
given: k = 2 | 9; N = 12 | 30
answer: 1 - k/N
tolerance: 0.5%

## Fejér weight of harmonic {k} with N = {N}?

::: misses
- [any] $1 - \frac kN$.
:::
:::

::: check
given: s = 0.2 | 0.5; x = 0.5 | 3
answer: x^2 + s^2
tolerance: 0.5%

## Gaussian blur (σ = {s}) of $x^2$ at {x}?

::: misses
- [any] $x^2 + \sigma^2$.
:::
:::
:::
