---
title: Pointwise and uniform convergence
heading: When a sequence of functions converges everywhere, but not all at once
eyebrow: A14 · Lesson 25 · Pointwise and uniform convergence
xp: 40
---

::: hook
Fourier series, power series, the iterates of a solver, a filter's response as more taps are added: each is a sequence of *functions* closing in on a limit function. There are two very different ways that can happen. **Pointwise**, at each x separately, perhaps very slowly at some places; or **uniformly**, with one bound on the error that holds at every x at once. Only uniform convergence lets you say "the approximation is within ε everywhere," and only it carries continuity and integrals over to the limit. The Gibbs overshoot of a square wave's Fourier series is the classic case of pointwise convergence that isn't uniform.
:::

::: play
- The curve is $f_n(x) = x^n$ on [0, 1]. For each x < 1 it goes to 0 as n grows, and at x = 1 it stays 1: the pointwise limit jumps at the end.
- The readouts give the largest gap between $f_n$ and its limit on [0, a] and on [0, 1). On [0, a] with a < 1 the gap is $a^n$, which goes to 0: uniform convergence there.
- On all of [0, 1) the gap stays at 1 for every n, because there are always points close enough to 1 where $x^n$ is still near 1. Pointwise, but not uniform.
:::
:::

```sim plot
view: graph
x: x = 0..1
y: y = 0..1.05
slider: n = 1..100 step 1 = 10
slider: a = 0.5..0.99 step 0.01 = 0.9
plot: x^n | samples: 1000 | label: xⁿ
marker: x = a | label: a
readout: largest gap on [0, a] = a^n
readout: largest gap on [0, 1) = 1
```

::: predict
## $f_n(x) = nxe^{-nx}$ tends to 0 at every x ≥ 0. What's $\sup_{x\ge 0}\lvert f_n(x)\rvert$ for large n?

- [ ] It goes to 0
- [x] It stays at $1/e$ for every n
- [ ] It grows like n
- [ ] It's undefined

::: reveal
$1/e$: the bump moves to x = 1/n and keeps its height, $n\cdot\frac1n e^{-1}$. Every point is eventually passed by the bump, so the pointwise limit is 0, but the largest error never shrinks: not uniform.
:::
:::

::: nameit
## Two kinds of convergence

- **Pointwise:** $f_n(x) \to f(x)$ for each x. N may depend on both ε and x.
- **Uniform:** for every ε there's an N with $\lvert f_n(x) - f(x)\rvert < \varepsilon$ for all n > N and *all* x at once. Equivalently,

$$\lVert f_n - f\rVert_\infty = \sup_x\lvert f_n(x) - f(x)\rvert \to 0$$

the **sup norm** of the error.

## Testing

- Compute the sup of the error (often with calculus): $x^n$ on [0, a] has sup $a^n$; $\frac{x}{1 + nx^2}$ on ℝ has sup $\frac{1}{2\sqrt n}$ at $x = 1/\sqrt n$; $\frac{\sin nx}{n}$ has sup $\frac1n$.
- **Cauchy criterion:** $(f_n)$ converges uniformly iff for every ε there's an N with $\lVert f_m - f_n\rVert_\infty < \varepsilon$ for all m, n > N.
- **Weierstrass M-test:** if $\lvert u_k(x)\rvert \le M_k$ for all x and $\sum M_k < \infty$, then $\sum u_k(x)$ converges uniformly (and absolutely), with error after N terms at most $\sum_{k>N}M_k$.

## Why it matters

Uniform convergence is what makes an approximation trustworthy everywhere, and (lesson 26) what lets limits pass through continuity, integrals and, with care, derivatives. Pointwise convergence alone allows a sequence of continuous functions to converge to a discontinuous one, as $x^n$ does on [0, 1].
:::

::: example
## Does $\frac{x}{1 + nx^2}$ converge uniformly on ℝ? How large must n be for an error below 0.01?

::: solution
1. **Pointwise limit.** The pointwise limit is 0.
2. **Find the peak.** The derivative of $\frac{x}{1 + nx^2}$ vanishes at $x = \frac{1}{\sqrt n}$, where the value is $\frac{1}{2\sqrt n}$.
3. **The sup goes to 0.**
   $$\lVert f_n\rVert_\infty = \frac{1}{2\sqrt n} \to 0$$
   so the convergence is uniform.
4. **Size n.** It's below 0.01 when $\sqrt n > 50$, so for n > 2500.

**Answer:** yes, it converges uniformly to 0, and n > 2500 keeps the error below 0.01.
:::
:::

::: example
## Bound the error of $\sum_{k=1}^N\frac{\sin kx}{k^2}$ as an approximation to the full series, for every x.

::: solution
1. **Bound each term.**
   $$\left\lvert\frac{\sin kx}{k^2}\right\rvert \le \frac{1}{k^2}$$
   and $\sum\frac{1}{k^2}$ converges.
2. **Apply the M-test.** The series converges uniformly, with error at most
   $$\sum_{k>N}\frac{1}{k^2} < \frac1N$$
3. **For N = 1000.** That's below $10^{-3}$ at every x.

**Answer:** the error is below $\frac1N$ at every x, so below $10^{-3}$ for N = 1000.
:::
:::

::: example
## Does $f_n(x) = x^n(1 - x)$ converge uniformly on [0, 1]?

::: solution
1. **Pointwise limit.** $f_n \to 0$ everywhere.
2. **Find the sup.**
   $$f_n' = x^{n-1}(n - (n + 1)x)$$
   vanishes at $x = \frac{n}{n + 1}$, where
   $$f_n = \frac{1}{n + 1}\left(\frac{n}{n + 1}\right)^n$$
3. **For n = 10.** That's 0.0350.
4. **Let n grow.** Since $\left(\frac{n}{n + 1}\right)^n \to \frac1e$, the sup behaves like $\frac{1}{e(n + 1)} \to 0$, so the convergence is uniform.
5. **Compare $x^n$ alone.** Its sup on [0, 1) stays 1: the factor $1 - x$ tames the corner near 1.

**Answer:** yes. The sup is about $\frac{1}{e(n + 1)}$, which goes to 0.
:::
:::

::: check
given: a = 0.5 | 0.9 | 0.99; e = 0.01 | 0.0001
answer: floor(ln(e)/ln(a)) + 1
tolerance: 0

## For $x^n$ on [0, {a}], what's the smallest n with $\lVert x^n\rVert_\infty < \given{e}$?

::: right
Right. Need $a^n < \varepsilon$: n = {answer}.
:::

::: misses
- [floor(ln(e)/ln(a))] At that n, $a^n$ is still at least ε.
- [any] Not yet. The sup on [0, a] is $a^n$.
:::
:::

::: check
given: e = 0.011 | 0.003 | 0.0007
answer: floor(1/(4*e^2)) + 1
tolerance: 0

## For $\frac{x}{1 + nx^2}$ on ℝ, what's the smallest n with sup norm below {e}?

::: right
Right. $\frac{1}{2\sqrt n} < \varepsilon$ when $n > \frac{1}{4\varepsilon^2}$: n = {answer}.
:::

::: misses
- [floor(1/(2*e)) + 1] The sup is $\frac{1}{2\sqrt n}$, so n must exceed $\frac{1}{4\varepsilon^2}$.
- [any] Not yet. The sup is at $x = 1/\sqrt n$.
:::
:::

::: check
given: n = 4 | 100 | 10000
answer: 1/(2*sqrt(n))
tolerance: 0.1%

## What's $\sup_x\left\lvert\frac{x}{1 + \given{n}x^2}\right\rvert$?

::: right
Right. $\frac{1}{2\sqrt n}$ = {answer}.
:::

::: misses
- [1/sqrt(n)] That's where the maximum is; the value there is half of it.
- [any] Not yet. Maximize: the peak is at $x = 1/\sqrt n$.
:::
:::

::: check
given: N = 10 | 100 | 1000
answer: 1/N
tolerance: 0.1%

## By the M-test with $M_k = 1/k^2$ and the bound $\sum_{k>N}\frac{1}{k^2} < \frac1N$, how far can $\sum_{k\le \given{N}}\frac{\sin kx}{k^2}$ be from the full sum, at worst?

::: right
Right. Less than {answer}, at every x.
:::

::: misses
- [1/N^2] That's the next term only.
- [any] Not yet. Bound the tail of $\sum 1/k^2$.
:::
:::

::: check
given: n = 2 | 5 | 10 | 20 | 50 | 100
answer: exp(-1)
tolerance: 0.1%

## What's $\sup_{x\ge 0}\given{n}xe^{-\given{n}x}$?

::: right
Right. $1/e$ = {answer}, the same for every n: pointwise convergence to 0 that isn't uniform.
:::

::: misses
- [1/n] The peak is at x = 1/n, but its height is $n\cdot\frac1ne^{-1}$.
- [any] Not yet. Maximize: the derivative vanishes at x = 1/n.
:::
:::

::: check
kind: choice

## Which sequence converges uniformly on [0, 1]?

- [ ] $x^n$
- [x] $\frac{\sin(nx)}{n}$
- [ ] $nxe^{-nx}$
- [ ] $\frac{nx}{1 + nx}$

::: misses
- [1] Near x = 1 it stays close to 1, while the limit there (for x < 1) is 0.
- [3] Its peak stays at $1/e$.
- [4] Its limit is 1 for x > 0 and 0 at 0, and near 0 it's far from 1 for every n.
:::
:::

::: check
kind: parts
given: n = 5 | 10 | 50

## $f_n(x) = x^n(1 - x)$ on [0, 1].

::: part
answer: n/(n + 1)
tolerance: 0.5%

### Where is its maximum?

::: misses
- [any] $f_n' = x^{n-1}(n - (n + 1)x)$.
:::
:::

::: part
answer: (n/(n + 1))^n/(n + 1)
tolerance: 0.5%

### What is $\lVert f_n\rVert_\infty$?

::: misses
- [1/(n + 1)] Include the factor $\left(\frac{n}{n + 1}\right)^n \approx \frac1e$.
- [any] Evaluate at $x = \frac{n}{n + 1}$.
:::
:::
:::

::: check
kind: derivation
vars: n = 1..100

## $f_n(x) = \frac{x}{1 + nx^2}$ on [0, ∞).

::: step
answer: 1/sqrt(n)

### Where is its maximum?
:::

::: step
answer: 1/(2*sqrt(n))

### What is its sup norm?
:::

::: right
Right. The sup norm goes to 0, so $f_n \to 0$ uniformly, though slowly.
:::
:::

::: explain
## Why can a sequence of continuous functions converge pointwise to a discontinuous limit, and why can't that happen with uniform convergence?

::: model
Pointwise convergence lets each point converge at its own pace. For $x^n$ on [0, 1], points near 1 converge to 0 extremely slowly, while x = 1 stays at 1, so every $f_n$ is continuous yet the limit jumps at 1: the slow region near 1 squeezes into a break. Uniform convergence forbids that by requiring one N that works at every point. Then near any point the limit is within ε of a continuous $f_n$, which itself varies by less than ε over a small enough interval, so the limit varies by less than 3ε there: it's continuous. The sup norm is the measure that makes this precise.
:::
:::

::: practice

::: check
given: a = 0.7 | 0.95; e = 0.001 | 0.00001
answer: floor(ln(e)/ln(a)) + 1
tolerance: 0

## Smallest n with $\sup_{[0,\given{a}]}x^n < \given{e}$?

::: misses
- [any] $\lfloor\ln\varepsilon/\ln a\rfloor + 1$.
:::
:::

::: check
given: n = 4 | 9 | 25 | 100 | 400 | 2500
answer: 1/(2*sqrt(n))
tolerance: 0.1%

## $\sup\frac{x}{1 + \given{n}x^2}$?

::: misses
- [any] $\frac{1}{2\sqrt n}$.
:::
:::

::: check
given: e = 0.033 | 0.021 | 0.013 | 0.007 | 0.0013 | 0.0009
answer: floor(1/(4*e^2)) + 1
tolerance: 0

## Smallest n with that sup below {e}?

::: misses
- [any] $n > \frac{1}{4\varepsilon^2}$.
:::
:::
:::
