---
title: "Interchange of Limits: Continuity, Integration, Differentiation"
module: Sequences and Series of Functions
moduleNumber: 7
lessonNumber: 2
order: 702
summary: >
  Passing to a limit inside a continuity statement, an integral, or a derivative
  is an interchange of two limits, and the two limits do not always commute.
  Uniform convergence licenses the first two swaps: the uniform limit of
  continuous functions is continuous, and the limit of the integrals is the
  integral of the limit. Differentiation needs uniform convergence of the
  derivatives, and counterexamples show why each hypothesis is required.
topics: [Sequences and Series of Functions]
sources:
  - book: Lebl
    ref: "Ch. 6 — Sequences of Functions; §6.2 Interchange of limits"
  - book: Shkoller
    ref: "§1.10 Interchanging limits with integrals"
  - book: Rosenlicht
    ref: "Ch. 7 — Interchange of limit operations"
draft: false
---

Much of analysis is the question of whether two limiting operations commute.
Continuity of a function is a limit ($\lim_{x_k \to x} f(x_k) = f(x)$); so are
integration and differentiation; and convergence of a sequence of functions is
another. Whenever a limit function inherits a property that each $f_n$ has, the
inheritance is a claim that two limits may be swapped. That claim is often
false.[^lebl-open]

The failure is visible already for numbers. With $x_{n,k} = \dfrac{n}{n+k}$,

$$
0 = \lim_{n \to \infty} \lim_{k \to \infty} \frac{n}{n+k}
\;\neq\;
\lim_{k \to \infty} \lim_{n \to \infty} \frac{n}{n+k} = 1,
$$

because the inner limits are taken in different orders. For sequences of
functions the two orders are "value of the limit function" versus "limit of the
values," and uniform convergence is the hypothesis that reconciles them.

$$
% caption: Continuity of the limit is the claim that this square of limits
% commutes; without uniform convergence the marked equality can fail.
\begin{tikzpicture}[scale=1.0, font=\footnotesize,
  cell/.style={align=center}]
\definecolor{acc}{HTML}{4A6FA5}
\node[cell] (tl) at (0,2.1) {$f_n(x_k)$};
\node[cell] (tr) at (4.6,2.1) {$f_n(x)$};
\node[cell] (bl) at (0,0) {$f(x_k)$};
\node[cell] (br) at (4.6,0) {$f(x)$};
\draw[->, acc, thick] (tl) -- (tr) node[midway, above, font=\scriptsize] {$k \to \infty$};
\draw[->, acc, thick] (tl) -- (bl) node[midway, left, font=\scriptsize] {$n \to \infty$};
\draw[->, acc, thick] (tr) -- (br) node[midway, right, font=\scriptsize] {$n \to \infty$};
\draw[->, acc, thick] (bl) -- (br) node[midway, below, font=\scriptsize] {$k \to \infty$};
\node[black, font=\large] at (2.3,1.05) {$?$};
\end{tikzpicture}
$$

## Continuity of the limit

Pointwise convergence does not preserve continuity. The powers $x^{2n}$, a
[discontinuous pointwise
limit](/real-analysis/function-sequences/pointwise-uniform-convergence), are one
witness; a simpler one uses straight lines.

> **Worked example (A tent collapsing to a jump).** On $[0, 1]$ define
> $$
> f_n(x) = \begin{cases} 1 - nx & \text{if } x < 1/n, \\ 0 & \text{if } x \ge 1/n. \end{cases}
> $$
> Each $f_n$ is continuous. Fix $x \in (0, 1]$; once $n \ge 1/x$ we have
> $x \ge 1/n$ and $f_n(x) = 0$, so $\lim_n f_n(x) = 0$. At $x = 0$, $f_n(0) = 1$
> for all $n$. The pointwise limit is $1$ at $0$ and $0$ elsewhere, discontinuous
> at the origin. The ramp steepens and narrows, its foot sliding toward $0$
> without ever lowering the value there.

$$
% caption: Each tent $f_n$ is continuous, but the peak at $0$ never descends
% while the ramp narrows, so the pointwise limit jumps at the origin.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-0.15,0) -- (5.4,0) node[anchor=north east] {$x$};
\draw[black, ->] (0,-0.15) -- (0,2.5) node[anchor=north east] {$y$};
\node[black, anchor=east, font=\scriptsize] at (0,2) {$1$};
% f_1: foot at x=2 (scaled), f_2 foot at 1, f_4 foot at 0.5
\draw[acc!55, thick] (0,2) -- (2.4,0) -- (5.2,0);
\node[acc!70, anchor=south west, font=\scriptsize] at (1.5,0.55) {$f_1$};
\draw[acc, thick] (0,2) -- (1.2,0) -- (5.2,0);
\node[acc, anchor=south west, font=\scriptsize] at (0.75,0.75) {$f_2$};
\draw[acc, very thick] (0,2) -- (0.6,0) -- (5.2,0);
\node[acc, anchor=south west, font=\scriptsize] at (0.32,1.1) {$f_4$};
\fill[black] (0,2) circle (1.8pt);
\node[black, anchor=west, font=\scriptsize] at (0.15,2.15) {limit value at $0$};
\end{tikzpicture}
$$

Uniform convergence rules this out. It keeps every $f_n$ inside a fixed band
around $f$, and continuity of the $f_n$ then carries over to $f$.

> **Theorem (Uniform limit of continuous functions).** Let $S \subset \mathbb{R}$
> and let $\{f_n\}$ be continuous functions $f_n : S \to \mathbb{R}$ converging
> uniformly to $f : S \to \mathbb{R}$. Then $f$ is continuous.

> **Proof.** Fix $x \in S$ and a sequence $x_m \to x$ in $S$; we show
> $f(x_m) \to f(x)$. Let $\epsilon > 0$. By uniform convergence choose $k$ with
> $|f_k(y) - f(y)| < \epsilon/3$ for all $y \in S$. Since $f_k$ is continuous at
> $x$, choose $N$ so that $|f_k(x_m) - f_k(x)| < \epsilon/3$ for $m \ge N$. Then
> for $m \ge N$,
> $$
> |f(x_m) - f(x)| \le |f(x_m) - f_k(x_m)| + |f_k(x_m) - f_k(x)| + |f_k(x) - f(x)| < \frac{\epsilon}{3} + \frac{\epsilon}{3} + \frac{\epsilon}{3} = \epsilon.
> $$
> Thus $f(x_m) \to f(x)$, and since $x$ was arbitrary, $f$ is continuous.
> $\;\square$

This is the **three-epsilons** argument: two of the thirds come from uniform
convergence (at $x_m$ and at $x$), and the middle third from the continuity of a
single well-chosen $f_k$. Uniformity is what lets one index $k$ serve at both
$x_m$ and $x$ simultaneously.

## Integral of the limit

The next swap is between the limit and the integral. Pointwise convergence fails
it, and can fail it badly: the limit of the integrals need not equal the integral
of the limit, and the limit function need not even be
[integrable](/real-analysis/riemann-integration/darboux-integral).

> **Worked example (The moving spike).** On $[0, 1]$ define
> $$
> f_n(x) = \begin{cases} n^2 x & \text{if } 0 \le x < 1/2n, \\ n - n^2\left(x - \tfrac{1}{2n}\right) & \text{if } 1/2n \le x < 1/n, \\ 0 & \text{if } x \ge 1/n, \end{cases}
> $$
> a triangular spike of height $n$ and base $1/n$, so
> $\int_0^1 f_n = \tfrac{1}{2}$ for every $n$. Yet for any fixed $x > 0$,
> $f_n(x) = 0$ once $n \ge 1/x$, and $f_n(0) = 0$, so the pointwise limit is the
> zero function. The integrals do not follow:
> $$
> \frac{1}{2} = \lim_{n \to \infty} \int_0^1 f_n(x)\,\d x \;\neq\; \int_0^1 \Big( \lim_{n \to \infty} f_n(x) \Big)\,\d x = \int_0^1 0\,\d x = 0.
> $$
> The area sits in a spike whose base shrinks toward $0$; every fixed $x$ is
> eventually outside the spike, so the pointwise limit is zero while each integral
> stays $\tfrac12$.

$$
% caption: The spike keeps unit-half area while its base shrinks toward $0$; at
% each fixed $x$ the height eventually leaves, so the pointwise limit is $0$ but
% every integral stays $\tfrac12$.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-0.15,0) -- (5.4,0) node[anchor=north east] {$x$};
\draw[black, ->] (0,-0.15) -- (0,2.9) node[anchor=north east] {$y$};
\fill[acc!14] (0,0) -- (2.0,1.1) -- (4.0,0) -- cycle;
\draw[acc!55, thick] (0,0) -- (2.0,1.1) -- (4.0,0);
\node[acc!70, anchor=south, font=\scriptsize] at (2.0,1.1) {$f_1$};
\fill[acc!14] (0,0) -- (1.0,1.7) -- (2.0,0) -- cycle;
\draw[acc, thick] (0,0) -- (1.0,1.7) -- (2.0,0);
\node[acc, anchor=south, font=\scriptsize] at (1.0,1.7) {$f_2$};
\fill[acc!14] (0,0) -- (0.5,2.5) -- (1.0,0) -- cycle;
\draw[acc, very thick] (0,0) -- (0.5,2.5) -- (1.0,0);
\node[acc, anchor=south, font=\scriptsize] at (0.5,2.5) {$f_4$};
\node[black, anchor=west, font=\scriptsize] at (2.9,1.9) {equal area,};
\node[black, anchor=west, font=\scriptsize] at (2.9,1.5) {sliding left};
\end{tikzpicture}
$$

Uniform convergence prevents this. The spike could stay uniformly
close to $0$ only by keeping a bounded height, and then its area would have to
shrink with its base.

> **Theorem (Interchange of limit and integral).** Let $\{f_n\}$ be Riemann
> integrable functions $f_n : [a, b] \to \mathbb{R}$ converging uniformly to
> $f : [a, b] \to \mathbb{R}$. Then $f$ is Riemann integrable and
> $$
> \int_a^b f = \lim_{n \to \infty} \int_a^b f_n.
> $$

> **Proof.** Let $\epsilon > 0$. Choose $M$ so that for $n \ge M$,
> $|f_n(x) - f(x)| < \dfrac{\epsilon}{2(b-a)}$ for all $x \in [a,b]$; then $f$ is
> bounded, being within a fixed distance of the bounded $f_n$. For integrability,
> the upper and lower integrals of $f$ satisfy
> $$
> \overline{\int_a^b} f - \underline{\int_a^b} f \le \int_a^b |f - f_n| + \left( \overline{\int_a^b} f_n - \underline{\int_a^b} f_n \right) \le \frac{\epsilon}{2(b-a)}\,(b-a) + 0 < \epsilon,
> $$
> using that $f_n$ is integrable so its own gap is $0$, and
> $|f(x) - f_n(x)| < \tfrac{\epsilon}{2(b-a)}$. As $\epsilon$ was arbitrary, $f$ is
> integrable. For the value, again with $n \ge M$,
> $$
> \left| \int_a^b f - \int_a^b f_n \right| \le \int_a^b |f - f_n| \le \frac{\epsilon}{2(b-a)}\,(b-a) = \frac{\epsilon}{2} < \epsilon,
> $$
> so $\int_a^b f_n \to \int_a^b f$. $\;\square$

The uniform bound $\|f - f_n\|_{[a,b]}$ multiplies against the fixed length
$b - a$ to control the whole integral at once. This is why the theorem needs a
bounded interval: on $[a, b]$ the factor $b - a$ is finite. Over an
[unbounded interval or improper
integral](/real-analysis/riemann-integration/log-exp-improper) uniform
convergence alone is not enough.[^lebl-improper]

> **Worked example (A computable limit of integrals).** The integral
> $\int_0^1 \sin(nx^2)\,\d x$ has no closed form for a fixed $n$, but
> $f_n(x) = \dfrac{nx + \sin(nx^2)}{n}$ converges uniformly to $x$ on $[0, 1]$, so
> $$
> \lim_{n \to \infty} \int_0^1 \frac{nx + \sin(nx^2)}{n}\,\d x = \int_0^1 x\,\d x = \frac{1}{2}.
> $$

## Derivative of the limit

Uniform convergence is enough to swap the limit with an integral, but not with a
derivative. Differentiation is the delicate operation, because a small uniform
change in a function can hide a large change in its slope.

> **Worked example (Uniform convergence, wild derivatives).** Let
> $f_n(x) = \dfrac{\sin(nx)}{n}$. Then $\|f_n\|_{\mathbb{R}} \le \tfrac{1}{n}$, so
> $f_n \to 0$ uniformly, and the derivative of the limit is $0$. But
> $f_n'(x) = \cos(nx)$, which does not converge even pointwise: $f_n'(0) = 1$ for
> all $n$, and $f_n'(\pi) = (-1)^n$ oscillates. The graphs are squeezed to zero
> height while their slopes stay order one.

$$
% caption: The curves $\sin(nx)/n$ are pressed toward $0$ uniformly, yet their
% slopes $\cos(nx)$ stay order one and never settle.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-0.15,0) -- (6,0) node[anchor=north east] {$x$};
\draw[black, ->] (0,-1.3) -- (0,1.4) node[anchor=north east] {$y$};
\draw[acc!45, thick] plot[domain=0:5.6, samples=120] (\x, {1.1*sin(deg(\x))});
\node[acc!60, anchor=south, font=\scriptsize] at (1.5,1.1) {$f_1$};
\draw[acc, very thick] plot[domain=0:5.6, samples=200] (\x, {0.28*sin(deg(4*\x))});
\node[acc, anchor=north east, font=\scriptsize] at (5.5,-0.35) {$f_4$};
\draw[black, dashed] (0,0) -- (5.6,0);
\node[black, anchor=west, font=\scriptsize] at (3.6,0.95) {slopes stay $\approx 1$};
\end{tikzpicture}
$$

To address this, require the derivatives themselves to converge uniformly. Then
the fundamental theorem of calculus, applied to the derivatives, transfers their
uniform convergence back up to the functions.

> **Theorem (Interchange of limit and derivative).** Let $I$ be a bounded
> interval and let $f_n : I \to \mathbb{R}$ be continuously differentiable.
> Suppose $\{f_n'\}$ converges uniformly to $g$ on $I$, and $\{f_n(c)\}$ converges
> for some $c \in I$. Then $\{f_n\}$ converges uniformly to a continuously
> differentiable $f$ with $f' = g$.

> **Proof.** Since each $f_n'$ is continuous hence integrable, the
> [fundamental theorem](/real-analysis/riemann-integration/fundamental-theorem)
> gives $f_n(x) = f_n(c) + \int_c^x f_n'$ for $x \in I$. The right side has a
> limit: $f_n(c) \to \ell$ by hypothesis, and $\int_c^x f_n' \to \int_c^x g$ by
> the integral interchange, since $f_n' \to g$ uniformly on $[c,x]$. Define
> $$
> f(x) = \ell + \int_c^x g.
> $$
> The function $g$ is continuous, being a uniform limit of continuous functions,
> so by the fundamental theorem $f$ is differentiable with $f' = g$. Uniform
> convergence of $f_n$ to $f$ follows from bounding
> $|f(x) - f_n(x)| \le |\ell - f_n(c)| + \int_c^x |g - f_n'|$ by
> $\epsilon/2 + \tfrac{\epsilon}{2(b-a)}(b-a) = \epsilon$ on $I = [a,b]$.
> $\;\square$

The anchor value $\{f_n(c)\}$ is not optional. Uniform convergence of the
derivatives determines $f$ only up to a constant, and $f_n(c) \to \ell$ supplies
that constant. Without it, $f_n(x) = x/n$ has $f_n' = 1/n \to 0$ uniformly while
$f_n \to 0$ merely pointwise.

## Summary of hypotheses

| Interchange | Sufficient hypothesis | Fails under pointwise |
| --- | --- | --- |
| $\lim$ with continuity | $f_n \to f$ uniformly | tent $\to$ jump at $0$ |
| $\lim$ with $\int$ | $f_n \to f$ uniformly, on $[a,b]$ | moving spike, area $\tfrac12 \neq 0$ |
| $\lim$ with $\dfrac{\d}{\d x}$ | $f_n' \to g$ uniformly, $\{f_n(c)\}$ converges | $\sin(nx)/n \to 0$, $f_n' = \cos(nx)$ |

The pattern is that uniform convergence of the object being differentiated or
integrated is what counts. For an integral, that object is $f_n$ itself; for a
derivative, it is $f_n'$. All three swaps apply at once to
[power series](/real-analysis/function-sequences/power-series-weierstrass), which
converge uniformly on closed subintervals together with all their derivatives, so
they may be integrated and differentiated term by term.

[^lebl-open]: Lebl, §6.2. The iterated-limit example $\tfrac{n}{n+k}$ shows that even for numbers the order of two limits matters; sequences of functions are the setting where the interchange arises constantly.
[^lebl-improper]: Lebl, §6.2, footnote to Theorem 6.2.4. Weaker hypotheses than uniform convergence suffice — pointwise convergence with a uniform bound $\|f_n\|_{[a,b]} \le M$ and $f$ integrable — but the proof needs the Lebesgue integral, beyond this course. Over infinite intervals uniform convergence can still fail to pass the limit through the integral.
