---
title: "What uniform convergence preserves: continuity, integrals and derivatives"
heading: When you may swap a limit with an integral or a derivative
eyebrow: "A14 · Lesson 26 · What uniform convergence preserves"
xp: 40
---

::: hook
Engineers swap limits and integrals constantly: integrate a Fourier series term by term, differentiate a power series to get a derivative, take the limit of a sequence of approximate solutions and assume its integral is the limit of their integrals. Usually it works. When it doesn't, the answer is silently wrong, and the culprit is always convergence that isn't uniform. This lesson gives the rules: uniform convergence preserves continuity and integrals; derivatives need the derivatives to converge uniformly too.
:::

::: play
- The curve is $f_n(x) = 2n^2xe^{-n^2x^2}$ on [0, 1]. At every x it tends to 0 as n grows: the spike rushes toward x = 0.
- Yet its integral over [0, 1] (readout) tends to 1, not 0. The limit of the integrals isn't the integral of the limit.
- The spike's height grows like 0.86n, so the sup norm of $f_n - 0$ grows: the convergence is far from uniform, which is exactly what lets the integrals misbehave.
:::
:::

```sim plot
view: graph
x: x = 0..1
y: y = 0..9
slider: n = 1..10 step 1 = 3
plot: 2*n^2*x*exp(-n^2*x^2) | samples: 1200 | label: fₙ(x)
readout: integral over [0, 1] = 1 - exp(-n^2)
readout: peak height = sqrt(2)*n*exp(-0.5)
```

::: predict
## $f_n(x) = \frac{\sin(n^2x)}{n}$ converges uniformly to 0. Do the derivatives $f_n'$ converge to 0?

- [ ] Yes, uniformly
- [ ] Yes, pointwise
- [x] No: $f_n'(x) = n\cos(n^2x)$, which doesn't converge at all
- [ ] The derivatives don't exist

::: reveal
No. Tiny, fast wiggles can have huge slopes: the functions shrink as $\frac1n$ while their slopes grow as n. Uniform convergence of the functions says nothing about the derivatives; you need the *derivatives* to converge uniformly.
:::
:::

::: nameit
## The three theorems

Let $f_n \to f$ on [a, b].

1. **Continuity:** if each $f_n$ is continuous and the convergence is uniform, f is continuous.
2. **Integrals:** if each $f_n$ is integrable and the convergence is uniform, then $\int_a^bf_n \to \int_a^bf$, because

$$\left\lvert\int_a^bf_n - \int_a^bf\right\rvert \le (b - a)\lVert f_n - f\rVert_\infty$$

3. **Derivatives:** if each $f_n$ is differentiable, $f_n'$ converges uniformly, and $f_n(x_0)$ converges at one point, then $f_n$ converges uniformly to a differentiable f with $f' = \lim f_n'$.

## For series

Apply them to partial sums. A uniformly convergent series of continuous functions has a continuous sum and can be integrated term by term; it can be differentiated term by term if the differentiated series converges uniformly.

## Power series

Inside its radius of convergence R, a power series converges uniformly on every closed interval [−r, r] with r < R (M-test with $M_k = \lvert a_k\rvert r^k$). So on such intervals it can be integrated and differentiated term by term, and the results have the same radius. Example: integrating $\sum_{k\ge 0}t^k = \frac{1}{1 - t}$ from 0 to x gives $\sum\frac{x^{k+1}}{k + 1} = -\ln(1 - x)$ for $\lvert x\rvert < 1$.
:::

::: example
## Find $\lim\int_0^1f_n$ and $\int_0^1\lim f_n$ for $f_n = 2n^2xe^{-n^2x^2}$.

::: solution
1. **Integrate first.**
   $$\begin{aligned} \int_0^12n^2xe^{-n^2x^2}dx &= \left[-e^{-n^2x^2}\right]_0^1 \\ &= 1 - e^{-n^2} \\ &\to 1 \end{aligned}$$
2. **Take the limit first.** $f_n(x) \to 0$ for every x (for x > 0 the exponential wins; at 0 it's 0), so
   $$\int_0^1\lim f_n = 0$$
3. **Why the swap fails.** The convergence isn't uniform:
   $$\lVert f_n\rVert_\infty = \sqrt2ne^{-1/2}$$
   grows.

**Answer:** $\lim\int_0^1f_n = 1$, but $\int_0^1\lim f_n = 0$.
:::
:::

::: example
## Use term-by-term integration to compute $\ln 2$.

::: solution
1. **The series.** For $\lvert x\rvert < 1$,
   $$-\ln(1 - x) = \sum_{k\ge 1}\frac{x^k}{k}$$
2. **Put in x = ½.**
   $$\begin{aligned} \ln 2 &= \sum\frac{1}{k2^k} \\ &= \frac12 + \frac18 + \frac{1}{24} + \cdots \end{aligned}$$
3. **Bound the tail after 16 terms.**
   $$\begin{aligned} \text{tail} &\le \frac{1}{17}\sum_{k\ge 17}2^{-k} \\ &= \frac{1}{17 \cdot 2^{16}} \\ &= 9.0 \times 10^{-7} \end{aligned}$$
   so 16 terms leave an error below $10^{-6}$.

**Answer:** $\ln 2 = \sum\frac{1}{k2^k}$, and 16 terms give it to within $10^{-6}$.
:::
:::

::: example
## Can $f(x) = \sum_{k\ge1}\frac{\sin kx}{k^3}$ be differentiated term by term?

::: solution
1. **What's needed.** Term-by-term differentiation needs the differentiated series to converge uniformly.
2. **The differentiated series.** It's $\sum\frac{\cos kx}{k^2}$, with
   $$\left\lvert\frac{\cos kx}{k^2}\right\rvert \le \frac{1}{k^2}$$
   and
   $$\begin{aligned} \sum\frac{1}{k^2} &= \frac{\pi^2}{6} \\ &= 1.645 \end{aligned}$$
3. **Apply the M-test.** By the Weierstrass M-test it converges uniformly, so yes:
   $$f'(x) = \sum\frac{\cos kx}{k^2}$$
   and $\lvert f'\rvert \le 1.645$.
4. **One more derivative.** Differentiating once more gives $\sum\frac{-\sin kx}{k}$, which isn't uniformly convergent (it jumps at multiples of 2π), so f is $C^1$ but its second derivative needs more care.

**Answer:** yes: $f'(x) = \sum\frac{\cos kx}{k^2}$, with $\lvert f'\rvert \le 1.645$.
:::
:::

::: check
given: L = 2 | 3; s = 0.01 | 0.002
answer: L*s
tolerance: 0.1%

## On an interval of length {L}, $\lVert f_n - f\rVert_\infty$ = {s}. How far apart can $\int f_n$ and $\int f$ be?

::: right
Right. $(b - a)\lVert f_n - f\rVert_\infty$ = {answer}.
:::

::: misses
- [s] Multiply by the interval's length.
- [any] Not yet. Integrate the sup bound.
:::
:::

::: check
given: n = 1 | 2 | 3
answer: 1 - exp(-n^2)
tolerance: 0.01%

## What's $\int_0^1 2n^2xe^{-n^2x^2}dx$ for n = {n}?

::: right
Right. $1 - e^{-n^2}$ = {answer}.
:::

::: misses
- [0] That's the integral of the pointwise limit; the integrals themselves tend to 1.
- [any] Not yet. An antiderivative is $-e^{-n^2x^2}$.
:::
:::

::: check
given: n = 2 | 5 | 20
answer: sqrt(2)*n*exp(-0.5)
tolerance: 0.1%

## How tall is the peak of $2n^2xe^{-n^2x^2}$ for n = {n}?

::: right
Right. At $x = \frac{1}{n\sqrt2}$ the value is $\sqrt2ne^{-1/2}$ = {answer}.
:::

::: misses
- [2*n*exp(-1)] Find where the derivative vanishes: $x = \frac{1}{n\sqrt2}$.
- [any] Not yet. Maximize over x.
:::
:::

::: check
given: x = 0.5 | 0.25 | -0.5
answer: -ln(1 - x)
tolerance: 0.01%

## Integrating $\sum t^k$ term by term from 0 to x gives $\sum\frac{x^{k+1}}{k + 1}$. What's its value at x = {x}?

::: right
Right. $-\ln(1 - x)$ = {answer}.
:::

::: misses
- [1/(1 - x)] That's the series before integrating.
- [any] Not yet. $\int_0^x\frac{dt}{1 - t}$.
:::
:::

::: check
given: n = 10 | 100 | 1000
answer: n
tolerance: 0.1%

## For $f_n = \frac{\sin(n^2x)}{n}$, what's $\lVert f_n'\rVert_\infty$ when n = {n}?

::: right
Right. $f_n' = n\cos(n^2x)$, with sup n = {answer}, while $\lVert f_n\rVert_\infty = 1/n$.
:::

::: misses
- [1/n] That's the sup of $f_n$ itself.
- [any] Not yet. Differentiate: the chain rule brings out $n^2$.
:::
:::

::: check
kind: choice

## A Fourier series $\sum c_k\sin(kx)$ has $\sum\lvert c_k\rvert < \infty$. Which is guaranteed?

- [x] It converges uniformly to a continuous function, which can be integrated term by term
- [ ] It can be differentiated term by term
- [ ] Its sum has a jump somewhere
- [ ] It converges only pointwise

::: misses
- [2] That needs $\sum k\lvert c_k\rvert < \infty$, for the differentiated series.
- [3] A uniform limit of continuous functions is continuous.
- [4] The M-test gives uniform convergence.
:::
:::

::: check
kind: parts
given: n = 4 | 100 | 10000

## $f_n(x) = \frac{\sin nx}{\sqrt n}$.

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

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

::: misses
- [any] $\frac{1}{\sqrt n}$, so $f_n \to 0$ uniformly.
:::
:::

::: part
answer: sqrt(n)
tolerance: 0.5%

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

::: misses
- [any] $f_n' = \sqrt n\cos nx$: the derivatives don't converge at all.
:::
:::
:::

::: check
kind: derivation
vars: x = 0..0.9

## Integrate geometric series term by term from 0 to x.

::: step
answer: ln(1 + x)

### What is $\sum_{k\ge0}\frac{(-1)^kx^{k+1}}{k + 1}$, from $\sum(-t)^k$?
:::

::: step
answer: atan(x)

### What is $\sum_{k\ge0}\frac{(-1)^kx^{2k+1}}{2k + 1}$, from $\sum(-t^2)^k$?
:::

::: right
Right. Power series converge uniformly on closed intervals inside their radius, so term-by-term integration is legitimate there.
:::
:::

::: explain
## Why does uniform convergence let you swap a limit and an integral, while pointwise convergence doesn't?

::: model
The difference between $\int f_n$ and $\int f$ is the integral of $f_n - f$, which is at most the length of the interval times the largest value of $\lvert f_n - f\rvert$. Uniform convergence says that largest value goes to zero, so the integrals must converge. Pointwise convergence only says each point's error eventually shrinks; the error can stay large somewhere, as a tall narrow spike that moves as n grows, and a spike of fixed area contributes a fixed amount to the integral however narrow it gets. That's exactly what happens with $2n^2xe^{-n^2x^2}$: every point's value goes to 0 while the area under the moving spike stays near 1.
:::
:::

::: practice

::: check
given: L = 2 | 0.5; s = 0.05 | 0.0004
answer: L*s
tolerance: 0.1%

## Integral difference bound, length {L}, sup error {s}?

::: misses
- [any] $(b - a)\lVert f_n - f\rVert_\infty$.
:::
:::

::: check
given: n = 2 | 3 | 5 | 10 | 20 | 50
answer: sqrt(2)*n*exp(-0.5)
tolerance: 0.1%

## Peak of $2n^2xe^{-n^2x^2}$, n = {n}?

::: misses
- [any] $\sqrt2ne^{-1/2}$.
:::
:::

::: check
given: x = 0.1 | 0.3 | 0.5 | 0.7 | 0.9 | 0.95
answer: -ln(1 - x)
tolerance: 0.01%

## $\sum_{k\ge 0}\frac{x^{k+1}}{k + 1}$ at {x}?

::: misses
- [any] $-\ln(1 - x)$.
:::
:::
:::
