Skip to content
The Lumenary
Advanced undergraduateUndergraduate 120 min

Real analysis

Calculus works — but why? One axiom about the real line, the completeness of R\R, proves the theorems calculus quietly relies on, and explains exactly when limits may be swapped.

Formally verified · 22 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review
MotivationH

When calculus goes wrong

Here is a famous series:

1−12+13−14+15−16+⋯=ln⁡2≈0.693.1 - \tfrac12 + \tfrac13 - \tfrac14 + \tfrac15 - \tfrac16 + \cdots = \ln 2 \approx 0.693.

Now add up exactly the same numbers in a different order — two positive terms, then one negative:

1+13−12+15+17−14+19+111−16+⋯=32ln⁡2≈1.040.1 + \tfrac13 - \tfrac12 + \tfrac15 + \tfrac17 - \tfrac14 + \tfrac19 + \tfrac1{11} - \tfrac16 + \cdots = \tfrac32 \ln 2 \approx 1.040.

Same terms, different sum. Riemann proved in 1854 that a series like this one, which converges but not absolutely, can be rearranged to add up to any real number you like. Addition of infinitely many numbers is not addition.

The history of calculus is full of such surprises. In his Cours d'analyse of 1821, Augustin-Louis Cauchy "proved" that a convergent series of continuous functions has a continuous sum. Five years later Niels Henrik Abel pointed out that the Fourier series

sin⁡x−12sin⁡2x+13sin⁡3x−⋯\sin x - \tfrac12 \sin 2x + \tfrac13 \sin 3x - \cdots

converges for every xx to a function that jumps at x=πx = \pi. In 1872 Karl Weierstrass presented a continuous function that has a tangent line nowhere — at a time when many mathematicians believed a continuous function must be differentiable at most points.

Real analysis is the response: precise definitions of limit, continuity, convergence and integral, and proofs of everything calculus uses. All of it rests on one property of the real numbers, completeness: the real line has no holes. In this lesson you will prove, from that single axiom, the intermediate value theorem, the extreme value theorem, the Bolzano–Weierstrass theorem and the fundamental theorem of calculus, and you will learn exactly when two limiting processes can be swapped.

IntuitionH

No holes, and one N for everyone

The rational numbers are full of holes. The decimal approximations 1,1.4,1.41,1.414,1.4142,…1, 1.4, 1.41, 1.414, 1.4142, \dots to 2\sqrt 2 get closer and closer to each other, but in Q\Q there is nothing for them to converge to. The set {x∈Q:x2<2}\{x \in \Q : x^2 < 2\} is bounded above but has no least upper bound in Q\Q. Completeness says that in R\R this never happens: every sequence that "ought to converge" does, and every bounded set has a sharpest bound. Each of the great theorems of this lesson fails over Q\Q. The function f(x)=x2−2f(x) = x^2 - 2 on [0,2]∩Q[0, 2] \cap \Q changes sign without ever being 00.

The second big idea is about the order of quantifiers. A sequence of functions fnf_n converges to ff pointwise on SS if for each x∈Sx \in S the numbers fn(x)f_n(x) converge to f(x)f(x). It converges uniformly if one threshold NN works for all xx at once: once n≥Nn \ge N, the whole graph of fnf_n lies inside a tube of width ε\varepsilon around the graph of ff.

2εf (dashed), fₙ (solid)
Uniform convergence: for $n \ge N$ the whole graph of $f_n$ (solid) lies in the tube of half-width $\varepsilon$ around the limit $f$ (dashed). Pointwise convergence only asks each vertical line to be eventually inside the tube — at its own pace.

The difference matters because limits are delicate. The continuous functions xnx^n on [0,1][0, 1] converge pointwise to a function that is 00 on [0,1)[0, 1) and jumps to 11 at x=1x = 1. The threshold NN that makes xn<εx^n < \varepsilon gets larger and larger as xx approaches 11, and no single NN works. Uniform convergence is precisely the hypothesis that rescues continuity, integrals and (with care) derivatives.

DefinitionsH

Definitions

Throughout, ∣x−y∣|x - y| is the distance between real numbers. We take R\R to be an ordered field (the familiar rules of arithmetic and inequalities) with one extra axiom.

Definition— supremum and the completeness axiom

An upper bound of S⊆RS \subseteq \R is a number uu with x≤ux \le u for all x∈Sx \in S. A supremum (least upper bound) of SS is an upper bound ss such that s≤us \le u for every upper bound uu; we write s=sup⁡Ss = \sup S. The completeness axiom: every non-empty subset of R\R that is bounded above has a supremum.

The supremum is characterised by an approximation property: an upper bound ss of SS is sup⁡S\sup S if and only if for every ε>0\varepsilon > 0 there is x∈Sx \in S with x>s−εx > s - \varepsilon. (Otherwise s−εs - \varepsilon would be a smaller upper bound.) Completeness implies the Archimedean property: N\N is not bounded above in R\R. Indeed, if s=sup⁡Ns = \sup \N existed, some n>s−1n > s - 1 would give n+1>sn + 1 > s. Hence 1/n→01/n \to 0.

Definition— convergence and Cauchy sequences

A sequence (an)(a_n) converges to LL, written an→La_n \to L, if for every ε>0\varepsilon > 0 there is NN such that ∣an−L∣<ε|a_n - L| < \varepsilon for all n≥Nn \ge N. It is a Cauchy sequence if for every ε>0\varepsilon > 0 there is NN such that ∣am−an∣<ε|a_m - a_n| < \varepsilon for all m,n≥Nm, n \ge N. A subsequence of (an)(a_n) is a sequence (aφ(k))k(a_{\varphi(k)})_k with φ:N→N\varphi : \N \to \N strictly increasing.

Definition— continuity and uniform continuity

Let f:S→Rf : S \to \R with S⊆RS \subseteq \R. ff is continuous at c∈Sc \in S if for every ε>0\varepsilon > 0 there is δ>0\delta > 0 such that ∣f(x)−f(c)∣<ε|f(x) - f(c)| < \varepsilon for all x∈Sx \in S with ∣x−c∣<δ|x - c| < \delta; it is continuous if it is continuous at every point of SS. It is uniformly continuous if for every ε>0\varepsilon > 0 there is a δ>0\delta > 0 that works at every point: ∣f(x)−f(y)∣<ε|f(x) - f(y)| < \varepsilon whenever x,y∈Sx, y \in S and ∣x−y∣<δ|x - y| < \delta.

Definition— pointwise and uniform convergence

Let fn,f:S→Rf_n, f : S \to \R. The sequence (fn)(f_n) converges to ff pointwise on SS if fn(x)→f(x)f_n(x) \to f(x) for each x∈Sx \in S: ∀x∈S ∀ε>0 ∃N ∀n≥N:∣fn(x)−f(x)∣<ε\forall x \in S\ \forall \varepsilon > 0\ \exists N\ \forall n \ge N : |f_n(x) - f(x)| < \varepsilon. It converges uniformly on SS if ∀ε>0 ∃N ∀n≥N ∀x∈S:∣fn(x)−f(x)∣<ε\forall \varepsilon > 0\ \exists N\ \forall n \ge N\ \forall x \in S : |f_n(x) - f(x)| < \varepsilon, equivalently if sup⁡x∈S∣fn(x)−f(x)∣→0\sup_{x \in S} |f_n(x) - f(x)| \to 0.

The only difference is where "∀x\forall x" stands. In the uniform definition NN is chosen before xx, so it cannot depend on xx.

Definition— Riemann integral (Darboux's formulation)

Let f:[a,b]→Rf : [a, b] \to \R be bounded. A partition PP of [a,b][a, b] is a finite list a=x0<x1<⋯<xn=ba = x_0 < x_1 < \dots < x_n = b. With Mi=sup⁡[xi−1,xi]fM_i = \sup_{[x_{i-1}, x_i]} f and mi=inf⁡[xi−1,xi]fm_i = \inf_{[x_{i-1}, x_i]} f, the upper and lower sums are

U(f,P)=∑i=1nMi (xi−xi−1),L(f,P)=∑i=1nmi (xi−xi−1).U(f, P) = \sum_{i=1}^n M_i\,(x_i - x_{i-1}), \qquad L(f, P) = \sum_{i=1}^n m_i\,(x_i - x_{i-1}).

ff is Riemann integrable if inf⁡PU(f,P)=sup⁡PL(f,P)\inf_P U(f, P) = \sup_P L(f, P); this common value is ∫abf\int_a^b f.

Adding points to a partition (a refinement) can only lower upper sums and raise lower sums. Comparing any two partitions with their common refinement shows that every lower sum is at most every upper sum. Consequently ff is integrable if and only if for every ε>0\varepsilon > 0 there is a partition with U(f,P)−L(f,P)<εU(f, P) - L(f, P) < \varepsilon (Riemann's criterion).

Worked examplesH

Examples, non-examples and warnings

Example— Limits, and how to prove them

  • an=nn+1→1a_n = \frac{n}{n+1} \to 1: ∣an−1∣=1n+1<ε|a_n - 1| = \frac{1}{n+1} < \varepsilon as soon as n>1/εn > 1/\varepsilon, which happens for large nn by the Archimedean property.
  • an=(−1)na_n = (-1)^n does not converge: any limit LL would satisfy ∣1−L∣<12|1 - L| < \tfrac12 and ∣−1−L∣<12|-1 - L| < \tfrac12, so 2=∣1−(−1)∣<12 = |1 - (-1)| < 1. But it has convergent subsequences (a2k→1a_{2k} \to 1, a2k+1→−1a_{2k+1} \to -1), as Bolzano–Weierstrass promises for a bounded sequence.
  • an=(1+1/n)na_n = (1 + 1/n)^n is increasing and bounded above by 33, so it converges by the monotone convergence theorem below. Its limit is called ee.

Example— A Cauchy sequence of rationals with no rational limit

Define q1=1q_1 = 1 and qn+1=qn2+1qnq_{n+1} = \frac{q_n}{2} + \frac{1}{q_n} (Newton's method for x2=2x^2 = 2). Every qnq_n is rational, qn→2q_n \to \sqrt 2 in R\R, and so (qn)(q_n) is Cauchy. In Q\Q it has no limit: if qn→Lq_n \to L in Q\Q then L=L2+1LL = \frac L2 + \frac1L, so L2=2L^2 = 2, which has no rational solution. Being Cauchy is about the sequence; converging is about the space it lives in.

Example— Pointwise but not uniform

  • fn(x)=xnf_n(x) = x^n on [0,1][0, 1]: the pointwise limit is f(x)=0f(x) = 0 for x<1x < 1, f(1)=1f(1) = 1. Convergence is uniform on [0,r][0, r] for each r<1r < 1 (the supremum of ∣fn∣|f_n| there is rn→0r^n \to 0) but not on [0,1)[0, 1), where the supremum is 11 for every nn.
  • gn(x)=nx1+n2x2g_n(x) = \dfrac{nx}{1 + n^2x^2} converges pointwise to 00 on R\R, and every gng_n and the limit are continuous. Yet gn(1/n)=12g_n(1/n) = \tfrac12, so the convergence is not uniform. Continuity of the limit does not imply uniform convergence.
  • hn(x)=2n2xe−n2x2h_n(x) = 2n^2 x e^{-n^2x^2} converges to 00 at every x∈[0,1]x \in [0, 1], but ∫01hn=1−e−n2→1\int_0^1 h_n = 1 - e^{-n^2} \to 1. The mass concentrates into a spike near 00, and limit and integral cannot be swapped.

Example— Functions that are and are not Riemann integrable

  • Dirichlet's function 1Q\mathbf 1_\Q (11 on rationals, 00 on irrationals) is not integrable on [0,1][0, 1]: every interval of positive length contains rationals and irrationals, so on every partition U=1U = 1 and L=0L = 0.
  • Thomae's function (f(p/q)=1/qf(p/q) = 1/q in lowest terms, f=0f = 0 at irrationals) is discontinuous at every rational and continuous at every irrational, yet it is integrable with integral 00: for ε>0\varepsilon > 0 only finitely many points have f≥εf \ge \varepsilon, and they can be enclosed in subintervals of tiny total length.
  • Every monotone function on [a,b][a, b] is integrable. With nn equal pieces the sum U−LU - L telescopes to (f(b)−f(a))(b−a)/n\big(f(b) - f(a)\big)(b - a)/n.
ProofH

Completeness: three theorems about sequences

Theorem— Theorem 1 (monotone convergence)

An increasing sequence that is bounded above converges, to sup⁡nan\sup_n a_n. (Likewise a decreasing sequence bounded below converges to its infimum.)

Proof

Let s=sup⁡{an:n∈N}s = \sup\{a_n : n \in \N\}, which exists by completeness. Given ε>0\varepsilon > 0, the approximation property gives NN with aN>s−εa_N > s - \varepsilon. For n≥Nn \ge N, monotonicity gives s−ε<aN≤an≤ss - \varepsilon < a_N \le a_n \le s, so ∣an−s∣<ε|a_n - s| < \varepsilon.

∎

Theorem— Lemma 2 (every sequence has a monotone subsequence)

Every real sequence has a subsequence that is increasing or decreasing.

Proof

Call an index mm a peak if am≥ana_m \ge a_n for every n>mn > m — from ama_m you can see to the horizon. If there are infinitely many peaks m1<m2<⋯m_1 < m_2 < \cdots, then am1≥am2≥⋯a_{m_1} \ge a_{m_2} \ge \cdots is a decreasing subsequence. Otherwise let n1n_1 be larger than every peak. As n1n_1 is not a peak, some n2>n1n_2 > n_1 has an2>an1a_{n_2} > a_{n_1}; as n2n_2 is not a peak, some n3>n2n_3 > n_2 has an3>an2a_{n_3} > a_{n_2}; and so on. This gives an increasing subsequence.

∎

Theorem— Theorem 3 (Bolzano–Weierstrass)

Every bounded sequence of real numbers has a convergent subsequence.

Proof

By Lemma 2 it has a monotone subsequence, which is bounded and hence converges by Theorem 1.

∎

Theorem— Theorem 4 (Cauchy criterion)

A sequence of real numbers converges if and only if it is a Cauchy sequence.

Proof

(⇒\Rightarrow) If an→La_n \to L, choose NN with ∣an−L∣<ε/2|a_n - L| < \varepsilon/2 for n≥Nn \ge N. Then for m,n≥Nm, n \ge N: ∣am−an∣≤∣am−L∣+∣L−an∣<ε|a_m - a_n| \le |a_m - L| + |L - a_n| < \varepsilon.

(⇐\Leftarrow) Let (an)(a_n) be Cauchy. It is bounded: with ε=1\varepsilon = 1 there is NN such that ∣an−aN∣<1|a_n - a_N| < 1 for n≥Nn \ge N, so ∣an∣≤max⁡(∣a0∣,…,∣aN−1∣,∣aN∣+1)|a_n| \le \max(|a_0|, \dots, |a_{N-1}|, |a_N| + 1) for all nn. By Bolzano–Weierstrass some subsequence aφ(k)→La_{\varphi(k)} \to L. The whole sequence converges to LL: given ε\varepsilon, choose NN with ∣am−an∣<ε/2|a_m - a_n| < \varepsilon/2 for m,n≥Nm, n \ge N, and KK with ∣aφ(k)−L∣<ε/2|a_{\varphi(k)} - L| < \varepsilon/2 for k≥Kk \ge K. For n≥Nn \ge N take k=max⁡(K,n)k = \max(K, n). Since φ(k)≥k≥n≥N\varphi(k) \ge k \ge n \ge N,

∣an−L∣≤∣an−aφ(k)∣+∣aφ(k)−L∣<ε2+ε2=ε.■|a_n - L| \le |a_n - a_{\varphi(k)}| + |a_{\varphi(k)} - L| < \tfrac\varepsilon2 + \tfrac\varepsilon2 = \varepsilon. \qquad \blacksquare

∎

Note

For an ordered field, the following are equivalent: the supremum property; the monotone convergence theorem; the Bolzano–Weierstrass theorem; "Cauchy sequences converge" together with the Archimedean property; the nested interval property together with the Archimedean property. Each fails in Q\Q. Up to a unique isomorphism, R\R is the only ordered field with these properties — see constructing ℤ, ℚ and ℝ for its construction by Dedekind cuts or Cauchy sequences.

ProofH

Continuous functions on a closed interval

We first record the link between ε–δ continuity and sequences. If ff is continuous at cc and xn→cx_n \to c (with xnx_n in the domain), then f(xn)→f(c)f(x_n) \to f(c). Given ε\varepsilon, take the δ\delta of continuity, then NN with ∣xn−c∣<δ|x_n - c| < \delta for n≥Nn \ge N; then ∣f(xn)−f(c)∣<ε|f(x_n) - f(c)| < \varepsilon for n≥Nn \ge N. Also, limits of sequences in [a,b][a, b] stay in [a,b][a, b]: if xn→xx_n \to x and x>bx > b, then eventually ∣xn−x∣<x−b|x_n - x| < x - b, forcing xn>bx_n > b.

Theorem— Theorem 5 (intermediate value theorem)

If f:[a,b]→Rf : [a, b] \to \R is continuous and f(a)≤0≤f(b)f(a) \le 0 \le f(b), then f(c)=0f(c) = 0 for some c∈[a,b]c \in [a, b]. Consequently a continuous function on [a,b][a, b] takes every value between f(a)f(a) and f(b)f(b).

Proof

Let S={x∈[a,b]:f(x)≤0}S = \{x \in [a, b] : f(x) \le 0\}. It contains aa and is bounded above by bb, so c=sup⁡Sc = \sup S exists, and a≤c≤ba \le c \le b. We show that f(c)f(c) is neither positive nor negative.

Suppose f(c)>0f(c) > 0. By continuity (with ε=f(c)\varepsilon = f(c)) there is δ>0\delta > 0 with f(x)>0f(x) > 0 for all x∈[a,b]x \in [a, b] with ∣x−c∣<δ|x - c| < \delta. By the approximation property some s∈Ss \in S satisfies c−δ<s≤cc - \delta < s \le c. Then ∣s−c∣<δ|s - c| < \delta, so f(s)>0f(s) > 0, contradicting s∈Ss \in S.

Suppose f(c)<0f(c) < 0. Then c≠bc \ne b (as f(b)≥0f(b) \ge 0), so c<bc < b. By continuity there is δ>0\delta > 0 with f(x)<0f(x) < 0 whenever x∈[a,b]x \in [a, b] and ∣x−c∣<δ|x - c| < \delta. The point x=min⁡(c+δ/2,b)x = \min(c + \delta/2, b) lies in [a,b][a, b], satisfies c<xc < x and ∣x−c∣<δ|x - c| < \delta, so f(x)<0f(x) < 0 and x∈Sx \in S. But x>c=sup⁡Sx > c = \sup S, a contradiction.

Hence f(c)=0f(c) = 0. For the general statement apply this to f−yf - y or y−fy - f.

∎

Theorem— Theorem 6 (extreme value theorem)

A continuous function f:[a,b]→Rf : [a, b] \to \R is bounded and attains its maximum and its minimum.

Proof

Bounded: otherwise for each nn there is xn∈[a,b]x_n \in [a, b] with ∣f(xn)∣>n|f(x_n)| > n. By Bolzano–Weierstrass a subsequence xφ(k)x_{\varphi(k)} converges to some x∈[a,b]x \in [a, b], and by continuity f(xφ(k))→f(x)f(x_{\varphi(k)}) \to f(x). A convergent sequence is bounded, but ∣f(xφ(k))∣>φ(k)≥k|f(x_{\varphi(k)})| > \varphi(k) \ge k. Contradiction.

Attains its maximum: let M=sup⁡f([a,b])M = \sup f([a, b]), finite by the first part. For each nn choose xnx_n with f(xn)>M−1/nf(x_n) > M - 1/n. A subsequence converges to some c∈[a,b]c \in [a, b], and f(c)=lim⁡f(xφ(k))f(c) = \lim f(x_{\varphi(k)}). Since M−1/φ(k)<f(xφ(k))≤MM - 1/\varphi(k) < f(x_{\varphi(k)}) \le M, this limit is MM. Apply the same to −f-f for the minimum.

∎

Both hypotheses matter. On (0,1](0, 1] the continuous function 1/x1/x is unbounded, on [0,∞)[0, \infty) the function xx is unbounded, and on (−1,1)(-1, 1) the function xx is bounded but has no maximum. On the closed interval [0,1][0, 1], the discontinuous function equal to xx for x<1x < 1 and to 00 at x=1x = 1 is bounded, with supremum 11, but never reaches it. What the proofs used about [a,b][a, b] is that every sequence in it has a subsequence converging in it — sequential compactness. In the language of point-set topology, the intermediate value theorem is about connectedness and the extreme value theorem about compactness.

Theorem— Theorem 7 (Heine–Cantor: uniform continuity)

A continuous function f:[a,b]→Rf : [a, b] \to \R is uniformly continuous.

Proof

If not, there is ε>0\varepsilon > 0 such that for each nn some xn,yn∈[a,b]x_n, y_n \in [a, b] satisfy ∣xn−yn∣<1/n|x_n - y_n| < 1/n but ∣f(xn)−f(yn)∣≥ε|f(x_n) - f(y_n)| \ge \varepsilon. By Bolzano–Weierstrass a subsequence xφ(k)x_{\varphi(k)} converges to some c∈[a,b]c \in [a, b]; then yφ(k)→cy_{\varphi(k)} \to c too, since ∣yφ(k)−xφ(k)∣<1/φ(k)|y_{\varphi(k)} - x_{\varphi(k)}| < 1/\varphi(k). By continuity at cc, f(xφ(k))−f(yφ(k))→f(c)−f(c)=0f(x_{\varphi(k)}) - f(y_{\varphi(k)}) \to f(c) - f(c) = 0, contradicting ∣f(xφ(k))−f(yφ(k))∣≥ε|f(x_{\varphi(k)}) - f(y_{\varphi(k)})| \ge \varepsilon.

∎

On (0,1](0, 1] the function 1/x1/x is continuous but not uniformly continuous: x=1/nx = 1/n and y=1/(n+1)y = 1/(n+1) are very close, yet ∣f(x)−f(y)∣=1|f(x) - f(y)| = 1.

ProofH

Uniform convergence and swapping limits

Theorem— Theorem 8 (uniform limit theorem)

If fn→ff_n \to f uniformly on SS and every fnf_n is continuous at c∈Sc \in S, then ff is continuous at cc. In particular, a uniform limit of continuous functions is continuous.

Proof

Let ε>0\varepsilon > 0. Choose NN with ∣fN(x)−f(x)∣<ε/3|f_N(x) - f(x)| < \varepsilon/3 for all x∈Sx \in S — here uniformity is used. Since fNf_N is continuous at cc, there is δ>0\delta > 0 with ∣fN(x)−fN(c)∣<ε/3|f_N(x) - f_N(c)| < \varepsilon/3 for x∈Sx \in S, ∣x−c∣<δ|x - c| < \delta. For such xx,

∣f(x)−f(c)∣≤∣f(x)−fN(x)∣+∣fN(x)−fN(c)∣+∣fN(c)−f(c)∣<ε3+ε3+ε3=ε.■|f(x) - f(c)| \le |f(x) - f_N(x)| + |f_N(x) - f_N(c)| + |f_N(c) - f(c)| < \tfrac\varepsilon3 + \tfrac\varepsilon3 + \tfrac\varepsilon3 = \varepsilon. \qquad \blacksquare

∎

Where does the argument break for pointwise convergence? The first step would choose NN depending on xx, and then δ\delta (chosen for fNf_N) depends on xx, which is circular. The example xnx^n shows the theorem genuinely fails, and Theorem 8 gives a quick proof that xn→0x^n \to 0 is not uniform on [0,1][0, 1]: the limit is discontinuous.

Theorem— Theorem 9 (integrals of uniform limits)

If fn→ff_n \to f uniformly on [a,b][a, b] and each fnf_n is Riemann integrable, then ff is Riemann integrable and ∫abfn→∫abf\int_a^b f_n \to \int_a^b f.

Proof

Let εn=sup⁡[a,b]∣fn−f∣→0\varepsilon_n = \sup_{[a, b]} |f_n - f| \to 0. On every subinterval, fn−εn≤f≤fn+εnf_n - \varepsilon_n \le f \le f_n + \varepsilon_n, so for every partition PP

U(f,P)−L(f,P)≤U(fn,P)−L(fn,P)+2εn(b−a).U(f, P) - L(f, P) \le U(f_n, P) - L(f_n, P) + 2\varepsilon_n (b - a).

Given ε\varepsilon, fix nn with 2εn(b−a)<ε/22\varepsilon_n (b - a) < \varepsilon/2, then PP with U(fn,P)−L(fn,P)<ε/2U(f_n, P) - L(f_n, P) < \varepsilon/2: Riemann's criterion shows ff is integrable. Finally ∣∫abfn−∫abf∣≤∫ab∣fn−f∣≤εn(b−a)→0\left|\int_a^b f_n - \int_a^b f\right| \le \int_a^b |f_n - f| \le \varepsilon_n (b - a) \to 0.

∎

For series this becomes the most useful test in analysis.

Theorem— Theorem 10 (Weierstrass M-test)

If ∣uk(x)∣≤Mk|u_k(x)| \le M_k for all x∈Sx \in S and ∑kMk<∞\sum_k M_k < \infty, then ∑kuk\sum_k u_k converges uniformly on SS. If moreover every uku_k is continuous, so is the sum.

Proof

Let sn(x)=∑k≤nuk(x)s_n(x) = \sum_{k \le n} u_k(x). For m>nm > n, ∣sm(x)−sn(x)∣≤∑k=n+1mMk|s_m(x) - s_n(x)| \le \sum_{k = n+1}^m M_k, which is small for large nn independently of xx. So each (sn(x))(s_n(x)) is Cauchy and converges (Theorem 4) to some s(x)s(x). Letting m→∞m \to \infty gives ∣s(x)−sn(x)∣≤∑k>nMk|s(x) - s_n(x)| \le \sum_{k > n} M_k for all xx, which tends to 00: the convergence is uniform. Continuity follows from Theorem 8.

∎

Derivatives are the most delicate. The functions sin⁡(nx)/n\sin(nx)/n converge uniformly to 00 (the supremum is 1/n1/n), but their derivatives cos⁡(nx)\cos(nx) do not converge at all — at x=πx = \pi they alternate between ±1\pm 1. Uniform convergence of the derivatives is what is needed.

Theorem— Theorem 11 (derivatives of limits)

Let fn:[a,b]→Rf_n : [a, b] \to \R be continuously differentiable, suppose fn′→gf_n' \to g uniformly on [a,b][a, b] and fn(x0)f_n(x_0) converges for some x0∈[a,b]x_0 \in [a, b]. Then fnf_n converges uniformly to a differentiable function ff with f′=gf' = g.

Proof

By Theorem 8, gg is continuous. By the fundamental theorem of calculus (Theorem 15 below), fn(x)=fn(x0)+∫x0xfn′f_n(x) = f_n(x_0) + \int_{x_0}^x f_n'. By Theorem 9 the right-hand side converges, uniformly in xx (the error is at most ∣fn(x0)−L∣+(b−a)sup⁡∣fn′−g∣|f_n(x_0) - L| + (b - a)\sup|f_n' - g|), to f(x):=L+∫x0xgf(x) := L + \int_{x_0}^x g, where L=lim⁡fn(x0)L = \lim f_n(x_0). By Theorem 14 below, f′=gf' = g.

∎

Without some such hypothesis, anything can happen.

Theorem— Theorem 12 (Weierstrass's function is not differentiable at 0)

Let W(x)=∑k≥0akcos⁡(bkπx)W(x) = \sum_{k \ge 0} a^k \cos(b^k \pi x) with a=12a = \tfrac12 and b=13b = 13. Then WW is continuous on R\R but not differentiable at 00.

Proof

Continuity: the M-test with Mk=akM_k = a^k. Now put hm=b−mh_m = b^{-m}. For k≥mk \ge m, bkhm=13k−mb^k h_m = 13^{k - m} is an odd integer, so cos⁡(bkπhm)=−1\cos(b^k \pi h_m) = -1. Since W(0)=∑ak=11−aW(0) = \sum a^k = \frac{1}{1-a},

W(hm)−W(0)hm=bm∑k<mak(cos⁡(πbk−m)−1)  −  2 (ab)m1−a.\frac{W(h_m) - W(0)}{h_m} = b^m \sum_{k < m} a^k \big(\cos(\pi b^{k - m}) - 1\big) \;-\; \frac{2\,(ab)^m}{1 - a}.

Using 0≤1−cos⁡t≤t2/20 \le 1 - \cos t \le t^2/2, the first term has absolute value at most π22∑k<makb2k−m=π22(ab)m∑j=1m(ab2)−j≤π2(ab)m2(ab2−1)\frac{\pi^2}{2} \sum_{k < m} a^k b^{2k - m} = \frac{\pi^2}{2} (ab)^m \sum_{j = 1}^m (ab^2)^{-j} \le \frac{\pi^2 (ab)^m}{2(ab^2 - 1)}. Hence

∣W(hm)−W(0)hm∣≥(ab)m(21−a−π22(ab2−1))=6.5m (4−0.059…)→∞.\left| \frac{W(h_m) - W(0)}{h_m} \right| \ge (ab)^m \left( \frac{2}{1 - a} - \frac{\pi^2}{2(ab^2 - 1)} \right) = 6.5^m \,(4 - 0.059\ldots) \to \infty.

If W′(0)W'(0) existed, these difference quotients would converge to it.

∎

The same function has no derivative at any point. Theorem (Weierstrass, 1872; stated, not proved here). If 0<a<10 < a < 1, bb is an odd integer and ab>1+3π2ab > 1 + \frac{3\pi}{2}, then WW is continuous and nowhere differentiable. G. H. Hardy (1916) showed that ab≥1ab \ge 1 suffices. A proof of a closely related example is in Stein and Shakarchi, Fourier Analysis (2003), chapter 4. Every partial sum of WW is infinitely differentiable; the limit is differentiable nowhere. The derivatives of the partial sums, of size about (ab)k(ab)^k, are as far from converging uniformly as possible.

ProofH

The Riemann integral and the fundamental theorem

Theorem— Theorem 13 (continuous functions are integrable)

Every continuous f:[a,b]→Rf : [a, b] \to \R is Riemann integrable. The indicator function 1Q\mathbf 1_\Q of the rationals is not.

Proof

Let ε>0\varepsilon > 0. By Heine–Cantor there is δ>0\delta > 0 with ∣f(s)−f(t)∣<ε/(b−a)|f(s) - f(t)| < \varepsilon/(b - a) whenever ∣s−t∣<δ|s - t| < \delta. Take a partition with all xi−xi−1<δx_i - x_{i-1} < \delta. On each piece, the extreme value theorem gives Mi=f(s)M_i = f(s) and mi=f(t)m_i = f(t) with ∣s−t∣<δ|s - t| < \delta, so Mi−mi<ε/(b−a)M_i - m_i < \varepsilon/(b - a), and

U(f,P)−L(f,P)=∑i(Mi−mi)(xi−xi−1)<εb−a∑i(xi−xi−1)=ε.U(f, P) - L(f, P) = \sum_i (M_i - m_i)(x_i - x_{i-1}) < \frac{\varepsilon}{b - a} \sum_i (x_i - x_{i-1}) = \varepsilon.

For 1Q\mathbf 1_\Q: every piece [xi−1,xi][x_{i-1}, x_i] of positive length contains a rational and an irrational, so Mi=1M_i = 1 and mi=0m_i = 0; every upper sum is b−ab - a and every lower sum is 00.

∎

We use three elementary properties of the integral, all proved directly from the definition: it is linear; it is additive over adjacent intervals, ∫acf=∫abf+∫bcf\int_a^c f = \int_a^b f + \int_b^c f (with the convention ∫ba=−∫ab\int_b^a = -\int_a^b); and ∣∫abg∣≤(b−a)sup⁡[a,b]∣g∣\left|\int_a^b g\right| \le (b - a) \sup_{[a, b]} |g|.

Theorem— Theorem 14 (fundamental theorem of calculus, part 1)

Let ff be Riemann integrable on [a,b][a, b] and F(x)=∫axfF(x) = \int_a^x f. If ff is continuous at x0∈(a,b)x_0 \in (a, b), then FF is differentiable at x0x_0 and F′(x0)=f(x0)F'(x_0) = f(x_0).

Proof

Let ε>0\varepsilon > 0 and choose δ>0\delta > 0 such that ∣f(t)−f(x0)∣<ε|f(t) - f(x_0)| < \varepsilon whenever ∣t−x0∣<δ|t - x_0| < \delta. For 0<∣h∣<δ0 < |h| < \delta (with x0+h∈[a,b]x_0 + h \in [a, b]),

F(x0+h)−F(x0)−hf(x0)=∫x0x0+h(f(t)−f(x0)) dt,F(x_0 + h) - F(x_0) - h f(x_0) = \int_{x_0}^{x_0 + h} \big(f(t) - f(x_0)\big)\,dt,

whose absolute value is at most ∣h∣⋅ε|h| \cdot \varepsilon. Dividing by ∣h∣|h|: ∣F(x0+h)−F(x0)h−f(x0)∣≤ε\left|\frac{F(x_0 + h) - F(x_0)}{h} - f(x_0)\right| \le \varepsilon.

∎

Theorem— Theorem 15 (fundamental theorem of calculus, part 2)

If FF is differentiable on [a,b][a, b] (one-sided at the ends) and F′=fF' = f is Riemann integrable, then ∫abf=F(b)−F(a)\int_a^b f = F(b) - F(a).

Proof

Let PP be any partition. By the mean value theorem, on each piece F(xi)−F(xi−1)=f(ti)(xi−xi−1)F(x_i) - F(x_{i-1}) = f(t_i)(x_i - x_{i-1}) for some ti∈(xi−1,xi)t_i \in (x_{i-1}, x_i), and mi≤f(ti)≤Mim_i \le f(t_i) \le M_i. Summing, the sum telescopes:

L(f,P)≤∑if(ti)(xi−xi−1)=F(b)−F(a)≤U(f,P).L(f, P) \le \sum_i f(t_i)(x_i - x_{i-1}) = F(b) - F(a) \le U(f, P).

So F(b)−F(a)F(b) - F(a) lies between every lower sum and every upper sum. Since ff is integrable, the only such number is ∫abf\int_a^b f.

∎

The hypothesis that F′F' is integrable cannot be dropped: Vito Volterra (1881) constructed a differentiable function whose derivative is bounded but not Riemann integrable. The Lebesgue integral repairs this partly (a bounded derivative is always Lebesgue integrable, and part 2 then holds), which is one of many reasons to continue to measure theory.

Formal mathematicsF

Real analysis in Lean and Mathlib

Mathlib states limits with filters: Tendsto a atTop (𝓝 L) says that aa eventually lands in every neighbourhood of LL. That one notion covers limits of sequences, of functions at a point, from the left, at infinity, and much more. To connect it with the lesson, we define the ε–N notions directly and prove that they agree with Mathlib's.

ConvergesToLean 4Formally verified
/-- `ConvergesTo a L`: the sequence `a` converges to `L` — for every `ε > 0` there is an index `N`
such that `|aₙ - L| < ε` for every `n ≥ N`. -/
def ConvergesTo (a : ℕ → ℝ) (L : ℝ) : Prop :=
  ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |a n - L| < ε
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
IsCauchyLean 4Formally verified
/-- `IsCauchy a`: the terms of `a` eventually stay close *to each other* — for every `ε > 0` there
is `N` with `|aₘ - aₙ| < ε` for all `m, n ≥ N`. No limit is mentioned. -/
def IsCauchy (a : ℕ → ℝ) : Prop :=
  ∀ ε > 0, ∃ N : ℕ, ∀ m ≥ N, ∀ n ≥ N, |a m - a n| < ε
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
convergesTo_iff_tendstoLean 4Applies a library theoremFormally verified
/-- The lesson's ε–N definition agrees with Mathlib's filter definition of a limit. This applies
Mathlib's `Metric.tendsto_atTop` (and `Real.dist_eq : dist x y = |x - y|`). -/
theorem convergesTo_iff_tendsto (a : ℕ → ℝ) (L : ℝ) :
    ConvergesTo a L ↔ Tendsto a atTop (𝓝 L) := by
  rw [Metric.tendsto_atTop]
  simp only [ConvergesTo, Real.dist_eq]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

The ε-arguments of the completeness section, written as calc chains that follow the human proofs line by line:

limit_uniqueLean 4Proved here from basic factsFormally verified
/-- **Limits are unique.** If `aₙ → L` and `aₙ → M`, then `L = M`. Otherwise take
`ε = |L - M| / 2`: far enough along, `aₙ` is within `ε` of both, and the triangle inequality gives
`|L - M| ≤ |L - aₙ| + |aₙ - M| < 2ε = |L - M|`. -/
theorem limit_unique {a : ℕ → ℝ} {L M : ℝ} (hL : ConvergesTo a L) (hM : ConvergesTo a M) :
    L = M := by
  by_contra hne
  have hpos : 0 < |L - M| / 2 := by
    have : 0 < |L - M| := abs_pos.mpr (sub_ne_zero.mpr hne)
    linarith
  obtain ⟨N₁, hN₁⟩ := hL _ hpos
  obtain ⟨N₂, hN₂⟩ := hM _ hpos
  have h1 := hN₁ (max N₁ N₂) (le_max_left _ _)
  have h2 := hN₂ (max N₁ N₂) (le_max_right _ _)
  have htri : |L - M| ≤ |a (max N₁ N₂) - L| + |a (max N₁ N₂) - M| := by
    calc |L - M| = |(a (max N₁ N₂) - M) - (a (max N₁ N₂) - L)| := by ring_nf
      _ ≤ |a (max N₁ N₂) - M| + |a (max N₁ N₂) - L| := abs_sub _ _
      _ = |a (max N₁ N₂) - L| + |a (max N₁ N₂) - M| := add_comm _ _
  linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
cauchy_of_convergesToLean 4Proved here from basic factsFormally verified
/-- **Every convergent sequence is Cauchy.** Given `ε`, choose `N` so that every term from `N` on
is within `ε/2` of the limit `L`; then `|aₘ - aₙ| ≤ |aₘ - L| + |L - aₙ| < ε/2 + ε/2 = ε`. -/
theorem cauchy_of_convergesTo {a : ℕ → ℝ} {L : ℝ} (h : ConvergesTo a L) : IsCauchy a := by
  intro ε hε
  obtain ⟨N, hN⟩ := h (ε / 2) (by linarith)
  refine ⟨N, fun m hm n hn => ?_⟩
  have hm' := hN m hm
  have hn' := hN n hn
  calc |a m - a n| = |(a m - L) - (a n - L)| := by ring_nf
    _ ≤ |a m - L| + |a n - L| := abs_sub _ _
    _ < ε / 2 + ε / 2 := add_lt_add hm' hn'
    _ = ε := by ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
convergesTo_of_cauchy_of_subseqLean 4Proved here from basic factsFormally verified
/-- **A Cauchy sequence with a convergent subsequence converges** (to the same limit). This is
the heart of "Cauchy ⇒ convergent": Bolzano–Weierstrass supplies the subsequence. Given `ε`, take
`N` from the Cauchy condition for `ε/2` and `K` so that `a (φ k)` is within `ε/2` of `L` for
`k ≥ K`. For `n ≥ N` pick `k = max K n`; since `φ` is strictly increasing, `φ k ≥ k ≥ n ≥ N`,
so `|aₙ - L| ≤ |aₙ - a (φ k)| + |a (φ k) - L| < ε`. -/
theorem convergesTo_of_cauchy_of_subseq {a : ℕ → ℝ} {L : ℝ} {φ : ℕ → ℕ} (ha : IsCauchy a)
    (hφ : StrictMono φ) (hsub : ConvergesTo (a ∘ φ) L) : ConvergesTo a L := by
  intro ε hε
  obtain ⟨N, hN⟩ := ha (ε / 2) (by linarith)
  obtain ⟨K, hK⟩ := hsub (ε / 2) (by linarith)
  refine ⟨N, fun n hn => ?_⟩
  have hk : n ≤ φ (max K n) := le_trans (le_max_right K n) (hφ.id_le _)
  have h1 : |a n - a (φ (max K n))| < ε / 2 := hN n hn _ (le_trans hn hk)
  have h2 : |a (φ (max K n)) - L| < ε / 2 := hK (max K n) (le_max_left _ _)
  calc |a n - L| = |(a n - a (φ (max K n))) + (a (φ (max K n)) - L)| := by ring_nf
    _ ≤ |a n - a (φ (max K n))| + |a (φ (max K n)) - L| := abs_add_le _ _
    _ < ε / 2 + ε / 2 := add_lt_add h1 h2
    _ = ε := by ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
monotone_convergesLean 4Proved here from basic factsFormally verified
/-- **Monotone convergence theorem.** An increasing sequence that is bounded above converges, to
the supremum `s` of its terms. Given `ε`, the number `s - ε` is not an upper bound, so some
`a_N > s - ε`; for `n ≥ N`, monotonicity gives `s - ε < a_N ≤ aₙ ≤ s`. This is exactly where the
completeness axiom (existence of `sSup`) enters. -/
theorem monotone_converges {a : ℕ → ℝ} (hmono : Monotone a) (hbdd : BddAbove (range a)) :
    ConvergesTo a (sSup (range a)) := by
  intro ε hε
  have hlt : sSup (range a) - ε < sSup (range a) := by linarith
  obtain ⟨_, ⟨N, rfl⟩, hN⟩ := exists_lt_of_lt_csSup (range_nonempty a) hlt
  refine ⟨N, fun n hn => ?_⟩
  have hle : a n ≤ sSup (range a) := le_csSup hbdd (mem_range_self n)
  have hge : a N ≤ a n := hmono hn
  rw [abs_lt]
  constructor <;> linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

Bolzano–Weierstrass and the completeness of R\R are cited from Mathlib, and combined with the lemmas above to give Theorem 4:

bolzano_weierstrassLean 4Applies a library theoremFormally verified
/-- **Bolzano–Weierstrass.** Every bounded sequence of real numbers has a convergent subsequence.
This applies Mathlib's `tendsto_subseq_of_bounded`, which holds in every proper metric space
(closed balls are compact), here the closed interval `[-M, M]`. -/
theorem bolzano_weierstrass (a : ℕ → ℝ) (M : ℝ) (hM : ∀ n, |a n| ≤ M) :
    ∃ L : ℝ, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (a ∘ φ) atTop (𝓝 L) := by
  obtain ⟨L, -, φ, hφ, hlim⟩ :=
    tendsto_subseq_of_bounded (Metric.isBounded_Icc (-M) M) (fun n => abs_le.mp (hM n))
  exact ⟨L, φ, hφ, hlim⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
cauchy_iff_convergesLean 4Applies a library theoremFormally verified
/-- **In `ℝ`, a sequence is Cauchy if and only if it converges.** The forward direction is the
completeness of `ℝ` (Mathlib's `cauchySeq_tendsto_of_complete`); the backward direction is
`cauchy_of_convergesTo`. Mathlib's `CauchySeq` is unfolded to ε–N form by `Metric.cauchySeq_iff`. -/
theorem cauchy_iff_converges (a : ℕ → ℝ) : IsCauchy a ↔ ∃ L, ConvergesTo a L := by
  constructor
  · intro h
    have hc : CauchySeq a := by
      rw [Metric.cauchySeq_iff]
      intro ε hε
      obtain ⟨N, hN⟩ := h ε hε
      exact ⟨N, fun m hm n hn => by rw [Real.dist_eq]; exact hN m hm n hn⟩
    obtain ⟨L, hL⟩ := cauchySeq_tendsto_of_complete hc
    exact ⟨L, (convergesTo_iff_tendsto a L).mpr hL⟩
  · rintro ⟨L, hL⟩
    exact cauchy_of_convergesTo hL
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

The intermediate value theorem, proved from the supremum exactly as in Theorem 5 (for a function continuous on all of R\R; a function continuous on [a,b][a, b] can be extended continuously by constants, so nothing is lost), next to Mathlib's general version and the extreme value theorem:

ivt_from_completenessLean 4Proved here from basic factsFormally verified
/-- **Intermediate value theorem, proved from completeness.** If `f` is continuous, `a ≤ b`,
`f a ≤ 0 ≤ f b`, then `f c = 0` for some `c ∈ [a, b]`. Let `S = {x ∈ [a, b] | f x ≤ 0}` and
`c = sup S`. If `f c > 0`, continuity gives a whole interval `(c - δ, c + δ)` where `f > 0`, so
`c - δ` would be an upper bound of `S` — impossible. If `f c < 0`, then `c < b` and `f < 0` a
little to the right of `c`, producing points of `S` larger than `c` — impossible. -/
theorem ivt_from_completeness {f : ℝ → ℝ} (hf : Continuous f) {a b : ℝ} (hab : a ≤ b)
    (ha : f a ≤ 0) (hb : 0 ≤ f b) : ∃ c ∈ Icc a b, f c = 0 := by
  set S : Set ℝ := {x | a ≤ x ∧ x ≤ b ∧ f x ≤ 0} with hS
  have hne : S.Nonempty := ⟨a, le_rfl, hab, ha⟩
  have hbdd : BddAbove S := ⟨b, fun x hx => hx.2.1⟩
  set c := sSup S with hc
  have hac : a ≤ c := le_csSup hbdd ⟨le_rfl, hab, ha⟩
  have hcb : c ≤ b := csSup_le hne fun x hx => hx.2.1
  refine ⟨c, ⟨hac, hcb⟩, le_antisymm (not_lt.mp fun hpos => ?_) (not_lt.mp fun hneg => ?_)⟩
  · -- `f c ≤ 0`: otherwise `f > 0` near `c`, and `c` would not be the least upper bound.
    obtain ⟨δ, hδ, hfδ⟩ := Metric.continuous_iff.mp hf c (f c) hpos
    obtain ⟨s, hsS, hs⟩ := exists_lt_of_lt_csSup hne (show c - δ < c by linarith)
    have hsc : s ≤ c := le_csSup hbdd hsS
    have hdist : dist s c < δ := by
      rw [Real.dist_eq, abs_lt]; constructor <;> linarith
    have := hfδ s hdist
    rw [Real.dist_eq, abs_lt] at this
    linarith [hsS.2.2]
  · -- `0 ≤ f c`: otherwise `f < 0` just to the right of `c`, giving points of `S` beyond `c`.
    have hcb' : c < b := lt_of_le_of_ne hcb (fun h => by rw [h] at hneg; linarith)
    obtain ⟨δ, hδ, hfδ⟩ := Metric.continuous_iff.mp hf c (-f c) (by linarith)
    set x := min (c + δ / 2) b with hx
    have hcx : c < x := lt_min (by linarith) hcb'
    have hdist : dist x c < δ := by
      rw [Real.dist_eq, abs_lt]
      constructor
      · linarith
      · have : x ≤ c + δ / 2 := min_le_left _ _
        linarith
    have hfx := hfδ x hdist
    rw [Real.dist_eq, abs_lt] at hfx
    have hxS : x ∈ S := ⟨by linarith, min_le_right _ _, by linarith⟩
    have : x ≤ c := le_csSup hbdd hxS
    linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
ivt_libraryLean 4Applies a library theoremFormally verified
/-- The intermediate value theorem in Mathlib's general form: a function continuous on `[a, b]`
takes every value between `f a` and `f b`. This applies Mathlib's `intermediate_value_Icc`, which
holds for any connected interval in a densely ordered conditionally complete order. -/
theorem ivt_library {f : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b) (hf : ContinuousOn f (Icc a b)) :
    Icc (f a) (f b) ⊆ f '' Icc a b :=
  intermediate_value_Icc hab hf
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
extreme_valueLean 4Applies a library theoremFormally verified
/-- **Extreme value theorem.** A function continuous on `[a, b]` (with `a ≤ b`) attains a maximum
there. This applies Mathlib's `IsCompact.exists_isMaxOn` to the compact interval `[a, b]`
(`isCompact_Icc`, Heine–Borel). -/
theorem extreme_value {f : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b) (hf : ContinuousOn f (Icc a b)) :
    ∃ c ∈ Icc a b, ∀ x ∈ Icc a b, f x ≤ f c := by
  obtain ⟨c, hc, hmax⟩ := isCompact_Icc.exists_isMaxOn (nonempty_Icc.mpr hab) hf
  exact ⟨c, hc, fun x hx => hmax hx⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

Uniform convergence, the ε/3 argument of Theorem 8, and Mathlib's version (which works over any topological space):

UniformlyConvergesOnLean 4Formally verified
/-- `UniformlyConvergesOn f g S`: the functions `fₙ` converge to `g` *uniformly* on `S` — one `N`
works for every `x ∈ S` at once. Compare pointwise convergence, where `N` may depend on `x`. -/
def UniformlyConvergesOn (f : ℕ → ℝ → ℝ) (g : ℝ → ℝ) (S : Set ℝ) : Prop :=
  ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, ∀ x ∈ S, |f n x - g x| < ε
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
uniform_limit_continuousLean 4Proved here from basic factsFormally verified
/-- **Uniform limits of continuous functions are continuous** (the ε/3 argument). Fix `x` and
`ε`. Choose `N` with `|f_N - g| < ε/3` everywhere, then `δ` with `|f_N y - f_N x| < ε/3` when
`|y - x| < δ`. Then
`|g y - g x| ≤ |g y - f_N y| + |f_N y - f_N x| + |f_N x - g x| < ε/3 + ε/3 + ε/3 = ε`. -/
theorem uniform_limit_continuous {f : ℕ → ℝ → ℝ} {g : ℝ → ℝ} (hf : ∀ n, Continuous (f n))
    (hu : UniformlyConvergesOn f g univ) : Continuous g := by
  rw [Metric.continuous_iff]
  intro x ε hε
  obtain ⟨N, hN⟩ := hu (ε / 3) (by linarith)
  obtain ⟨δ, hδ, hfδ⟩ := Metric.continuous_iff.mp (hf N) x (ε / 3) (by linarith)
  refine ⟨δ, hδ, fun y hy => ?_⟩
  have h1 : |f N y - g y| < ε / 3 := hN N le_rfl y (mem_univ y)
  have h2 : |f N y - f N x| < ε / 3 := by simpa [Real.dist_eq] using hfδ y hy
  have h3 : |f N x - g x| < ε / 3 := hN N le_rfl x (mem_univ x)
  rw [Real.dist_eq]
  calc |g y - g x| = |(f N y - f N x) - (f N y - g y) + (f N x - g x)| := by ring_nf
    _ ≤ |(f N y - f N x) - (f N y - g y)| + |f N x - g x| := abs_add_le _ _
    _ ≤ |f N y - f N x| + |f N y - g y| + |f N x - g x| := by
        gcongr; exact abs_sub _ _
    _ < ε / 3 + ε / 3 + ε / 3 := by gcongr
    _ = ε := by ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
uniform_limit_continuous_libraryLean 4Applies a library theoremFormally verified
/-- Mathlib's uniform limit theorem: if `Fₙ → f` uniformly (along any filter, here `n → ∞`) and
the `Fₙ` are continuous, then `f` is continuous. This applies `TendstoUniformly.continuous`; its
proof passes through *locally* uniform convergence, which is all continuity needs. -/
theorem uniform_limit_continuous_library {X : Type*} [TopologicalSpace X] {F : ℕ → X → ℝ}
    {f : X → ℝ} (h : TendstoUniformly F f atTop) (hc : ∀ n, Continuous (F n)) : Continuous f :=
  h.continuous (Frequently.of_forall hc)
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

The example xnx^n: pointwise convergence to 00 on [0,1)[0, 1), and a proof by Bernoulli's inequality that it is not uniform there:

pow_pointwiseLean 4Applies a library theoremFormally verified
/-- **Pointwise convergence of `xⁿ`.** For `0 ≤ x < 1`, `xⁿ → 0`. This applies Mathlib's
`tendsto_pow_atTop_nhds_zero_of_lt_one`. (At `x = 1` every term is `1`.) So on `[0, 1]` the
pointwise limit of the continuous functions `xⁿ` is `0` for `x < 1` and `1` at `x = 1`: it jumps. -/
theorem pow_pointwise {x : ℝ} (h0 : 0 ≤ x) (h1 : x < 1) :
    ConvergesTo (fun n => x ^ n) 0 :=
  (convergesTo_iff_tendsto _ 0).mpr (tendsto_pow_atTop_nhds_zero_of_lt_one h0 h1)
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
pow_not_uniformLean 4Proved here from basic factsFormally verified
/-- **`xⁿ → 0` is not uniform on `[0, 1)`.** Take `ε = 1/2`. Whatever `N` is proposed, let
`n = N + 1` and `x = 1 - 1/(2n)`. Bernoulli's inequality `(1 + t)ⁿ ≥ 1 + n t` (for `t ≥ -2`)
gives `xⁿ ≥ 1 - n/(2n) = 1/2`, so `|xⁿ - 0| < 1/2` fails. -/
theorem pow_not_uniform : ¬ UniformlyConvergesOn (fun n x => x ^ n) (fun _ => 0) (Ico 0 1) := by
  intro h
  obtain ⟨N, hN⟩ := h (1 / 2) (by norm_num)
  set n : ℕ := N + 1 with hn
  have hnpos : (0 : ℝ) < n := by positivity
  set x : ℝ := 1 - 1 / (2 * n) with hx
  have hx0 : 0 ≤ x := by
    rw [hx, sub_nonneg, div_le_one (by positivity)]
    have : (1 : ℝ) ≤ n := by rw [hn]; push_cast; linarith [N.cast_nonneg (α := ℝ)]
    linarith
  have hx1 : x < 1 := by
    have : 0 < 1 / (2 * (n : ℝ)) := by positivity
    rw [hx]; linarith
  have hbern : 1 + (n : ℝ) * (-(1 / (2 * n))) ≤ (1 + -(1 / (2 * n))) ^ n := by
    apply one_add_mul_le_pow
    have : 1 / (2 * (n : ℝ)) ≤ 1 := by
      rw [div_le_one (by positivity)]
      have : (1 : ℝ) ≤ n := by rw [hn]; push_cast; linarith [N.cast_nonneg (α := ℝ)]
      linarith
    linarith
  have hhalf : (1 : ℝ) / 2 ≤ x ^ n := by
    have e1 : 1 + (n : ℝ) * (-(1 / (2 * n))) = 1 / 2 := by field_simp; ring
    have e2 : (1 + -(1 / (2 * (n : ℝ)))) = x := by rw [hx]; ring
    rw [e1, e2] at hbern
    exact hbern
  have := hN n (by omega) x ⟨hx0, hx1⟩
  simp only [sub_zero] at this
  rw [abs_of_nonneg (pow_nonneg hx0 n)] at this
  linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

Finally integration. Mathlib's integral ∫ t in a..b, f t is the Lebesgue integral; for continuous ff it agrees with the Riemann integral. The first fundamental theorem is proved here by the estimate of Theorem 14, and the second is cited, together with the mean value theorem used in its proof:

ftc_oneLean 4Proved here from basic factsFormally verified
/-- **Fundamental theorem of calculus, part 1.** If `f` is continuous, then `F(u) = ∫ₐᵘ f` is
differentiable with `F' = f`. Proof by an estimate, as in the lesson: given `c > 0`, continuity at
`x` gives `δ` with `|f t - f x| < c` for `|t - x| < δ`. For `|h| < δ`,
`F(x + h) - F(x) - h·f(x) = ∫ₓ^{x+h} (f t - f x) dt`, whose absolute value is at most `c·|h|`.
That is exactly the little-o condition defining the derivative. -/
theorem ftc_one {f : ℝ → ℝ} (hf : Continuous f) (a x : ℝ) :
    HasDerivAt (fun u => ∫ t in a..u, f t) (f x) x := by
  rw [hasDerivAt_iff_isLittleO_nhds_zero, Asymptotics.isLittleO_iff]
  intro c hc
  obtain ⟨δ, hδ, hfδ⟩ := Metric.continuous_iff.mp hf x c hc
  rw [Metric.eventually_nhds_iff]
  refine ⟨δ, hδ, fun h hh => ?_⟩
  have hint : ∀ p q : ℝ, IntervalIntegrable f MeasureTheory.volume p q :=
    fun p q => hf.intervalIntegrable p q
  have key : (∫ t in a..x + h, f t) - (∫ t in a..x, f t) - h • f x
      = ∫ t in x..x + h, (f t - f x) := by
    rw [intervalIntegral.integral_interval_sub_left (hint _ _) (hint _ _),
      intervalIntegral.integral_sub (hint _ _) intervalIntegrable_const,
      intervalIntegral.integral_const, smul_eq_mul, smul_eq_mul]
    ring
  rw [key]
  have hh' : |h| < δ := by simpa [Real.dist_eq] using hh
  have hbound : ∀ t ∈ Set.uIoc x (x + h), ‖f t - f x‖ ≤ c := by
    intro t ht
    have htx : |t - x| ≤ |h| := by
      rcases Set.mem_uIoc.mp ht with ⟨h1, h2⟩ | ⟨h1, h2⟩
      · rw [abs_of_pos (by linarith), abs_of_pos (by linarith)]; linarith
      · rw [abs_of_nonpos (by linarith), abs_of_neg (by linarith)]; linarith
    have : dist t x < δ := by rw [Real.dist_eq]; linarith
    have := hfδ t this
    rw [Real.dist_eq] at this
    rw [Real.norm_eq_abs]
    exact this.le
  calc ‖∫ t in x..x + h, (f t - f x)‖ ≤ c * |x + h - x| :=
        intervalIntegral.norm_integral_le_of_norm_le_const hbound
    _ = c * ‖h‖ := by rw [Real.norm_eq_abs]; ring_nf
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
ftc_one_libraryLean 4Applies a library theoremFormally verified
/-- The same statement as `ftc_one`, from Mathlib: `Continuous.integral_hasStrictDerivAt` gives
even *strict* differentiability of `u ↦ ∫ₐᵘ f`. -/
theorem ftc_one_library {f : ℝ → ℝ} (hf : Continuous f) (a x : ℝ) :
    HasDerivAt (fun u => ∫ t in a..u, f t) (f x) x :=
  (hf.integral_hasStrictDerivAt a x).hasDerivAt
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
mean_valueLean 4Applies a library theoremFormally verified
/-- **Mean value theorem.** If `f` is continuous on `[a, b]` and has derivative `f'` on `(a, b)`,
then `f' c = (f b - f a)/(b - a)` for some `c ∈ (a, b)`. This applies Mathlib's
`exists_hasDerivAt_eq_slope`, proved there from Rolle's theorem. -/
theorem mean_value {f f' : ℝ → ℝ} {a b : ℝ} (hab : a < b) (hfc : ContinuousOn f (Icc a b))
    (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) :
    ∃ c ∈ Ioo a b, f' c = (f b - f a) / (b - a) :=
  exists_hasDerivAt_eq_slope f f' hab hfc hff'
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
ftc_twoLean 4Applies a library theoremFormally verified
/-- **Fundamental theorem of calculus, part 2.** If `F` has derivative `f` at every point of
`[a, b]` and `f` is integrable there, then `∫ₐᵇ f = F b - F a`. This applies Mathlib's
`intervalIntegral.integral_eq_sub_of_hasDerivAt`. -/
theorem ftc_two {F f : ℝ → ℝ} {a b : ℝ} (hF : ∀ x ∈ uIcc a b, HasDerivAt F (f x) x)
    (hint : IntervalIntegrable f MeasureTheory.volume a b) : ∫ x in a..b, f x = F b - F a :=
  intervalIntegral.integral_eq_sub_of_hasDerivAt hF hint
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor
rationals_and_irrationals_denseLean 4Applies a library theoremFormally verified
/-- **Every interval contains both rationals and irrationals.** This is why the indicator function
of `ℚ` (Dirichlet's function) is not Riemann integrable on `[0, 1]`: on every subinterval of every
partition its supremum is `1` and its infimum is `0`, so every upper sum is `1` and every lower sum
is `0`. Assembled from Mathlib's `exists_rat_btwn` (Archimedean property) and
`exists_irrational_btwn`. -/
theorem rationals_and_irrationals_dense {x y : ℝ} (h : x < y) :
    (∃ q : ℚ, x < q ∧ (q : ℝ) < y) ∧ (∃ r : ℝ, Irrational r ∧ x < r ∧ r < y) :=
  ⟨exists_rat_btwn h, exists_irrational_btwn h⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/RealAnalysis.leanTry it in the Lean web editor

What is and is not formalised. Proved here from the definitions: uniqueness of limits, convergent ⇒ Cauchy, the subsequence step of the Cauchy criterion, monotone convergence (Theorem 1), the intermediate value theorem (Theorem 5), the uniform limit theorem (Theorem 8), the non-uniformity of xnx^n, the first fundamental theorem (Theorem 14, for continuous ff) and, in the solutions to the Lean exercises, the sum rule for limits. Cited from Mathlib: Bolzano–Weierstrass, completeness of R\R, the extreme value theorem, the mean value theorem and the second fundamental theorem. Not formalised: Lemma 2, Heine–Cantor (in Mathlib as CompactSpace.uniformContinuous_of_continuous), Theorems 9–11, Weierstrass's function, and the non-integrability of 1Q\mathbf 1_\Q. Mathlib has no separate theory of the Riemann integral on R\R (its general BoxIntegral covers Riemann-type integrals on boxes), so for 1Q\mathbf 1_\Q we formalise only the density facts the proof uses.

ComputationC

Measuring sup-distances, and a function with no tangent

Uniform convergence is a statement about one number per nn, the supremum sup⁡S∣fn−f∣\sup_S |f_n - f|. The program computes it for the examples of this lesson, exactly where calculus gives a closed form and on a fine grid as a cross-check. Watch three things: xnx^n on [0,1)[0, 1), where the supremum never moves from 11; the spikes hnh_n, whose integrals tend to 11 although hn→0h_n \to 0 at every point; and sin⁡(nx)/n\sin(nx)/n, which converges uniformly while its derivatives keep oscillating.

Pointwise versus uniform convergence: sup-distancesPythonExact computationNumerical approximationComputationally tested
"""Pointwise versus uniform convergence: measuring sup-distances.

Uniform convergence of f_n to f on S means sup over S of |f_n - f| -> 0. We
measure that supremum for three classic sequences, using exact formulas where
calculus gives them and a fine grid as a cross-check:

1. x^n -> 0 pointwise on [0, 1), but the sup over [0, 1) is 1 for every n
   (not uniform); on [0, 0.9] the sup is 0.9^n -> 0 (uniform).
2. h_n(x) = 2 n^2 x exp(-n^2 x^2) -> 0 pointwise on [0, 1], yet the integral
   of h_n over [0, 1] is 1 - exp(-n^2) -> 1: limit and integral cannot be
   swapped, and indeed sup h_n = sqrt(2) n exp(-1/2) blows up.
3. s_n(x) = sin(n x)/n -> 0 uniformly (sup = 1/n), but the derivatives
   cos(n x) do not converge at x = pi: limit and derivative cannot be swapped.

Evidence: exact closed forms (derived in the docstrings) plus numerical grid
checks; the grid can only ever estimate a supremum from below.
"""

import math

def grid(a, b, points):
    """Equally spaced points from a to b inclusive (points >= 2)."""
    if points < 2:
        raise ValueError("need at least two points")
    step = (b - a) / (points - 1)
    return [a + i * step for i in range(points)]

def grid_sup(func, xs):
    """Largest |func(x)| over the sample points xs: a lower bound for the sup."""
    return max(abs(func(x)) for x in xs)

def spike(n, x):
    """h_n(x) = 2 n^2 x exp(-n^2 x^2), a moving spike of area about 1."""
    return 2 * n * n * x * math.exp(-(n * x) ** 2)

def spike_sup(n):
    """Exact sup of h_n on [0, 1]: at x = 1/(n sqrt 2), h_n = sqrt(2) n e^(-1/2)."""
    return math.sqrt(2) * n * math.exp(-0.5)

def spike_integral(n):
    """Exact integral of h_n over [0, 1]: [-exp(-n^2 x^2)] from 0 to 1."""
    return 1 - math.exp(-n * n)

def midpoint_integral(func, a, b, strips):
    """Composite midpoint rule, a numerical check of spike_integral."""
    width = (b - a) / strips
    return width * sum(func(a + (i + 0.5) * width) for i in range(strips))

def main():
    xs = grid(0.0, 1.0, 20001)[:-1]  # [0, 1) sampled
    print("1. x^n -> 0 pointwise on [0, 1); is it uniform?")
    print("    n   sup on [0,0.9]   grid sup on [0,1)   exact sup on [0,1)")
    for n in [1, 5, 20, 100, 1000]:
        near = grid_sup(lambda x: x ** n, xs)
        print(f"{n:5d}   {0.9 ** n:14.3e}   {near:17.6f}   {1:18d}")
    print("   On [0, 0.9]: uniform. On [0, 1): the sup stays 1, so not uniform.")
    print()
    print("2. Spikes h_n -> 0 pointwise on [0, 1], but their integrals do not")
    print("    n   h_n(1/2)    sup h_n   integral (exact)   midpoint rule")
    for n in [1, 2, 5, 10, 50]:
        mid = midpoint_integral(lambda x: spike(n, x), 0.0, 1.0, 4000)
        print(f"{n:5d}   {spike(n, 0.5):9.2e}   {spike_sup(n):7.2f}"
              f"   {spike_integral(n):16.6f}   {mid:13.6f}")
    print("   lim of integrals = 1, but integral of lim = 0.")
    print()
    print("3. sin(nx)/n -> 0 uniformly (sup = 1/n); derivatives cos(nx)")
    for n in [1, 2, 3, 4, 10, 11]:
        sup = grid_sup(lambda x: math.sin(n * x) / n, grid(0, math.pi, 2001))
        print(f"   n = {n:2d}: grid sup = {sup:.4f}, derivative at pi ="
              f" {math.cos(n * math.pi):+.0f}")
    print()
    print("Epistemic status: the suprema and integrals in the 'exact' columns")
    print("come from closed forms proved by calculus; the grid and midpoint")
    print("columns are numerical cross-checks (a grid only bounds a sup from")
    print("below). Finitely many n can illustrate, but not prove, what happens")
    print("as n -> infinity; the proofs are in the lesson.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Notice that the grid's estimate of sup⁡[0,1)x1000\sup_{[0, 1)} x^{1000} is only about 0.950.95. A grid of 20,00020{,}000 points never gets close enough to 11. A grid can only bound a supremum from below, which is why the "exact" column comes from a proof. This is numerical illustration, not a proof of uniform or non-uniform convergence.

The second program evaluates Weierstrass's function at the points 13−m13^{-m} of Theorem 12. There the infinite tail can be summed exactly, so only mm cosines need floating point. The difference quotients at 00 grow like 6.5m6.5^m, while those of the smooth partial sum W3W_3 shrink to W3′(0)=0W_3'(0) = 0.

Weierstrass's function: difference quotients that run awayPythonExact computationNumerical approximationComputationally tested
"""Weierstrass's function: difference quotients at 0 that run away.

W(x) = sum over k >= 0 of a^k cos(b^k pi x), with a = 1/2 and b = 13, is a
uniform limit of smooth functions (Weierstrass M-test), hence continuous. At
the points h_m = 13^(-m) we can evaluate W exactly in closed form: for k >= m
the number b^k h_m = 13^(k-m) is an odd integer, so cos(b^k pi h_m) = -1 and
the infinite tail sums to -a^m/(1 - a). Only the first m terms need floating
point. The difference quotients D_m = (W(h_m) - W(0))/h_m then grow like
(ab)^m = 6.5^m, so W is not differentiable at 0. Every partial sum W_K is
smooth, and its quotients settle down to W_K'(0) = 0 instead.

Evidence: exact closed forms for the tail plus floating-point arithmetic for
finitely many terms; one point (x = 0) is examined, not every point.
"""

import math

A = 0.5
B = 13

def partial_sum(x, terms, a=A, b=B):
    """W_K(x): the first `terms` terms of the series (floating point)."""
    return sum(a ** k * math.cos(b ** k * math.pi * x) for k in range(terms))

def w_at_zero(a=A):
    """W(0) = sum of a^k = 1/(1 - a), exactly."""
    return 1 / (1 - a)

def w_at_power(m, a=A, b=B):
    """W(b^-m) for an odd integer b: m float terms plus the exact tail."""
    if b % 2 == 0:
        raise ValueError("b must be odd for the closed-form tail")
    head = sum(a ** k * math.cos(math.pi / b ** (m - k)) for k in range(m))
    tail = -(a ** m) / (1 - a)  # cos(odd multiple of pi) = -1
    return head + tail

def quotient(m, a=A, b=B):
    """D_m = (W(h) - W(0)) / h with h = b^-m."""
    return (w_at_power(m, a, b) - w_at_zero(a)) * b ** m

def partial_quotient(m, terms, a=A, b=B):
    """Difference quotient of the smooth partial sum W_K at 0, h = b^-m."""
    h = 1 / b ** m
    return (partial_sum(h, terms, a, b) - partial_sum(0, terms, a, b)) / h

def main():
    print("W(x) = sum (1/2)^k cos(13^k pi x);  ab = 6.5 > 1 + 3pi/2")
    print("Difference quotients at 0 with h = 13^-m:")
    print("  m          h            D_m   D_m / 6.5^m   W_3 quotient")
    for m in range(1, 9):
        d = quotient(m)
        p = partial_quotient(m, 3)
        print(f"{m:3d}   {B ** -m:10.3e}   {d:12.4e}   {d / 6.5 ** m:11.5f}"
              f"   {p:12.4e}")
    print()
    print("D_m / 6.5^m tends to a negative constant, so |D_m| -> infinity:")
    print("W has no derivative at 0. The smooth partial sum W_3 behaves")
    print("as calculus predicts: its quotients shrink to W_3'(0) = 0.")
    print()
    print("Epistemic status: the tail of the series is summed exactly, and")
    print("only m cosines are computed in floating point, so these numbers are")
    print("reliable; together with the lesson's estimate they prove that W is")
    print("not differentiable at 0. They say nothing about other points:")
    print("nowhere-differentiability needs Weierstrass's argument for every x.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Here the computation and the proof of Theorem 12 tell the same story, and the computation's numbers are reliable to many digits. But it examines one point, x=0x = 0. "Nowhere differentiable" is a statement about uncountably many points, and only Weierstrass's argument (or Hardy's) covers them all.

Explore

Explore: limits, tubes and spikes

ε and N. Shrink ε and see how far out you must go before every term of (1+1/n)n(1 + 1/n)^n stays in the band around ee. The convergence is slow: the error is about e/(2n)e/(2n).

(1 + 1/n)ⁿ → e: find N for each ε

Plot the terms aₙ and test a candidate limit with an ε-band: from some index on, every term must stay inside.

an =
  • term inside the band
  • term outside the band
  • band from L − ε to L + ε

a80 = 2.701485

From n = 27 on, all of the first 2,000 terms lie within ε = 0.05 of L = 2.71828.

Evidence, not proof: a computer can check only finitely many terms. A proof must show |aₙ − L| < ε for every n ≥ N.

Pointwise, not uniform. Increase nn. For any fixed x<1x < 1 the curve xnx^n eventually drops below the line y=0.1y = 0.1, but there are always points just left of 11 where it is still above. No tube of width 0.10.1 around the limit ever contains the whole graph.

xⁿ on [0, 1]: the threshold N depends on x

Move the sliders and trace along the curves to read off values.

  • y = xⁿ
  • y = 0.1
  • y = xⁿ: y = 1
  • y = 0.1: y = 0.1

Mass escaping into a spike. The shaded area under hn(x)=2n2xe−n2x2h_n(x) = 2n^2xe^{-n^2x^2} on [0,1][0, 1] stays close to 11, while the spike runs into the yy-axis and hn(x)→0h_n(x) \to 0 at every point.

Spikes: ∫hₙ → 1 but hₙ → 0 pointwise

Move the sliders and trace along the curves to read off values.

  • hₙ(x)
  • Signed area: above the axis counts as positive, below (hatched) as negative
  • hₙ(x): y = 0.1465
  • Signed area from 0 to 1 ≈ 0.9817 (numerical integration)

Upper and lower sums. For the continuous function x2x^2 on [0,1][0, 1], compare the left and right sums (here, because x2x^2 is increasing, these are the lower and upper sums) as the number of strips grows. Their difference is exactly 1/n1/n.

Riemann sums

Approximate the area under a curve with thin strips, and watch the error shrink as the strips get thinner.

  • f(x) = x²

Left sum with 8 strips

L8 = 0.273438

Exact value of the integral

∫01 f(x) dx = 0.333333

Error (sum − integral)

−0.059896

All four rules with n = 8

RuleSumError
Left (L8)0.273438−0.059896
Right (R8)0.3984380.065104
Midpoint (M8)0.332031−0.001302
Trapezoid (T8)0.3359380.002604

Double n and watch the error: left and right sums roughly halve it, midpoint and trapezoid sums cut it to about a quarter.

Towards a curve with no tangent. These are partial sums of ∑(1/2)kcos⁡(5kπx)\sum (1/2)^k \cos(5^k \pi x). Here ab=2.5≥1ab = 2.5 \ge 1, so by Hardy's theorem the full sum is nowhere differentiable. Each extra term adds smaller, faster wiggles. Zoom in on any part of the last curve and it still looks rough.

Partial sums of a Weierstrass function

Move the sliders and trace along the curves to read off values.

  • 1 term
  • 2 terms
  • 3 terms
  • 4 terms
  • 1 term: y = 0
  • 2 terms: y = 0
  • 3 terms: y = 0
  • 4 terms: y = 0
Exercises

Exercises

1. Real analysis

Warm-upHuman

Which of these sequences converge (as n→∞n \to \infty)? Choose all that apply.

Choose all that apply

2. Real analysis

Warm-upHuman

Let an=nn+1a_n = \dfrac{n}{n + 1}, which converges to 11. For ε=150\varepsilon = \dfrac{1}{50}, what is the smallest NN such that ∣an−1∣<ε|a_n - 1| < \varepsilon for every n≥Nn \ge N?

3. Real analysis

CoreHuman

Each sequence converges pointwise to 00 on [0,1][0, 1]. Which converge uniformly on [0,1][0, 1]? Choose all that apply.

Choose all that apply

4. Real analysis

CoreHuman

The extreme value theorem says: a continuous function on a closed bounded interval [a,b][a, b] attains a maximum. Which example shows that the word closed cannot be dropped?

Choose one

5. Real analysis

CoreHuman

Here is a flawed proof that a pointwise limit ff of continuous functions fnf_n is continuous at cc.

  1. Let ε>0\varepsilon > 0.
  2. For each xx, choose NxN_x with ∣fn(x)−f(x)∣<ε/3|f_n(x) - f(x)| < \varepsilon/3 for n≥Nxn \ge N_x.
  3. Let N=NcN = N_c and choose δ>0\delta > 0 with ∣fN(x)−fN(c)∣<ε/3|f_N(x) - f_N(c)| < \varepsilon/3 when ∣x−c∣<δ|x - c| < \delta.
  4. For ∣x−c∣<δ|x - c| < \delta: ∣f(x)−f(c)∣≤∣f(x)−fN(x)∣+∣fN(x)−fN(c)∣+∣fN(c)−f(c)∣|f(x) - f(c)| \le |f(x) - f_N(x)| + |f_N(x) - f_N(c)| + |f_N(c) - f(c)|.
  5. Each of the three terms is less than ε/3\varepsilon/3, so ∣f(x)−f(c)∣<ε|f(x) - f(c)| < \varepsilon.

Which step is wrong?

Choose one

6. Real analysis

CoreFormal

Which Lean statement says that f n converges to g uniformly on the set S (and not merely pointwise)?

Choose one

7. Real analysis

CoreHuman

Let f(x)=x3f(x) = x^3 on [0,2][0, 2] and let PnP_n split [0,2][0, 2] into nn equal pieces. What is the smallest nn for which U(f,Pn)−L(f,Pn)≤1100U(f, P_n) - L(f, P_n) \le \dfrac{1}{100}?

8. Real analysis

CoreComputational

The proof of the intermediate value theorem can be turned into an algorithm by bisection (the nested-interval form of completeness). Write bisect(f, a, b, steps) which assumes f(a) <= 0 <= f(b) and returns the pair (lo, hi) after steps halvings: at each step let m = (lo + hi) / 2; if f(m) <= 0 replace lo by m, otherwise replace hi by m. The invariant f(lo) <= 0 <= f(hi) is kept, and hi - lo is halved each time.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

9. Real analysis

StretchHuman

With the usual distance ∣x−y∣|x - y|, in which of these sets does every Cauchy sequence converge to a point of the set? Choose all that apply.

Choose all that apply

10. Real analysis

StretchHuman

Let fn(x)=sin⁡(n2x)nf_n(x) = \dfrac{\sin(n^2 x)}{n} on R\R. Which statements are true? Choose all that apply.

Choose all that apply
Common misconceptionsH

Common misconceptions

Misconception

"A limit of continuous functions is continuous." Only if the convergence is uniform (or at least locally uniform). The functions xnx^n are continuous on [0,1][0, 1] and their pointwise limit jumps at 11. Cauchy's 1821 "sum theorem" made exactly this mistake. More generally, never interchange two limits — lim⁡nlim⁡x\lim_n \lim_x versus lim⁡xlim⁡n\lim_x \lim_n, a limit and an integral, a limit and a derivative, two infinite sums — without a theorem that allows it. Theorems 8, 9 and 11 are such theorems. The examples xnx^n, hnh_n and sin⁡(nx)/n\sin(nx)/n show that each needs its hypothesis.

Misconception

"Every bounded function on [0,1][0, 1] is Riemann integrable." The indicator function of Q\Q is bounded, but all its upper sums are 11 and all its lower sums are 00. Lebesgue's criterion (below) says precisely which bounded functions are integrable: those whose points of discontinuity form a set of measure zero. 1Q\mathbf 1_\Q is discontinuous everywhere.

Misconception

"If the terms get closer and closer together, the sequence converges." Consecutive terms getting close is not enough. The partial sums sn=1+12+⋯+1ns_n = 1 + \frac12 + \cdots + \frac1n satisfy sn+1−sn→0s_{n+1} - s_n \to 0, yet sn→∞s_n \to \infty. The Cauchy condition asks that all pairs of late terms be close, ∣am−an∣<ε|a_m - a_n| < \varepsilon for all m,n≥Nm, n \ge N, and s2n−sn≥12s_{2n} - s_n \ge \tfrac12 shows the harmonic series fails it.

Misconception

"Continuous functions are differentiable except at a few corners." Weierstrass's function is continuous and differentiable nowhere. Worse, by the Baire category theorem (Banach and Mazurkiewicz, 1931), in the space of continuous functions on [0,1][0, 1] with the sup-distance the nowhere-differentiable functions form a comeagre set — in the sense of category, "most" continuous functions are like Weierstrass's.

Misconception

"Convergence and uniform convergence differ only for weird functions." They differ already for nx/(1+n2x2)nx/(1 + n^2x^2), a smooth function with a smooth limit. And uniform convergence of fnf_n says nothing about convergence of fn′f_n', as sin⁡(nx)/n\sin(nx)/n shows.

ViewpointsH

Many ways of seeing

Topology— Connectedness, compactness and completeness

The three big theorems on [a,b][a, b] are topological theorems in disguise. The intermediate value theorem says that a continuous image of a connected space is connected (and the connected subsets of R\R are the intervals). The extreme value theorem and Heine–Cantor say that [a,b][a, b] is compact: every open cover has a finite subcover, equivalently (in metric spaces) every sequence has a convergent subsequence. Both are proved in point-set topology for general spaces.

Completeness, by contrast, is not a topological property. The interval (0,1)(0, 1) is homeomorphic to R\R (by t↦tan⁡(πt−π/2)t \mapsto \tan(\pi t - \pi/2)), yet 1/n1/n is a Cauchy sequence in (0,1)(0, 1) with no limit there. Completeness belongs to the metric, and in complete metric spaces it yields the Baire category theorem: a countable union of closed sets with empty interior has empty interior. Applied to the complete space C[0,1]C[0, 1], it shows that nowhere-differentiable functions are generic (Banach, 1931).

Analysis— Lebesgue: which functions are integrable, and when limits commute

Henri Lebesgue answered the question "which bounded functions are Riemann integrable?" exactly. Lebesgue's criterion: a bounded f:[a,b]→Rf : [a, b] \to \R is Riemann integrable if and only if its set of discontinuities has measure zero (it can be covered by countably many intervals of total length less than any ε>0\varepsilon > 0). Thomae's function is discontinuous only on the countable set Q\Q, so it is integrable; 1Q\mathbf 1_\Q is discontinuous everywhere, so it is not.

Lebesgue's integral (1902) integrates 1Q\mathbf 1_\Q (its integral is 00) and, more importantly, comes with far better limit theorems. The dominated convergence theorem says: if fn→ff_n \to f pointwise and ∣fn∣≤g|f_n| \le g for one integrable gg, then ∫fn→∫f\int f_n \to \int f — no uniformity needed. The spikes hnh_n escape it, as they must: sup⁡nhn(x)≈2/(ex)\sup_n h_n(x) \approx 2/(ex) near 00, which is not integrable. See measure theory and, for the space C[0,1]C[0, 1] with the sup norm as a complete normed space, functional analysis.

Probability— Rough paths and a probabilistic proof of approximation

Weierstrass's monster is the typical behaviour of randomness. The paths of Brownian motion are continuous and, with probability 11, nowhere differentiable (Paley, Wiener and Zygmund, 1933). Over a time step hh a Brownian path moves about h\sqrt h, so its difference quotients are of size h−1/2→∞h^{-1/2} \to \infty.

Probability also proves one of the best theorems about uniform approximation. Weierstrass approximation theorem: every continuous ff on [0,1][0, 1] is a uniform limit of polynomials. Sergei Bernstein's proof (1912) takes SnS_n binomially distributed with parameters nn and xx, and sets

Bnf(x)=E ⁣[f ⁣(Snn)]=∑k=0nf ⁣(kn)(nk)xk(1−x)n−k.B_n f(x) = \mathbb E\!\left[f\!\left(\tfrac{S_n}{n}\right)\right] = \sum_{k=0}^n f\!\left(\tfrac kn\right) \binom nk x^k (1 - x)^{n-k}.

The law of large numbers (Chebyshev's inequality: Pr⁡(∣Sn/n−x∣≥δ)≤14nδ2\Pr(|S_n/n - x| \ge \delta) \le \frac{1}{4n\delta^2}) and the uniform continuity of ff (Heine–Cantor) give sup⁡x∣Bnf(x)−f(x)∣→0\sup_x |B_n f(x) - f(x)| \to 0.

Algebra— The only complete ordered field

To an algebraist, R\R is characterised by a universal statement: every complete ordered field is isomorphic to R\R, by a unique isomorphism. The proof sends 1↦11 \mapsto 1, extends to Q\Q, and uses suprema to extend to everything. Remove completeness and many other ordered fields appear. Examples are the real algebraic numbers, the field R(t)\R(t) of rational functions ordered so that tt is larger than every real number (non-Archimedean: 1/t1/t is a positive infinitesimal), and the hyperreal numbers of non-standard analysis. Every theorem of this lesson fails in some ordered field, because every proof used completeness. Completion also depends on the distance chosen: completing Q\Q for the pp-adic absolute value gives the pp-adic numbers Qp\Q_p, where ∑npn=11−p\sum_n p^n = \frac{1}{1 - p} converges and a series converges as soon as its terms tend to 00.

Logic— How much does each theorem cost?

Logicians measure the strength of these theorems. In reverse mathematics, over the weak base theory RCA₀ ("computable mathematics"), the intermediate value theorem is provable outright. The Heine–Borel theorem for [0,1][0, 1] is equivalent to weak König's lemma (WKL₀). The Bolzano–Weierstrass theorem is equivalent to the much stronger arithmetical comprehension (ACA₀) — see Simpson's Subsystems of Second Order Arithmetic. In constructive analysis (Bishop, 1967), the exact intermediate value theorem cannot be proved, since there is no algorithm to decide on which side of 00 the value at a midpoint lies. An approximate version holds: for every ε>0\varepsilon > 0 there is cc with ∣f(c)∣<ε|f(c)| < \varepsilon. And Abraham Robinson's non-standard analysis (1961) makes Leibniz's infinitesimals rigorous using the compactness theorem of first-order logic.

History & global context

History and global context

  • Exhaustion. Archimedes (3rd century BCE) computed the area of a parabolic segment by squeezing it between inscribed and circumscribed polygons — the ancestor of upper and lower sums. Liu Hui (3rd century CE, China) bounded π\pi by the same kind of squeeze with polygons of 3⋅2n3 \cdot 2^n sides.
  • Infinite series in Kerala. Mādhava of Saṅgamagrāma (c. 1340 – c. 1425) and his school in Kerala found the power series of sine, cosine and arctangent, with estimates for the error of truncation. Their derivations are recorded in Jyeṣṭhadeva's Yuktibhāṣā (c. 1530).
  • Calculus and its critics. Newton and Leibniz created the calculus in the 1660s–1680s. George Berkeley's The Analyst (1734) mocked infinitesimals as "ghosts of departed quantities", and no fully satisfactory answer came for a century.
  • Rigour. Bernard Bolzano's 1817 paper proved the intermediate value theorem from a form of completeness, and his manuscripts (published only in the twentieth century) contain a continuous nowhere-differentiable function. Cauchy's Cours d'analyse (1821) and his later lectures founded analysis on limits; Abel (1826) found the counterexample to Cauchy's sum theorem. Christoph Gudermann (1838) used the phrase "uniform convergence", and Philipp Ludwig von Seidel and George Gabriel Stokes isolated the concept in 1847. Karl Weierstrass, Gudermann's student, made it central in his Berlin lectures of the 1860s, where the ε–δ style took its modern form.
  • The integral. Bernhard Riemann defined his integral in his 1854 habilitation thesis on Fourier series (published 1868). Gaston Darboux (1875) gave the formulation by upper and lower sums used here, and Henri Lebesgue's 1902 thesis introduced the integral that superseded it.
  • The real numbers. In 1872 Richard Dedekind (cuts), Georg Cantor (Cauchy sequences, following Charles Méray, 1869) and Eduard Heine published constructions of R\R. In the same year Weierstrass presented his nowhere-differentiable function to the Berlin Academy; Paul du Bois-Reymond published it in 1875.
Further reading

Further reading

  • Stephen Abbott, Understanding Analysis (2nd edition, 2015) — the friendliest rigorous introduction; motivates every definition by an example like the ones above.
  • Walter Rudin, Principles of Mathematical Analysis (3rd edition, 1976) — concise and complete; chapters 3, 4, 6 and 7 cover this lesson.
  • Terence Tao, Analysis I and Analysis II (2006) — builds everything from the axioms, very close in spirit to a formal proof.
  • David Bressoud, A Radical Approach to Real Analysis (1994; 2nd edition 2007) — the subject told through the historical crises (Fourier series, Cauchy's error) that created it.
  • Michael Spivak, Calculus (1967) — calculus done rigorously, with outstanding exercises.