Survey of Mathematics

4.2 Convergence, completeness and the contraction mapping theorem

A space is complete when every sequence whose terms bunch together has a limit in the space. A map that shrinks every distance by a fixed factor below 1, run again and again in a complete space, always settles on exactly one fixed point. That is how cos x = x, Newton's method, PageRank and reinforcement-learning value iteration all work.

Beyond the courseRudin, Principles of Mathematical Analysis, ch. 3 (Cauchy sequences), ch. 7 (uniform convergence) and ch. 9 (contraction principle)Abbott, Understanding Analysis, ch. 2 and ch. 6Banach, Fundamenta Mathematicae 3 (1922), pp. 133 to 181

Chapter 1.2 ended on a fact about the real line: a sequence of real numbers converges if and only if its terms bunch together (the Cauchy criterion). The fact is what lets us prove a limit exists without knowing its value. Does it hold in other metric spaces? In Q\mathbb Q it fails, and in the space of continuous functions it holds. The spaces where it holds are called complete, and they are where equations get solved. The method is to start with any guess, improve it by a rule that brings every pair of points closer together by a fixed factor, and let the sequence of guesses run. The guesses bunch, completeness gives them somewhere to land, and the landing point solves the equation.

Before you start

4.1: metric space, open ball, closed set and the sup metric. 1.2: the Cauchy criterion. 1.6: uniform convergence and the geometric series.

Quick checkWhich sequence of rational numbers has terms that bunch together (is Cauchy) but has no limit in Q\mathbb Q?
Quick checkIn the sup metric on C[0,1]C[0, 1], what does d(f,g)<0.1d(f, g) < 0.1 say about the graphs?
Quick checkFor 0≤q<10 \le q < 1, what is 1+q+q2+q3+⋯1 + q + q^2 + q^3 + \cdots?

The picture: the staircase that closes in

We want a number xx with cos⁡x=x\cos x = x. Nobody has a formula, but here is a method: start anywhere, press the cosine key on a calculator, and press it again on the answer, over and over. The picture shows what happens. The curve is y=cos⁡xy = \cos x and the dashed line is y=xy = x. A solution is a point where they cross. Going up or down from the dashed line to the curve applies the map. Going sideways back to the dashed line copies the output into the next input. The red and green segments form a staircase (a cobweb) that closes in on the crossing point. Three things to do:

  1. Run the cosine preset from several starting points. The staircase always lands on the same point, x∗≈0.7390851x^* \approx 0.7390851.
  2. Switch to “Newton for x² − 2”. The curve is almost flat where it crosses the line, and the path lands on 2\sqrt 2 in two or three rounds.
  3. Switch to “−1.5x + 1.25”. There is still a crossing, but the staircase spirals outward. The map pushes points apart instead of together. The difference between the two behaviours is whether the slope at the crossing has size below 11.
nnxnx_nerror ∣xn−x∗∣\lvert x_n - x^*\rvert
00110.26090.2609
110.54030.54030.19880.1988
220.85760.85760.11850.1185
330.65430.65430.08480.0848
550.70140.70140.03770.0377
10100.74420.74420.00520.0052

The error drops by a factor of about 0.670.67 per step, which is the size of the slope of the cosine curve at the crossing, ∣sin⁡0.739∣≈0.674\lvert \sin 0.739 \rvert \approx 0.674.

Where this came from· Picard's iteration, Banach's abstraction

Émile Picard’s memoir of 1890 on partial differential equations used the method of successive approximations: to solve an equation, start from a guess, plug it into the right-hand side to get a better guess, and repeat. In 1893 he applied the same method to ordinary differential equations and showed that the guesses converge. Stefan Banach’s doctoral work in Lwów (written around 1920, published in 1922 in Fundamenta Mathematicae, volume 3, under the title Sur les opérations dans les ensembles abstraits et leur application aux équations intégrales) set the idea in abstract spaces and proved the fixed point theorem of this chapter. The abstract version isolates exactly what the iteration needs: a space where bunching sequences have limits, and a map that shrinks every distance by a fixed factor. Picard’s theorem for differential equations and the theorems for integral equations became applications of one result, which is why it carries Banach’s name.

The idea, in words

Three ideas, each one a line in the picture.

Why· Convergence, completeness, contraction
  1. Convergence in a metric space is the game of 1.2 with the distance dd in place of ∣x−y∣|x - y|: xn→xx_n \to x means d(xn,x)d(x_n, x) goes to 00.
  2. Completeness says there are no holes. If the terms of a sequence bunch together, there is a point at the place where they are bunching. R\mathbb R has this; Q\mathbb Q does not (the truncations of 2\sqrt 2 bunch at a hole), and neither does (0,1](0, 1] (the sequence 1n\frac1n bunches at 00, which is not in the space).
  3. A contraction is a map TT with d(Tx,Ty)≤q d(x,y)d(Tx, Ty) \le q\,d(x, y) for a fixed q<1q < 1: it brings every pair of points closer together by the same factor. Applying it again and again, the steps d(xn+1,xn)d(x_{n+1}, x_n) shrink geometrically, so their sum is finite and the sequence bunches. Completeness provides the limit, and the limit is fixed by TT because TT is continuous. Two different fixed points are impossible, because a contraction would bring them closer together, yet each stays put.

Definitions and theorems: convergence

Definition B

Convergent sequence in a metric space

Let (xn)(x_n) be a sequence of points in a metric space (X,d)(X, d). It converges to x∈Xx \in X, written xn→xx_n \to x, if

∀ε>0  ∃N  ∀n>N:d(xn,x)<ε.\forall \varepsilon > 0\ \ \exists N\ \ \forall n > N:\quad d(x_n, x) < \varepsilon.

Equivalently, every open ball B(x,ε)B(x, \varepsilon) contains all but finitely many terms. For X=RX = \mathbb R with d=∣x−y∣d = |x - y| this is the definition of 1.2.

In one linexn→xx_n \to x if the distance d(xn,x)d(x_n, x) tends to 00: for every ε>0\varepsilon > 0, all terms after some index lie in the ball B(x,ε)B(x, \varepsilon).

Why it existsIt is the ε\varepsilon-NN game of 1.2 with the distance of the space in place of ∣an−L∣|a_n - L|, so every theorem about limits can be re-proved with only (M1) to (M3).

Theorem B Rudin ch. 3; Abbott Sec. 2.2

Limits in a metric space are unique

If xn→xx_n \to x and xn→yx_n \to y in a metric space, then x=yx = y.

In one lineA sequence in a metric space converges to at most one point.

Why it is trueGive each limit half the budget: eventually the terms are within ε/2\varepsilon/2 of both, so the two limits are within ε\varepsilon of each other, and (M1) turns 'within every ε\varepsilon' into 'equal'.

ProofAbbott Sec. 2.2
The idea: The same ε/2 proof as in 1.2, using only (M1) to (M3).
Let ε>0\varepsilon > 0.
Arbitrary tolerance.
Choose NN with d(xn,x)<ε2d(x_n, x) < \frac\varepsilon2 and d(xn,y)<ε2d(x_n, y) < \frac\varepsilon2 for n>Nn > N.
Convergence to xx and to yy, each with tolerance ε/2\varepsilon/2; take the later of the two starting indices.
For such nn: d(x,y)≤d(x,xn)+d(xn,y)<εd(x, y) \le d(x, x_n) + d(x_n, y) < \varepsilon.
(M3) through xnx_n, and (M2) to turn d(x,xn)d(x, x_n) into d(xn,x)d(x_n, x).
So d(x,y)=0d(x, y) = 0 and x=yx = y. ■\blacksquare
A non-negative number below every positive ε\varepsilon is 00, and (M1): d(x,y)=0d(x, y) = 0 means x=yx = y.
Theorem B standard; Apostol Sec. 8.4

Convergence in R^n is coordinatewise

Let x(k)=(x1(k),…,xn(k))∈Rnx^{(k)} = (x^{(k)}_1, \dots, x^{(k)}_n) \in \mathbb R^n and x=(x1,…,xn)x = (x_1, \dots, x_n). Then x(k)→xx^{(k)} \to x in d1d_1, or in d2d_2, or in d∞d_\infty, if and only if xi(k)→xix^{(k)}_i \to x_i for every ii.

In one lineA sequence of vectors converges in Rn\mathbb R^n (for any of the 1-, 2- or max-distances) if and only if each coordinate converges as a sequence of real numbers.

Why it is trueBy the comparison theorem of 4.1 the three norms are within factors of nn of each other and of the size of any single coordinate, so 'the vector is within ε\varepsilon' and 'every coordinate is within about ε\varepsilon' are the same statement.

Proofstandard
The idea: Sandwich each coordinate gap between norms: one coordinate is at most the max-norm, which is at most the 2-norm, at most the 1-norm; and the 1-norm is at most n times the max-norm.
For every ii: ∣xi(k)−xi∣≤∥x(k)−x∥∞≤∥x(k)−x∥2≤∥x(k)−x∥1\lvert x^{(k)}_i - x_i \rvert \le \lVert x^{(k)} - x \rVert_\infty \le \lVert x^{(k)} - x \rVert_2 \le \lVert x^{(k)} - x \rVert_1.
By the comparison theorem of 4.1 (the 1-, 2- and max-norms), applied to the vector x(k)−xx^{(k)} - x.
(⇒\Rightarrow) If x(k)→xx^{(k)} \to x in one of the three distances, every coordinate converges.
Each coordinate gap is at most each of the three norms, by the chain. If one of those three tends to 00 (whichever distance we assumed), the coordinate gap, which is non-negative and below it, is squeezed to 00.
(⇐\Leftarrow) Let ε>0\varepsilon > 0. There is NN with ∣xi(k)−xi∣<εn\lvert x^{(k)}_i - x_i \rvert < \frac\varepsilon n for all ii and all k>Nk > N.
Each coordinate converges, so each has its own starting index for tolerance ε/n\varepsilon/n; take the largest of the nn indices.
So ∥x(k)−x∥∞≤∥x(k)−x∥2≤∥x(k)−x∥1<ε\lVert x^{(k)} - x \rVert_\infty \le \lVert x^{(k)} - x \rVert_2 \le \lVert x^{(k)} - x \rVert_1 < \varepsilon. All three distances are below ε\varepsilon. ■\blacksquare
For such kk, ∥x(k)−x∥∞<εn\lVert x^{(k)} - x \rVert_\infty < \frac\varepsilon n. Then ∥⋅∥1≤n ∥⋅∥∞\lVert \cdot \rVert_1 \le n\,\lVert \cdot \rVert_\infty from 4.1, and ∥⋅∥∞≤∥⋅∥2≤∥⋅∥1\lVert \cdot \rVert_\infty \le \lVert \cdot \rVert_2 \le \lVert \cdot \rVert_1.
Theorem B Rudin ch. 7; Abbott Sec. 6.2

Convergence in the sup metric is uniform convergence

Let fn,f∈C[a,b]f_n, f \in C[a, b]. Then fn→ff_n \to f in the sup metric if and only if fn→ff_n \to f uniformly on [a,b][a, b].

In one lineFor continuous fnf_n and ff on [a,b][a, b]: d∞(fn,f)→0d_\infty(f_n, f) \to 0 if and only if fn→ff_n \to f uniformly on [a,b][a, b].

Why it is trueThe sup metric is the largest vertical gap, and 'the largest gap is below ε\varepsilon' says the same as 'every gap is below ε\varepsilon'. The NN that works for all xx at once is the NN that makes the largest gap small.

ProofAbbott Sec. 6.2
The idea: Unpack both definitions side by side. They differ only by 'max of the gap is below ε' versus 'every gap is below ε', and these are equivalent because the maximum is one of the gaps.
Sup metric: ∀ε ∃N ∀n>N: max⁡x∈[a,b]∣fn(x)−f(x)∣<ε\forall \varepsilon\ \exists N\ \forall n > N:\ \max_{x \in [a, b]} \lvert f_n(x) - f(x) \rvert < \varepsilon.
The definition of convergence in a metric space, with d∞(fn,f)=max⁡x∣fn(x)−f(x)∣d_\infty(f_n, f) = \max_x \lvert f_n(x) - f(x) \rvert.
Uniform: ∀ε ∃N ∀n>N ∀x∈[a,b]: ∣fn(x)−f(x)∣<ε\forall \varepsilon\ \exists N\ \forall n > N\ \forall x \in [a, b]:\ \lvert f_n(x) - f(x) \rvert < \varepsilon.
The definition of uniform convergence in 1.6: one NN for all xx at once.
So the first implies the second for the same NN.
If the maximum of the gaps is below ε\varepsilon, every gap is, since each is at most the maximum.
If every gap is below ε\varepsilon, the maximum is a gap, so it is below ε\varepsilon. Hence the second implies the first. ■\blacksquare
The maximum is attained at some point (extreme value theorem, 1.3), and at that point the gap is below ε\varepsilon.

In the picture of 1.6, the open ball B(f,ε)B(f, \varepsilon) in the sup metric is the tube of half-height ε\varepsilon around the graph of ff: a function gg is in the ball exactly when its whole graph fits in the tube. Convergence in the sup metric is the graphs fnf_n fitting into every tube eventually.

Theorem B Rudin ch. 3; Abbott Sec. 3.2

Closed sets and limits of sequences

In a metric space: (a) x∈A‾x \in \overline A iff there are points an∈Aa_n \in A with an→xa_n \to x. (b) AA is closed iff (an∈Aa_n \in A and an→xa_n \to x imply x∈Ax \in A).

In one lineA point lies in the closure of AA if and only if some sequence in AA converges to it. Hence AA is closed if and only if the limit of every convergent sequence of points of AA lies in AA.

Why it is trueA point in the closure has a point of AA in each ball B(x,1n)B(x, \frac1n), and those points converge to xx; conversely a sequence in AA tending to xx puts points of AA in every ball around xx.

ProofAbbott Sec. 3.2
The idea: (a) Choose a_n in the ball of radius 1/n, for the forward direction; use a ball containing late terms for the backward. (b) A closed iff A equals its closure, and (a) describes the closure.
(a, ⇒\Rightarrow) Let x∈A‾x \in \overline A. For each nn, pick an∈A∩B(x,1n)a_n \in A \cap B(x, \frac1n).
By the definition of the closure in 4.1, every ball around xx meets AA.
Then an→xa_n \to x.
d(an,x)<1n→0d(a_n, x) < \frac1n \to 0.
(a, ⇐\Leftarrow) If an∈Aa_n \in A and an→xa_n \to x, every ball B(x,r)B(x, r) contains some an∈Aa_n \in A, so x∈A‾x \in \overline A.
Convergence: given r>0r > 0, all late terms are in B(x,r)B(x, r), and they are points of AA.
(b) AA is closed iff A‾⊆A\overline A \subseteq A iff every limit of a sequence in AA is in AA, by (a). ■\blacksquare
The theorem on interior, closure and boundary in 4.1, part (b): AA is closed iff A=A‾A = \overline A, and always A⊆A‾A \subseteq \overline A.

Definitions and theorems: Cauchy sequences and completeness

Definition B

Cauchy sequence in a metric space

A sequence (xn)(x_n) in a metric space is Cauchy if ∀ε>0 ∃N ∀m,n>N: d(xm,xn)<ε\forall \varepsilon > 0\ \exists N\ \forall m, n > N:\ d(x_m, x_n) < \varepsilon. (For R\mathbb R this is the Cauchy sequence of 1.2.)

In one lineA sequence whose terms eventually stay close to each other: for every ε>0\varepsilon > 0 there is NN with d(xm,xn)<εd(x_m, x_n) < \varepsilon for all m,n>Nm, n > N.

Why it existsIt describes bunching without naming a limit, so we can prove a limit exists when we cannot find it.

Theorem B Rudin Thm 3.11(a)

Convergent sequences are Cauchy

Every convergent sequence in a metric space is a Cauchy sequence.

In one lineIf xn→xx_n \to x in a metric space, then (xn)(x_n) is Cauchy.

Why it is trueTerms close to xx are close to each other: split d(xm,xn)d(x_m, x_n) through xx with ε/2\varepsilon/2 each.

ProofRudin 3.11
The idea: Triangle inequality through the limit.
Let ε>0\varepsilon > 0 and choose NN with d(xn,x)<ε2d(x_n, x) < \frac\varepsilon2 for n>Nn > N.
Arbitrary tolerance, and half of it for each term.
For m,n>Nm, n > N: d(xm,xn)≤d(xm,x)+d(x,xn)<ε2+ε2=εd(x_m, x_n) \le d(x_m, x) + d(x, x_n) < \frac\varepsilon2 + \frac\varepsilon2 = \varepsilon. ■\blacksquare
(M3) and (M2).

The converse is what fails in some spaces and holds in others, and that difference is the next definition.

Definition B

Complete metric space

A metric space XX is complete if every Cauchy sequence in XX converges to a point of XX.

In one lineA metric space in which every Cauchy sequence converges to a point of the space.

Why it existsIt is the 'no holes' property. It lets us construct solutions as limits of approximations without knowing the solution in advance.

Worked example
Decide whether each space is complete: R\mathbb R, Q\mathbb Q, (0,1](0, 1], [0,1][0, 1], and a set with the discrete metric.

Solution.

  1. R\mathbb R is complete. Every Cauchy sequence of reals converges. That is the Cauchy criterion of 1.2, which rests on the completeness axiom of 1.1.
  2. Q\mathbb Q is not. The truncations 1,1.4,1.41,1.414,…1, 1.4, 1.41, 1.414, \dots of 2\sqrt 2 are rational and Cauchy, but their only limit in R\mathbb R is 2∉Q\sqrt 2 \notin \mathbb Q, and limits are unique. The Cauchy sequence bunches at a hole of Q\mathbb Q, which we know by uniqueness of limits.
  3. (0,1](0, 1] is not. The sequence xn=1nx_n = \frac1n is Cauchy (it converges in R\mathbb R), but its limit 00 is not in (0,1](0, 1]. The point missing from the space is the endpoint 00. No point of (0,1](0, 1] can serve as a limit, since the limit in R\mathbb R is unique.
  4. [0,1][0, 1] is complete. A Cauchy sequence in [0,1][0, 1] converges in R\mathbb R to some xx, and 0≤xn≤10 \le x_n \le 1 passes to the limit, so x∈[0,1]x \in [0, 1]. Closed subsets keep their limits. This is the idea of the theorem on closed subsets below.
  5. A set with the discrete metric is complete. For ε=12\varepsilon = \frac12, d(xm,xn)<12d(x_m, x_n) < \frac12 forces d(xm,xn)=0d(x_m, x_n) = 0, that is, xm=xnx_m = x_n, for all m,n>Nm, n > N. So a Cauchy sequence is constant from some point, and it converges to that constant. The metric takes only the values 00 and 11, so “close” means “equal”.

Answer. Complete: R\mathbb R, [0,1][0, 1], discrete spaces. Not complete: Q\mathbb Q, (0,1](0, 1]. ■\blacksquare

Quick checkWhich of these is a complete metric space with the usual distance ∣x−y∣|x - y|?
Theorem B Rudin Thm 3.11(c); Apostol Sec. 8.4

R^n is complete

Every Cauchy sequence in Rn\mathbb R^n (with d1d_1, d2d_2 or d∞d_\infty) converges.

In one lineRn\mathbb R^n with the 1-, 2- or max-distance is complete.

Why it is trueA Cauchy sequence of vectors has Cauchy coordinates, each coordinate sequence converges in the complete line R\mathbb R, and convergence is coordinatewise.

ProofRudin 3.11
The idea: Cauchy in the vector implies Cauchy in each coordinate (a coordinate gap is at most the norm), so each coordinate converges by completeness of R, and then the vector converges by the coordinatewise theorem.
Let (x(k))(x^{(k)}) be Cauchy. Then, for each coordinate ii, the real sequence (xi(k))k(x^{(k)}_i)_k is Cauchy.
The first link of the chain in the coordinatewise proof: ∣xi(k)−xi(l)∣≤∥x(k)−x(l)∥∞≤∥x(k)−x(l)∥2≤∥x(k)−x(l)∥1\lvert x^{(k)}_i - x^{(l)}_i \rvert \le \lVert x^{(k)} - x^{(l)} \rVert_\infty \le \lVert x^{(k)} - x^{(l)} \rVert_2 \le \lVert x^{(k)} - x^{(l)} \rVert_1.
So xi(k)→xix^{(k)}_i \to x_i for some real number xix_i, for each ii.
R\mathbb R is complete (1.2).
Put x=(x1,…,xn)x = (x_1, \dots, x_n). Then x(k)→xx^{(k)} \to x in the vector distance. ■\blacksquare
The theorem that convergence in R^n is coordinatewise, proved above.

The space of continuous functions is complete

This is the theorem where 1.6 and this unit meet. A Cauchy sequence of continuous functions is a sequence of graphs that bunch together in the tube sense. We must produce a limit function that is itself continuous.

Theorem B Rudin ch. 7; Abbott Sec. 6.2

C[a, b] with the sup metric is complete

The metric space C[a,b]C[a, b] with d∞(f,g)=max⁡[a,b]∣f−g∣d_\infty(f, g) = \max_{[a, b]} \lvert f - g \rvert is complete.

In one lineEvery Cauchy sequence of continuous functions on [a,b][a, b], in the sup metric, converges uniformly to a continuous function.

Why it is trueFix xx: the numbers fn(x)f_n(x) are a Cauchy sequence of reals, so they converge. That defines a limit function. The Cauchy condition gives the same NN for every xx, so the convergence is uniform, and a uniform limit of continuous functions is continuous.

ProofRudin ch. 7
The idea: Build the limit function point by point using completeness of R, show the convergence is uniform because the Cauchy N does not depend on x, and then show the limit is continuous with the 3-epsilon argument (the theorem of 1.6, written out again here).
Let (fn)(f_n) be a Cauchy sequence in C[a,b]C[a, b] for d∞d_\infty.
By hypothesis: ∀ε ∃N ∀m,n>N: max⁡x∣fn(x)−fm(x)∣<ε\forall \varepsilon\ \exists N\ \forall m, n > N:\ \max_x \lvert f_n(x) - f_m(x) \rvert < \varepsilon.
Fix x∈[a,b]x \in [a, b]. The real sequence (fn(x))n(f_n(x))_n is Cauchy.
For one fixed xx, ∣fn(x)−fm(x)∣≤d∞(fn,fm)\lvert f_n(x) - f_m(x) \rvert \le d_\infty(f_n, f_m), because the maximum is at least the value at xx.Where the idea comes from: evaluate at a point, and the sup metric becomes a plain distance in R.
So it converges. Define f(x)=lim⁡nfn(x)f(x) = \lim_n f_n(x) for each x∈[a,b]x \in [a, b]. This is the pointwise limit, a function on [a,b][a, b] that we do not yet know is continuous.
R\mathbb R is complete (1.2, Cauchy criterion).
Let ε>0\varepsilon > 0 and choose NN with d∞(fn,fm)<ε2d_\infty(f_n, f_m) < \frac\varepsilon2 for all m,n>Nm, n > N.
Arbitrary tolerance; use half of it for the Cauchy condition.
For all x∈[a,b]x \in [a, b] and all n>Nn > N: ∣fn(x)−f(x)∣≤ε2<ε\lvert f_n(x) - f(x) \rvert \le \frac\varepsilon2 < \varepsilon.
Fix any xx and any n>Nn > N. For every m>Nm > N, ∣fn(x)−fm(x)∣<ε2\lvert f_n(x) - f_m(x) \rvert < \frac\varepsilon2. Let m→∞m \to \infty: fm(x)→f(x)f_m(x) \to f(x), and a bound that holds along a convergent sequence holds in the limit, in the non-strict form.This is the key step: N was chosen before x, so the same N serves every point.
So fn→ff_n \to f uniformly on [a,b][a, b].
This is the definition of uniform convergence in 1.6: one NN for all xx at once.
Let c∈[a,b]c \in [a, b] and ε>0\varepsilon > 0. By uniform convergence, pick one index nn with ∣fn(x)−f(x)∣<ε3|f_n(x) - f(x)| < \frac\varepsilon3 for every x∈[a,b]x \in [a, b].
We must show the pointwise limit ff is continuous at an arbitrary point c∈[a,b]c \in [a, b]: for every ε\varepsilon a δ\delta with ∣f(x)−f(c)∣<ε|f(x) - f(c)| < \varepsilon when ∣x−c∣<δ|x - c| < \delta. We have no formula for ff, so we compare it with a function we do understand, one fnf_n.This is the 3-epsilon argument, the same one as in the theorem of 1.6 that a uniform limit of continuous functions is continuous.
Choose δ>0\delta > 0 with ∣fn(x)−fn(c)∣<ε3|f_n(x) - f_n(c)| < \frac\varepsilon3 whenever ∣x−c∣<δ|x - c| < \delta.
fnf_n is continuous at cc (it is in C[a,b]C[a, b]), so there is δ>0\delta > 0 that keeps fn(x)f_n(x) within ε3\frac\varepsilon3 of fn(c)f_n(c).
For ∣x−c∣<δ|x - c| < \delta: ∣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)| < \frac\varepsilon3 + \frac\varepsilon3 + \frac\varepsilon3 = \varepsilon.
Go from f(x)f(x) to f(c)f(c) by way of fn(x)f_n(x) and fn(c)f_n(c): three pieces, each below ε3\frac\varepsilon3. The two outer pieces are the uniform estimate, used at the two points xx and cc with the same nn. The middle piece is the continuity of fnf_n.The uniformity matters: the same nn works at both xx and cc. With only pointwise convergence the nn needed at xx could be different from the one needed at cc, and the argument fails.
Therefore ff is continuous, so f∈C[a,b]f \in C[a, b].
cc was arbitrary, so ff is continuous at every point of [a,b][a, b].
Hence fn→ff_n \to f in d∞d_\infty, and the Cauchy sequence converges in C[a,b]C[a, b]. ■\blacksquare
The theorem above that convergence in the sup metric is uniform convergence: uniform convergence of continuous functions is convergence in d∞d_\infty.

In the picture: the graphs fnf_n and fmf_m for large n,mn, m lie in a tube around each other; at each xx the values fn(x)f_n(x) pile up at a number, which we call f(x)f(x); and the tube around ff then contains fnf_n for large nn. The tube of the visualizer above is that tube.

Proof workshopRebuild the proof that C[a, b] is complete

Each line of the proof is shown in order. Choose the reason that justifies it, then press Check.

  1. Let (fn)(f_n) be Cauchy in d∞d_\infty. For each fixed xx, (fn(x))(f_n(x)) is a Cauchy sequence of real numbers.
  2. So fn(x)f_n(x) converges. Define f(x)=lim⁡fn(x)f(x) = \lim f_n(x).
  3. Given ε\varepsilon, choose NN with d∞(fn,fm)<ε/2d_\infty(f_n, f_m) < \varepsilon/2 for m,n>Nm, n > N.
  4. For every xx and n>Nn > N: ∣fn(x)−f(x)∣≤ε/2\lvert f_n(x) - f(x) \rvert \le \varepsilon/2.
  5. So fn→ff_n \to f uniformly on [a,b][a, b].
  6. Fix cc and ε\varepsilon. Pick nn with ∣fn−f∣<ε/3|f_n - f| < \varepsilon/3 everywhere, then δ\delta with ∣fn(x)−fn(c)∣<ε/3|f_n(x) - f_n(c)| < \varepsilon/3 for ∣x−c∣<δ|x - c| < \delta. Then ∣f(x)−f(c)∣<ε|f(x) - f(c)| < \varepsilon.
  7. So ff is continuous at every cc.
  8. Hence f∈C[a,b]f \in C[a, b] and d∞(fn,f)→0d_\infty(f_n, f) \to 0.
Theorem B standard

Closed subsets of complete spaces are complete

Let XX be a complete metric space and A⊆XA \subseteq X, with the distance of XX. Then AA is complete if and only if AA is closed in XX.

In one lineInside a complete space, a subset with the same distance is complete if and only if it is closed.

Why it is trueA Cauchy sequence in the subset has a limit in the big space; being closed keeps that limit in the subset. Conversely, a subset that is complete already contains the limit of any sequence of its points that converges in the big space.

Proofstandard
The idea: (⇐) A Cauchy sequence in A is Cauchy in X, so it converges to some x in X, and closedness puts x in A. (⇒) A convergent sequence of points of A is Cauchy, so it has a limit inside A, and limits are unique.
(⇐\Leftarrow) Let AA be closed and (an)(a_n) a Cauchy sequence in AA. It is Cauchy in XX.
The distance is the same, so the Cauchy condition does not change.
So an→xa_n \to x for some x∈Xx \in X.
XX is complete.
Since AA is closed, x∈Ax \in A. So AA is complete.
The theorem above on closed sets and limits of sequences, part (b).
(⇒\Rightarrow) Let AA be complete and an∈Aa_n \in A with an→x∈Xa_n \to x \in X. Then (an)(a_n) is Cauchy.
Convergent sequences are Cauchy.
So an→a∈Aa_n \to a \in A, and a=xa = x. Hence x∈Ax \in A, and AA is closed by the same theorem. ■\blacksquare
AA is complete, so an→aa_n \to a for some a∈Aa \in A. Limits are unique in XX.
Worked example
Show that the set Δ\Delta of probability vectors in Rn\mathbb R^n (entries ≥0\ge 0 adding to 11) is complete.

Solution.

  1. Rn\mathbb R^n is complete. With the 1-distance, say. The theorem above, which holds for each of the three distances.
  2. Δ\Delta is closed. Let x(k)∈Δx^{(k)} \in \Delta with x(k)→xx^{(k)} \to x. By the coordinatewise theorem, each xi(k)→xix^{(k)}_i \to x_i. Each xi(k)≥0x^{(k)}_i \ge 0, so xi≥0x_i \ge 0 (limits preserve non-strict inequalities). And ∑ixi(k)=1\sum_i x^{(k)}_i = 1, so ∑ixi=1\sum_i x_i = 1 by the sum law of 1.2. Closed means limits of sequences in the set stay in the set. Inequalities with "≥\ge" and equations survive limits.
  3. Apply the closed-subset theorem. Δ\Delta is closed in a complete space, hence complete. This is the space on which PageRank is iterated, as we see below.

Answer. Δ\Delta is complete. The same argument shows any set defined by non-strict inequalities and equations on coordinates is complete. ■\blacksquare

Quick checkIn the proof that C[a,b]C[a, b] is complete, what does the sup metric give us that makes the limit function continuous?

Definitions and theorems: contractions

Definition B

Contraction

A map T:X→XT : X \to X from a metric space to itself is a contraction if there is a number qq with 0≤q<10 \le q < 1 such that

d(Tx,Ty)≤q d(x,y)for all x,y∈X.d(Tx, Ty) \le q\,d(x, y) \qquad \text{for all } x, y \in X.

The number qq is a contraction constant. It must be the same for all pairs, and it must be less than 11.

In one lineA map T:X→XT : X \to X that brings every pair of points closer together by a fixed factor q<1q < 1: d(Tx,Ty)≤q d(x,y)d(Tx, Ty) \le q\,d(x, y).

Why it existsIt is the map whose repeated application squeezes the whole space, which is what makes iteration converge.

Definition B

Fixed point

A fixed point of T:X→XT : X \to X is a point x∗∈Xx^* \in X with Tx∗=x∗T x^* = x^*. In the cobweb picture it is a point where the curve y=T(x)y = T(x) crosses the line y=xy = x.

In one lineA point x∗x^* that TT leaves where it is: Tx∗=x∗T x^* = x^*.

Why it existsSolving an equation x=T(x)x = T(x) is the same as finding a fixed point of TT. Many equations can be put in that form.

Worked example
Which of these are contractions of R\mathbb R? T1(x)=x3+5T_1(x) = \frac x3 + 5, T2(x)=2xT_2(x) = 2x, T3(x)=sin⁡xT_3(x) = \sin x, T4(x)=∣x∣2T_4(x) = \frac{\lvert x \rvert}{2}.

Solution. For each map, compute ∣Tx−Ty∣\lvert Tx - Ty \rvert in terms of ∣x−y∣\lvert x - y \rvert.

  1. T1T_1. ∣T1x−T1y∣=13∣x−y∣\lvert T_1x - T_1y \rvert = \frac13\lvert x - y \rvert. The constant 55 cancels. So T1T_1 is a contraction with q=13q = \frac13. The fixed point solves x=x3+5x = \frac x3 + 5, giving x∗=7.5x^* = 7.5.
  2. T2T_2. ∣T2x−T2y∣=2∣x−y∣\lvert T_2x - T_2y \rvert = 2\lvert x - y \rvert. The factor is 22, which is not below 11: it expands. Not a contraction.
  3. T3T_3. For xx and yy close to 00, sin⁡x−sin⁡y≈x−y\sin x - \sin y \approx x - y, so the ratio ∣sin⁡x−sin⁡y∣∣x−y∣\frac{\lvert \sin x - \sin y \rvert}{\lvert x - y \rvert} gets arbitrarily close to 11. No q<1q < 1 works for all pairs. The mean value theorem gives ratio ∣cos⁡c∣\lvert \cos c \rvert for some cc between xx and yy, whose supremum over cc is 11. So T3T_3 shrinks distances but not by a uniform factor, so it is not a contraction on R\mathbb R.
  4. T4T_4. By the reverse triangle inequality (the worked example in 4.1, with z=0z = 0), ∣∣x∣−∣y∣∣≤∣x−y∣\lvert \lvert x \rvert - \lvert y \rvert \rvert \le \lvert x - y \rvert, so ∣T4x−T4y∣≤12∣x−y∣\lvert T_4x - T_4y \rvert \le \frac12\lvert x - y \rvert. Absolute value does not expand distances, and the factor 12\frac12 does the rest. So q=12q = \frac12, and the fixed point is 00.

Answer. T1T_1 and T4T_4 are contractions; T2T_2 and T3T_3 are not. ■\blacksquare

When a map is differentiable, a bound on the slope settles it. This is the mean value theorem of 1.4 at work.

Theorem B standard (mean value theorem)

Derivative test for a contraction

Let II be an interval, g:I→Rg : I \to \mathbb R differentiable with ∣g′(x)∣≤q\lvert g'(x) \rvert \le q for all x∈Ix \in I, where q<1q < 1. Then ∣g(x)−g(y)∣≤q ∣x−y∣\lvert g(x) - g(y) \rvert \le q\,\lvert x - y \rvert for all x,y∈Ix, y \in I. If also g(I)⊆Ig(I) \subseteq I and II is closed, gg is a contraction of the complete space II.

In one lineIf gg is differentiable on an interval II and ∣g′(x)∣≤q<1\lvert g'(x) \rvert \le q < 1 for every x∈Ix \in I, then ∣g(x)−g(y)∣≤q∣x−y∣\lvert g(x) - g(y) \rvert \le q\lvert x - y \rvert for all x,y∈Ix, y \in I.

Why it is trueBetween two points the mean value theorem says the average slope equals the derivative somewhere in between, and that derivative has size at most qq.

Proofstandard
The idea: The mean value theorem turns the difference g(x) − g(y) into g'(c)(x − y), and |g'(c)| ≤ q.
Let x≠yx \ne y in II. There is cc between xx and yy with g(x)−g(y)=g′(c) (x−y)g(x) - g(y) = g'(c)\,(x - y).
Nothing to prove for x=yx = y. Otherwise the mean value theorem (1.4) applies on the interval between them, inside II, where gg is differentiable.
So ∣g(x)−g(y)∣=∣g′(c)∣ ∣x−y∣≤q ∣x−y∣\lvert g(x) - g(y) \rvert = \lvert g'(c) \rvert\,\lvert x - y \rvert \le q\,\lvert x - y \rvert. ■\blacksquare
c∈Ic \in I, where ∣g′∣≤q\lvert g' \rvert \le q.

(A closed interval II is a closed subset of the complete space R\mathbb R, so it is complete by the closed-subset theorem. This is why the derivative test comes with ”g(I)⊆Ig(I) \subseteq I and II closed”.)

Quick checkIs T(x)=x+1xT(x) = x + \dfrac1x on [1,∞)[1, \infty) a contraction? (It satisfies ∣Tx−Ty∣<∣x−y∣\lvert Tx - Ty \rvert < \lvert x - y \rvert whenever x≠yx \ne y.)

The Banach fixed point theorem

Theorem B Banach 1922; Rudin ch. 9

Banach fixed point theorem

Let (X,d)(X, d) be a non-empty complete metric space and T:X→XT : X \to X a contraction with constant qq, 0≤q<10 \le q < 1. Then:

(a) TT has exactly one fixed point x∗x^*.

(b) For every x0∈Xx_0 \in X, the sequence xn+1=Txnx_{n+1} = T x_n converges to x∗x^*.

(c) A priori bound: d(xn,x∗)≤qn1−q d(x1,x0)d(x_n, x^*) \le \dfrac{q^n}{1 - q}\,d(x_1, x_0) for every n≥0n \ge 0.

(d) A posteriori bound: d(xn,x∗)≤q1−q d(xn,xn−1)d(x_n, x^*) \le \dfrac{q}{1 - q}\,d(x_n, x_{n-1}) for every n≥1n \ge 1.

In one lineA contraction TT of a non-empty complete metric space has exactly one fixed point x∗x^*; from any start x0x_0 the iterates xn+1=Txnx_{n+1} = T x_n converge to x∗x^*, with d(xn,x∗)≤qn1−q d(x1,x0)d(x_n, x^*) \le \dfrac{q^n}{1 - q}\,d(x_1, x_0).

Why it is trueThe steps d(xn+1,xn)d(x_{n+1}, x_n) shrink by the factor qq each time, so the total distance still to travel is a geometric series. That makes the sequence Cauchy; completeness gives the limit; continuity of TT makes it fixed; and two fixed points would be pulled together, which is impossible.

ProofRudin ch. 9; Banach 1922
The idea: Step 1: each step is at most q times the previous, so steps shrink geometrically. Step 2: add the steps from n on with the triangle inequality; the geometric sum is finite and small, so the sequence is Cauchy. Step 3: completeness gives a limit. Step 4: the limit is fixed. Step 5: uniqueness by pulling two fixed points together. Steps 6 and 7: let m go to infinity in the Step 2 bound.
Let x0∈Xx_0 \in X and xn+1=Txnx_{n+1} = T x_n. Then d(xn+1,xn)=d(Txn,Txn−1)≤q d(xn,xn−1)d(x_{n+1}, x_n) = d(T x_n, T x_{n-1}) \le q\,d(x_n, x_{n-1}).
Pick any starting point and define the iterates. Apply the contraction inequality with x=xnx = x_n and y=xn−1y = x_{n-1}.Where the idea comes from: it is the contractive sequence of 1.2's stretch problem, now in any metric space.
So d(xn+1,xn)≤qn d(x1,x0)d(x_{n+1}, x_n) \le q^n\,d(x_1, x_0) for all n≥0n \ge 0.
Induction on nn: the case n=0n = 0 is an equality, and each step multiplies the bound by qq.
For m>nm > n: d(xm,xn)≤∑k=nm−1d(xk+1,xk)≤d(x1,x0)∑k=nm−1qkd(x_m, x_n) \le \sum_{k=n}^{m-1} d(x_{k+1}, x_k) \le d(x_1, x_0) \sum_{k=n}^{m-1} q^k.
For m>nm > n, the triangle inequality (M3) applied repeatedly along xn,xn+1,…,xmx_n, x_{n+1}, \dots, x_m: the distance is at most the total length of the journey in small steps.The detour through intermediate points is where the triangle inequality is used to the full.
So d(xm,xn)≤qn1−q d(x1,x0)d(x_m, x_n) \le \dfrac{q^n}{1 - q}\,d(x_1, x_0) for all m>nm > n.
The finite geometric sum is below the infinite one: ∑k≥nqk=qn1−q\sum_{k \ge n} q^k = \frac{q^n}{1 - q} (1.6).
The right side tends to 00 as n→∞n \to \infty, so (xn)(x_n) is Cauchy.
qn→0q^n \to 0 because 0≤q<10 \le q < 1 (1.6, geometric sequence). Given ε\varepsilon, choose NN with qN1−q d(x1,x0)<ε\frac{q^N}{1 - q}\,d(x_1, x_0) < \varepsilon; then every m>n>Nm > n > N has d(xm,xn)<εd(x_m, x_n) < \varepsilon.
So xn→x∗x_n \to x^* for some x∗∈Xx^* \in X. This proves (b).
XX is complete: this is the only place the hypothesis is used.No formula for x* is needed. Completeness is what promises that x* is there.
Now d(Tx∗,x∗)≤d(Tx∗,xn+1)+d(xn+1,x∗)≤q d(x∗,xn)+d(xn+1,x∗)d(T x^*, x^*) \le d(T x^*, x_{n+1}) + d(x_{n+1}, x^*) \le q\,d(x^*, x_n) + d(x_{n+1}, x^*).
The contraction inequality with x=x∗x = x^* and y=xny = x_n gives d(Tx∗,xn+1)≤q d(x∗,xn)d(T x^*, x_{n+1}) \le q\,d(x^*, x_n), because xn+1=Txnx_{n+1} = T x_n. This is the proof that a contraction is continuous: if xn→x∗x_n \to x^* then Txn→Tx∗T x_n \to T x^*, since d(Txn,Tx∗)≤q d(xn,x∗)d(T x_n, T x^*) \le q\,d(x_n, x^*).Having a limit is not yet having a fixed point. We must still show that T does not move the limit, and this is the place where T being continuous is used.
So d(Tx∗,x∗)=0d(T x^*, x^*) = 0, that is, Tx∗=x∗T x^* = x^*. This shows a fixed point exists.
Both terms on the right tend to 00 because xn→x∗x_n \to x^*. A non-negative number below every ε\varepsilon is 00, and (M1).
Subtract: (1−q) d(x,y)≤0(1 - q)\,d(x, y) \le 0. Since 1−q>01 - q > 0 and d≥0d \ge 0, d(x,y)=0d(x, y) = 0, so x=yx = y. This proves (a).
Uniqueness. If Tx=xT x = x and Ty=yT y = y, then d(x,y)=d(Tx,Ty)≤q d(x,y)d(x, y) = d(T x, T y) \le q\,d(x, y).
Hence d(x∗,xn)≤qn1−q d(x1,x0)d(x^*, x_n) \le \dfrac{q^n}{1 - q}\,d(x_1, x_0). This proves (c).
For fixed nn, let m→∞m \to \infty in d(xm,xn)≤qn1−q d(x1,x0)d(x_m, x_n) \le \frac{q^n}{1 - q}\,d(x_1, x_0). We have xm→x∗x_m \to x^*, and the reverse triangle inequality gives ∣d(xm,xn)−d(x∗,xn)∣≤d(xm,x∗)→0\lvert d(x_m, x_n) - d(x^*, x_n) \rvert \le d(x_m, x^*) \to 0, so d(xm,xn)→d(x∗,xn)d(x_m, x_n) \to d(x^*, x_n).
Then d(xn,x∗)≤q1−q d(xn,xn−1)d(x_n, x^*) \le \dfrac{q}{1 - q}\,d(x_n, x_{n-1}). This proves (d). ■\blacksquare
Apply (c) to the iteration that starts at xn−1x_{n-1}: its first step is xnx_n, its zeroth is xn−1x_{n-1}, and its limit is the same x∗x^* by uniqueness. Take the exponent 11 in (c).

In the picture: the red and green staircase has steps that shrink by the factor qq at each round. A path with geometrically shrinking steps has finite total length, so it cannot wander forever. It settles at a point, and that point must lie on the diagonal (Tx=xTx = x) because the last step before settling has length 00.

Proof workshopRebuild the proof of the Banach fixed point theorem

Tap the lines in the order a proof would write them. Each line can only use what is already above it.

    Why· Where each hypothesis was used, and what fails without it
    • Completeness (step “so xn→x∗x_n \to x^*”). Without it there can be no fixed point. T(x)=x2T(x) = \frac x2 on X=(0,1]X = (0, 1] is a contraction with q=12q = \frac12, and the iterates 12,14,18,…\frac12, \frac14, \frac18, \dots bunch at 00, a hole. TT has no fixed point in XX.
    • q<1q < 1, uniformly. For T(x)=x+1xT(x) = x + \frac1x on [1,∞)[1, \infty) distances shrink but the factor tends to 11; there is no fixed point although [1,∞)[1, \infty) is complete.
    • TT maps XX into XX. T(x)=x2+1T(x) = \frac x2 + 1 is a contraction of R\mathbb R with fixed point 22, but it sends [0,1][0, 1] out of [0,1][0, 1] (it sends 11 to 1.51.5). Restricted to [0,1][0, 1] the iteration leaves the space, and there is no fixed point in [0,1][0, 1].
    • Non-empty. The theorem says “there is exactly one”, which needs a point to start from.
    Why· The two error bounds are for different jobs

    The a priori bound (c) tells you before you start how many steps you need. Given qq and the first step d(x1,x0)d(x_1, x_0), you can solve qn1−qd(x1,x0)<tolerance\frac{q^n}{1 - q}d(x_1, x_0) < \text{tolerance} for nn. The a posteriori bound (d) says that once you have computed two consecutive iterates, the remaining error is at most q1−q\frac{q}{1 - q} times their gap. That is a safe stopping rule: for q=12q = \frac12, stop when two successive guesses differ by less than the tolerance, because then the error is at most the gap. For qq near 11 the factor q1−q\frac{q}{1-q} is large, and a small gap does not guarantee a small error. The bounds are usually pessimistic, because qq is a worst case over all pairs of points.

    Quick checkIn the Banach fixed point theorem, which step is the ONLY one that uses completeness of XX?
    Quick checkA map has a fixed point x∗x^* and TT has slope −1.5-1.5 there (as in the last preset of the cobweb). What happens to iterates started near x∗x^*?

    Examples: solving equations by iteration

    Worked example
    Solve cos⁡x=x\cos x = x by iteration, with a guaranteed error bound.

    Solution.

    1. Put the equation in the form x=g(x)x = g(x). g(x)=cos⁡xg(x) = \cos x. A solution of cos⁡x=x\cos x = x is exactly a fixed point of gg.
    2. Choose a complete space that gg maps into itself. X=[0,1]X = [0, 1]. On [0,1][0, 1], cos⁡\cos is decreasing, so g([0,1])=[cos⁡1,1]=[0.5403,1]⊆[0,1]g([0, 1]) = [\cos 1, 1] = [0.5403, 1] \subseteq [0, 1]. [0,1][0, 1] is a closed subset of R\mathbb R, hence complete. And gg must map XX into XX, or the iteration could leave the space.
    3. Bound the slope. g′(x)=−sin⁡xg'(x) = -\sin x, and on [0,1][0, 1], sin⁡\sin is increasing, so ∣g′(x)∣≤sin⁡1≈0.8415=:q<1\lvert g'(x) \rvert \le \sin 1 \approx 0.8415 =: q < 1. The derivative test (mean value theorem) turns this into ∣g(x)−g(y)∣≤q∣x−y∣\lvert g(x) - g(y) \rvert \le q\lvert x - y \rvert.
    4. Apply Banach. There is exactly one solution of cos⁡x=x\cos x = x in [0,1][0, 1], and the iterates converge to it from any start in [0,1][0, 1]. There are no other solutions anywhere: if cos⁡x=x\cos x = x then x=cos⁡x∈[−1,1]x = \cos x \in [-1, 1] and cos⁡x>0\cos x > 0 there, so x∈(0,1]x \in (0, 1].
    5. Compute. Start at x0=1x_0 = 1: x1=cos⁡1=0.5403x_1 = \cos 1 = 0.5403, x2=0.8576x_2 = 0.8576, x3=0.6543x_3 = 0.6543, and so on. Here d(x1,x0)=0.4597d(x_1, x_0) = 0.4597. One step to find the number the a priori bound needs.
    6. Number of steps. The bound is qn1−q d(x1,x0)=2.90 (0.8415)n\dfrac{q^n}{1 - q}\,d(x_1, x_0) = 2.90\,(0.8415)^n. For error below 10−610^{-6} we need n≥87n \ge 87. 0.841587×2.90≈8.7×10−70.8415^{87} \times 2.90 \approx 8.7 \times 10^{-7}.
    7. Compare with reality. The error is already below 10−610^{-6} at n=32n = 32. The bound used the worst slope on all of [0,1][0, 1], namely sin⁡1=0.84\sin 1 = 0.84. Near the solution the slope is sin⁡(0.739)=0.674\sin(0.739) = 0.674, so the true rate is 0.6740.674 per step. The bound is a guarantee, not an estimate.

    Answer. The unique solution is x∗≈0.7390851x^* \approx 0.7390851 (the “Dottie number”); 8787 steps are guaranteed to give six correct decimals, and 3232 suffice in practice. ■\blacksquare

    Your answerStarting at x0=1x_0 = 1 and iterating xn+1=cos⁡xnx_{n+1} = \cos x_n (in radians), what is x2x_2? (Three decimals.)
    Your answerFor cos⁡x=x\cos x = x with q=sin⁡1≈0.8415q = \sin 1 \approx 0.8415 and d(x1,x0)≈0.4597d(x_1, x_0) \approx 0.4597, find the smallest nn with qn1−qd(x1,x0)≤10−6\frac{q^n}{1 - q}d(x_1, x_0) \le 10^{-6}.
    Python labFixed-point iteration for cos x = x: the guarantee against the truth
    import math
    
    g = math.cos            # the map: we solve cos(x) = x
    x0 = 1.0                # starting guess
    q = math.sin(1)         # contraction constant of cos on [0, 1]: max |sin x| = sin 1
    
    # find the fixed point to machine accuracy
    xs = [x0]
    for _ in range(200):
        xs.append(g(xs[-1]))
    xstar = xs[-1]
    
    d10 = abs(xs[1] - xs[0])
    print("fixed point x* =", xstar)
    print(" n   x_n        true error   a priori bound")
    for n in [1, 2, 3, 5, 10, 20, 32, 40]:
        err = abs(xs[n] - xstar)
        bound = q**n / (1 - q) * d10
        print(f"{n:2d}  {xs[n]:.7f}  {err:.2e}    {bound:.2e}")
    
    tol = 1e-6
    n_guaranteed = math.ceil(math.log(tol * (1 - q) / d10) / math.log(q))
    n_actual = next(n for n in range(len(xs)) if abs(xs[n] - xstar) < tol)
    print("steps guaranteed by the bound:", n_guaranteed, " steps actually needed:", n_actual)

    Try this. The bound is above the true error in every row, as the theorem promises. Now solve x=e−xx = e^{-x} instead: change the map to g = lambda x: math.exp(-x), the start to x0 = 0.5, and the constant to q = math.exp(-0.4) (valid on [0.4,0.7][0.4, 0.7]), and delete the rows with n above 20. You should see 32 steps guaranteed and 20 actually needed. Which map has the larger gap between guarantee and truth, and why? (The constant qq is the worst slope on the whole interval; the true rate is the slope at the fixed point.)

    Newton’s method is a contraction near a root

    Newton’s method for f(x)=0f(x) = 0 iterates N(x)=x−f(x)f′(x)N(x) = x - \dfrac{f(x)}{f'(x)}. A root rr is a fixed point of NN. Why does it converge so fast?

    Theorem B standard

    Newton's method is a local contraction

    Let ff be twice continuously differentiable near rr with f(r)=0f(r) = 0 and f′(r)≠0f'(r) \ne 0. Then there is δ>0\delta > 0 such that N(x)=x−f(x)/f′(x)N(x) = x - f(x)/f'(x) maps I=[r−δ,r+δ]I = [r - \delta, r + \delta] into II and satisfies ∣N(x)−N(y)∣≤12∣x−y∣\lvert N(x) - N(y) \rvert \le \frac12\lvert x - y \rvert on II. Hence for every x0∈Ix_0 \in I, the Newton iterates converge to rr, and rr is the only root in II.

    In one lineIf ff has a continuous second derivative, f(r)=0f(r) = 0 and f′(r)≠0f'(r) \ne 0, then for some δ>0\delta > 0 Newton's map NN is a contraction of [r−δ,r+δ][r - \delta, r + \delta] with constant 12\frac12, so Newton's method converges to rr from every start in that interval.

    Why it is trueN′(x)=f(x)f′′(x)/f′(x)2N'(x) = f(x)f''(x)/f'(x)^2, which is 00 at the root. A derivative that is 00 at rr and continuous is small on a small interval around rr.

    Proofstandard
    The idea: Differentiate N, see that N'(r) = 0, use continuity to keep |N'| ≤ 1/2 on a small interval, and check N maps the interval into itself.
    N′(x)=1−f′(x)2−f(x)f′′(x)f′(x)2=f(x) f′′(x)f′(x)2N'(x) = 1 - \dfrac{f'(x)^2 - f(x)f''(x)}{f'(x)^2} = \dfrac{f(x)\,f''(x)}{f'(x)^2}.
    Quotient rule on f/f′f/f': (ff′)′=f′2−ff′′f′2\left(\frac{f}{f'}\right)' = \frac{f'^2 - f f''}{f'^2}. We need f′′f'' to exist for this, and f′≠0f' \ne 0 near rr (by continuity of f′f' from f′(r)≠0f'(r) \ne 0).
    So N′(r)=0N'(r) = 0.
    f(r)=0f(r) = 0.This is the whole secret of Newton's method: the map is flat at the fixed point.
    Choose δ>0\delta > 0 with f′≠0f' \ne 0 and ∣N′(x)∣≤12\lvert N'(x) \rvert \le \frac12 for all x∈Ix \in I.
    N′N' is continuous near rr (since f,f′,f′′f, f', f'' are continuous and f′≠0f' \ne 0), and N′(r)=0N'(r) = 0, so for small enough δ\delta we have ∣N′(x)∣≤12\lvert N'(x) \rvert \le \frac12 on II. Continuity of N′N' at rr with value 00 means: for the tolerance 12\frac12 there is a δ\delta that works.
    Then ∣N(x)−N(y)∣≤12∣x−y∣\lvert N(x) - N(y) \rvert \le \frac12\lvert x - y \rvert on II.
    The derivative test: mean value theorem.
    NN maps II into II. As II is closed in R\mathbb R, it is complete, so Banach applies. ■\blacksquare
    N(r)=rN(r) = r because f(r)=0f(r) = 0, so ∣N(x)−r∣=∣N(x)−N(r)∣≤12∣x−r∣≤δ\lvert N(x) - r \rvert = \lvert N(x) - N(r) \rvert \le \frac12\lvert x - r \rvert \le \delta for x∈Ix \in I.
    Worked example
    Newton's method for x2=2x^2 = 2: find an interval where NN is a contraction and bound the error.

    Solution.

    1. The map. f(x)=x2−2f(x) = x^2 - 2, N(x)=x−x2−22x=x2+1xN(x) = x - \dfrac{x^2 - 2}{2x} = \dfrac{x}{2} + \dfrac1x. This is the Babylonian method of 1.2.
    2. The slope. N′(x)=12−1x2N'(x) = \dfrac12 - \dfrac1{x^2}, which is 00 at x=2x = \sqrt 2. The root is a fixed point where the slope vanishes.
    3. Choose an interval. Take I=[1.2,1.6]I = [1.2, 1.6]. N′N' is increasing, with N′(1.2)=0.5−0.694=−0.194N'(1.2) = 0.5 - 0.694 = -0.194 and N′(1.6)=0.5−0.391=0.109N'(1.6) = 0.5 - 0.391 = 0.109. So ∣N′∣≤0.195\lvert N' \rvert \le 0.195 on II; take q=0.2q = 0.2. An increasing function has its extreme values at the ends of the interval.
    4. Check that NN maps II into II. NN is convex (N′′(x)=2/x3>0N''(x) = 2/x^3 > 0), so its largest value on II is at an end: N(1.2)=1.4333N(1.2) = 1.4333, N(1.6)=1.425N(1.6) = 1.425. And N(x)≥2=1.4142N(x) \ge \sqrt 2 = 1.4142 for all x>0x > 0 (arithmetic-geometric mean). So N(I)⊆[1.4142,1.4333]⊆IN(I) \subseteq [1.4142, 1.4333] \subseteq I. The map must send the space into itself.
    5. Run it from x0=1.5x_0 = 1.5. x1=1712=1.416667x_1 = \frac{17}{12} = 1.416667, so d(x1,x0)=0.0833d(x_1, x_0) = 0.0833. The a priori bound gives d(xn,2)≤0.2n0.8(0.0833)=0.104 (0.2)nd(x_n, \sqrt 2) \le \dfrac{0.2^n}{0.8}(0.0833) = 0.104\,(0.2)^n. Apply Banach with q=0.2q = 0.2.
    6. Compare with the true errors. x1−2=2.5×10−3x_1 - \sqrt 2 = 2.5 \times 10^{-3}, x2−2=2.1×10−6x_2 - \sqrt 2 = 2.1 \times 10^{-6}, x3−2=1.6×10−12x_3 - \sqrt 2 = 1.6 \times 10^{-12}. The bound allows 0.0208, 0.0042, 0.00080.0208,\ 0.0042,\ 0.0008. The bound is true but loose. The true error is roughly squared at each step, which is faster than any fixed factor qq: a map whose slope is 00 at the fixed point has a better contraction constant on every smaller interval.

    Answer. On [1.2,1.6][1.2, 1.6], NN is a contraction with q=0.2q = 0.2; the iterates converge to 2\sqrt 2 from any start there. ■\blacksquare

    Your answerNewton's method for x2=2x^2 = 2 is N(x)=x2+1xN(x) = \frac x2 + \frac1x. Starting at x0=1.5x_0 = 1.5, what is x1x_1? (Give a fraction.)
    Worked example
    Solve the linear system x=Ax+bx = Ax + b by iteration, with A=[0.50.20.10.3]A = \begin{bmatrix} 0.5 & 0.2 \\ 0.1 & 0.3 \end{bmatrix} and b=(1,2)b = (1, 2).

    Solution. We use the max-distance on R2\mathbb R^2, the complete space of 4.1.

    1. Write the map. T(x)=Ax+bT(x) = Ax + b. A solution of the system is a fixed point of TT. The system (I−A)x=b(I - A)x = b is the same equation as x=Ax+bx = Ax + b.
    2. Compute the contraction constant. T(x)−T(y)=A(x−y)T(x) - T(y) = A(x - y). For any vector zz, ∥Az∥∞=max⁡i∣∑jAijzj∣≤max⁡i∑j∣Aij∣ ∥z∥∞\lVert Az \rVert_\infty = \max_i \lvert \sum_j A_{ij}z_j \rvert \le \max_i \sum_j \lvert A_{ij} \rvert\,\lVert z \rVert_\infty. The row sums of ∣A∣\lvert A \rvert are 0.70.7 and 0.40.4, so ∥Az∥∞≤0.7 ∥z∥∞\lVert Az \rVert_\infty \le 0.7\,\lVert z \rVert_\infty. Each entry of zz has size at most ∥z∥∞\lVert z \rVert_\infty, and the largest row sum is the worst case. This is the operator norm of 3.5 for the max-distance.
    3. Apply Banach. TT is a contraction of the complete space (R2,d∞)(\mathbb R^2, d_\infty) with q=0.7q = 0.7. There is exactly one solution and the iteration converges from any start. R2\mathbb R^2 is complete, by the theorem above.
    4. Iterate from x0=(0,0)x_0 = (0, 0). x1=(1,2)x_1 = (1, 2), x2=(1.9,2.7)x_2 = (1.9, 2.7), x3=(2.49,3.0)x_3 = (2.49, 3.0), x4=(2.845,3.149)x_4 = (2.845, 3.149). Each step is one matrix-vector product plus bb.
    5. Compare with the exact solution. Solving (I−A)x=b(I - A)x = b by elimination gives x∗=(103,103)x^* = (\frac{10}3, \frac{10}3). The errors in max-distance are 3.33, 2.33, 1.43, 0.84, 0.493.33,\ 2.33,\ 1.43,\ 0.84,\ 0.49, shrinking by about 0.580.58 to 0.70.7 per step. The a priori bound 0.7n0.3(2)\frac{0.7^n}{0.3}(2) gives 4.67, 3.27, 2.29, 1.604.67,\ 3.27,\ 2.29,\ 1.60 for n=1,2,3,4n = 1, 2, 3, 4. Every error is below its bound, as the theorem promises.

    Answer. x∗=(10/3,10/3)x^* = (10/3, 10/3). The method needs only matrix-vector products, which is why iterative solvers for huge sparse systems use it. ■\blacksquare

    Worked example
    Picard iteration for y′=yy' = y, y(0)=1y(0) = 1: the contraction on a space of functions.

    Solution. We solve the differential equation by finding a fixed point of an operator that acts on functions.

    1. Turn the equation into an integral equation. y′=yy' = y with y(0)=1y(0) = 1 holds exactly when y(t)=1+∫0ty(s) dsy(t) = 1 + \int_0^t y(s)\,ds. The fundamental theorem of calculus (1.5) in both directions.
    2. Define the operator. On the space X=C[0,a]X = C[0, a] with the sup metric, let (Ty)(t)=1+∫0ty(s) ds(Ty)(t) = 1 + \int_0^t y(s)\,ds. A fixed point Ty=yTy = y is a solution. TT sends continuous functions to continuous functions (an integral is continuous in its upper limit). The “points” of the space are now functions, and TT is a map from the space to itself.
    3. Show it is a contraction. For y,z∈Xy, z \in X and t∈[0,a]t \in [0, a]: ∣(Ty)(t)−(Tz)(t)∣=∣∫0t(y−z) ds∣≤∫0t∣y(s)−z(s)∣ ds≤t d∞(y,z)≤a d∞(y,z)\lvert (Ty)(t) - (Tz)(t) \rvert = \left\lvert \int_0^t (y - z)\,ds \right\rvert \le \int_0^t \lvert y(s) - z(s) \rvert\,ds \le t\,d_\infty(y, z) \le a\,d_\infty(y, z). Taking the maximum over tt, d∞(Ty,Tz)≤a d∞(y,z)d_\infty(Ty, Tz) \le a\,d_\infty(y, z). The integral of a function bounded by d∞(y,z)d_\infty(y, z) over an interval of length tt is at most t d∞(y,z)t\,d_\infty(y, z). So q=aq = a, which is below 11 for a<1a < 1.
    4. Apply Banach with a=12a = \frac12. C[0,12]C[0, \frac12] is complete, so there is exactly one solution on [0,12][0, \frac12], found by iterating from any starting function. Completeness of C[a,b]C[a, b] is the theorem of this chapter.
    5. Run the iteration from y0=1y_0 = 1. y1=1+ty_1 = 1 + t, y2=1+t+t22y_2 = 1 + t + \frac{t^2}{2}, y3=1+t+t22+t36y_3 = 1 + t + \frac{t^2}2 + \frac{t^3}{6}, in general yn=∑k=0ntkk!y_n = \sum_{k=0}^n \frac{t^k}{k!}. Each application of TT integrates the previous polynomial and adds 11.
    6. Recognise the limit. yn→ety_n \to e^t uniformly on [0,12][0, \frac12]: the partial sums of the exponential series of 1.6. The theorem promised convergence in the sup metric; here we see it concretely.
    7. Error bound. d∞(y1,y0)=max⁡[0,1/2]t=12d_\infty(y_1, y_0) = \max_{[0, 1/2]} t = \frac12, so d∞(yn,et)≤(1/2)n1/2⋅12=2−nd_\infty(y_n, e^t) \le \frac{(1/2)^n}{1/2} \cdot \frac12 = 2^{-n}. For n=3n = 3 the bound is 0.1250.125, and the true error is e0.5−7948≈0.0029e^{0.5} - \frac{79}{48} \approx 0.0029. Again a guarantee that is far from tight. The factor aa is the worst case over the interval.

    Answer. The unique solution on [0,12][0, \frac12] is y=ety = e^t. Restarting the argument at t=12t = \frac12 with the new initial value e1/2e^{1/2} extends it to [0,1][0, 1], and so on, so it exists for all t≥0t \ge 0. ■\blacksquare

    Your answerIn Picard iteration for y′=yy' = y, y(0)=1y(0) = 1, the third iterate is y3(t)=1+t+t22+t36y_3(t) = 1 + t + \frac{t^2}{2} + \frac{t^3}{6}. What is y3(12)y_3(\frac12)? (Give a fraction.)
    A preview· Preview: chapter 7.1, the existence and uniqueness theorem for ODEs

    The example above had f(t,y)=yf(t, y) = y. For a general equation y′=f(t,y)y' = f(t, y) with y(0)=y0y(0) = y_0, the operator is (Ty)(t)=y0+∫0tf(s,y(s)) ds(Ty)(t) = y_0 + \int_0^t f(s, y(s))\,ds on C[0,a]C[0, a]. If ff satisfies a Lipschitz condition ∣f(t,y)−f(t,z)∣≤L ∣y−z∣\lvert f(t, y) - f(t, z) \rvert \le L\,\lvert y - z \rvert, the same estimate gives d∞(Ty,Tz)≤L a d∞(y,z)d_\infty(Ty, Tz) \le L\,a\,d_\infty(y, z). So TT is a contraction when a<1La < \frac1L. This is the Picard–Lindelöf theorem of MATH 376, and chapter 7.1 is this page with ff in place of yy.

    Where it is used

    Used inside maths· Inside maths: existence theorems and the real numbers themselves

    The contraction mapping theorem is how analysts prove that equations have solutions without finding them: the existence and uniqueness of solutions of ODEs (7.1), the inverse function theorem (Rudin’s ch. 9 proves it by contraction), and the implicit function theorem in Unit 5. Completeness also underlies the real numbers: R\mathbb R is what you get by adding to Q\mathbb Q the limit of every Cauchy sequence, a construction due to Cantor and others around 1870. And it explains 1.6: a series converges when its partial sums are Cauchy, and on a closed interval inside its radius of convergence the partial sums of a power series are a Cauchy sequence in C[a,b]C[a, b], so the sum is a continuous function.

    Used in the real world· PageRank is a contraction in the 1-norm

    In 2.11 the Google matrix G=dP+1−dn11TG = dP + \frac{1-d}{n}\mathbf 1\mathbf 1^{\mathsf T} ranks web pages: the power method xk+1=Gxkx_{k+1} = Gx_k converges to the stationary vector π\pi. We can read this as a contraction. Take X=ΔX = \Delta, the set of probability vectors, which is complete (above), with the 1-distance ∥x−y∥1\lVert x - y \rVert_1. For x,y∈Δx, y \in \Delta, the difference z=x−yz = x - y has entries adding to 00, so 1Tz=0\mathbf 1^{\mathsf T}z = 0 and the teleportation term vanishes:

    Gx−Gy=dP(x−y)+1−dn1 (1Tz)=dPz.Gx - Gy = dP(x - y) + \tfrac{1-d}{n}\mathbf 1\,(\mathbf 1^{\mathsf T}z) = dP z.

    In 2.11 we proved that a stochastic matrix never increases the 1-norm: ∥Pz∥1≤∥z∥1\lVert Pz \rVert_1 \le \lVert z \rVert_1. Hence

    ∥Gx−Gy∥1≤d ∥x−y∥1.\lVert Gx - Gy \rVert_1 \le d\,\lVert x - y \rVert_1 .

    Also GG maps Δ\Delta into Δ\Delta: for a probability vector xx, Gx=dPx+1−dn1Gx = dPx + \frac{1-d}{n}\mathbf 1 has non-negative entries that add to d+(1−d)=1d + (1 - d) = 1 (the theorem “A stochastic matrix keeps probability vectors” of 2.11 gives that PxPx adds to 11). So GG is a contraction of Δ\Delta with constant q=d=0.85q = d = 0.85. Banach gives, at once and without the Perron–Frobenius theorem: a unique stationary distribution, convergence from every starting vector, and ∥xk−π∥1≤dk ∥x0−π∥1≤2dk\lVert x_k - \pi \rVert_1 \le d^k\,\lVert x_0 - \pi \rVert_1 \le 2d^k (two probability vectors are at 1-distance at most 22). This recovers the bound of 2.11. To guarantee a 1-distance below 10−810^{-8} takes k=118k = 118 steps, because 2×0.85118≈9.4×10−92 \times 0.85^{118} \approx 9.4 \times 10^{-9}. Page, Brin, Motwani and Winograd’s 1998 report says that for a web of 322 million links the iteration converged in about 52 steps (the figure quoted in 2.11), so the guarantee is cautious and the actual rate is set by the second eigenvalue.

    Worked example 2.11; computed
    Run the PageRank contraction on the four-page web of 2.11 with d=0.85d = 0.85, from x0=(1,0,0,0)x_0 = (1, 0, 0, 0).

    Solution.

    1. The matrix. Page 1 links to pages 2, 3, 4; page 2 to 3 and 4; page 3 to page 1; page 4 to pages 1 and 3. The columns of PP are (0,13,13,13)(0, \frac13, \frac13, \frac13), (0,0,12,12)(0, 0, \frac12, \frac12), (1,0,0,0)(1, 0, 0, 0), (12,0,12,0)(\frac12, 0, \frac12, 0), and G=0.85 P+0.15411TG = 0.85\,P + \frac{0.15}{4}\mathbf 1\mathbf 1^{\mathsf T}. This is the web of 2.11. Every entry of GG is at least 0.03750.0375.
    2. The fixed point. Solving Gπ=πG\pi = \pi gives π≈(0.3682, 0.1418, 0.2880, 0.2021)\pi \approx (0.3682,\ 0.1418,\ 0.2880,\ 0.2021). Page 1 ranks highest: two pages link to it, and one of them is page 3 which sends all its weight there.
    3. Iterate and measure. The 1-distance to π\pi at steps k=0,1,2,3,4,5,6k = 0, 1, 2, 3, 4, 5, 6 is 1.264, 0.661, 0.223, 0.085, 0.058, 0.028, 0.0081.264,\ 0.661,\ 0.223,\ 0.085,\ 0.058,\ 0.028,\ 0.008. The guarantee dk∥x0−π∥1d^k \lVert x_0 - \pi \rVert_1 is 1.264, 1.074, 0.913, 0.776, 0.660, 0.561, 0.4771.264,\ 1.074,\ 0.913,\ 0.776,\ 0.660,\ 0.561,\ 0.477. The error is below the guarantee at every step, and much below it: the actual rate is about 0.460.46, the second-largest eigenvalue size of GG (0.85×0.5470.85 \times 0.547, using the ∣λ2∣≈0.547|\lambda_2| \approx 0.547 of 2.11).
    4. Steps for 10−810^{-8}. The guarantee needs k=118k = 118; this web reaches 10−810^{-8} at k=25k = 25. The contraction constant dd is a worst case over all webs. The real rate depends on the web’s own eigenvalues, as the power method theorem of 2.11 said.

    Answer. π≈(0.368,0.142,0.288,0.202)\pi \approx (0.368, 0.142, 0.288, 0.202) is the unique PageRank vector. Banach turns “does it converge, and how fast” into one line: q=dq = d. ■\blacksquare

    Your answerBy the guarantee 2 dk2\,d^k with d=0.85d = 0.85, what is the smallest number of PageRank iterations kk that ensures a 1-distance below 10−810^{-8} to the PageRank vector?
    Used in the real world· Reinforcement learning: value iteration converges because the Bellman operator is a $\gamma$-contraction

    An agent in a world with states ss chooses actions aa, collects rewards r(s,a)r(s, a), and moves to a next state s′s' with probability P(s′∣s,a)P(s' \mid s, a). A discount γ∈[0,1)\gamma \in [0, 1) makes later rewards worth less. The value V(s)V(s) is the best total discounted reward from state ss. The Bellman operator maps a table of values V∈R∣S∣V \in \mathbb R^{\lvert S \rvert} to a new table:

    (TV)(s)=max⁡a[r(s,a)+γ∑s′P(s′∣s,a) V(s′)].(TV)(s) = \max_a \Big[ r(s, a) + \gamma \sum_{s'} P(s' \mid s, a)\,V(s') \Big].

    The optimal value V∗V^* is a fixed point of TT. Claim: TT is a contraction of (R∣S∣,d∞)(\mathbb R^{\lvert S \rvert}, d_\infty) with q=γq = \gamma. Proof. Fix ss and aa and write uau_a and waw_a for the bracket evaluated at VV and at WW. Then ∣ua−wa∣=γ ∣∑s′P(s′∣s,a)(V(s′)−W(s′))∣≤γ ∥V−W∥∞\lvert u_a - w_a \rvert = \gamma\,\big\lvert \sum_{s'} P(s' \mid s, a)(V(s') - W(s')) \big\rvert \le \gamma\,\lVert V - W \rVert_\infty, because the probabilities are non-negative and add to 11. Also ∣max⁡aua−max⁡awa∣≤max⁡a∣ua−wa∣\lvert \max_a u_a - \max_a w_a \rvert \le \max_a \lvert u_a - w_a \rvert (if the larger maximum is ua∗u_{a^*}, then max⁡u−max⁡w≤ua∗−wa∗\max u - \max w \le u_{a^*} - w_{a^*}). Hence ∥TV−TW∥∞≤γ ∥V−W∥∞\lVert TV - TW \rVert_\infty \le \gamma\,\lVert V - W \rVert_\infty. ■\blacksquare Since R∣S∣\mathbb R^{\lvert S \rvert} with the max-distance is complete, Banach gives a unique V∗V^*, value iteration Vk+1=TVkV_{k+1} = TV_k converges to it from any start, and ∥Vk−V∗∥∞≤γk∥V0−V∗∥∞\lVert V_k - V^* \rVert_\infty \le \gamma^k \lVert V_0 - V^* \rVert_\infty. Richard Bellman developed dynamic programming in the 1950s (his book Dynamic Programming appeared in 1957); this is the standard proof that its main algorithm works, found in any reinforcement-learning text (Sutton and Barto’s, for example).

    Worked example
    Value iteration on a two-state world with γ=0.9\gamma = 0.9.

    Solution. States AA and BB, two actions each. In AA: stay gives reward 11 and keeps you in AA; go gives reward 00 and moves you to BB. In BB: stay gives reward 22; go gives reward 00 and moves you to AA. All moves are certain (so PP is 00 or 11).

    1. The Bellman operator. (TV)(A)=max⁡(1+0.9 V(A), 0+0.9 V(B))(TV)(A) = \max(1 + 0.9\,V(A),\ 0 + 0.9\,V(B)) and (TV)(B)=max⁡(2+0.9 V(B), 0+0.9 V(A))(TV)(B) = \max(2 + 0.9\,V(B),\ 0 + 0.9\,V(A)). The maximum is over the two actions available in each state.
    2. Contraction. q=γ=0.9q = \gamma = 0.9 in the max-distance on R2\mathbb R^2. By the claim above. So one fixed point, reached from any start.
    3. Iterate from V0=(0,0)V_0 = (0, 0). V1=(1,2)V_1 = (1, 2). V2=(max⁡(1.9,1.8), max⁡(3.8,0.9))=(1.9,3.8)V_2 = (\max(1.9, 1.8),\ \max(3.8, 0.9)) = (1.9, 3.8). V3=(max⁡(2.71,3.42), max⁡(5.42,1.71))=(3.42,5.42)V_3 = (\max(2.71, 3.42),\ \max(5.42, 1.71)) = (3.42, 5.42). At step 3 the best move from AA switches from “stay” to “go”: it is better to walk to the richer state BB.
    4. Find the fixed point by hand. In BB staying forever is best: V∗(B)=21−0.9=20V^*(B) = \dfrac{2}{1 - 0.9} = 20. In AA, going to BB gives 0.9×20=180.9 \times 20 = 18, which beats staying (1+0.9×18=17.21 + 0.9 \times 18 = 17.2), so V∗(A)=18V^*(A) = 18. Check: T(18,20)=(max⁡(17.2,18), max⁡(20,16.2))=(18,20)T(18, 20) = (\max(17.2, 18),\ \max(20, 16.2)) = (18, 20).
    5. The errors. ∥Vk−V∗∥∞=20, 18, 16.2, 14.58\lVert V_k - V^* \rVert_\infty = 20,\ 18,\ 16.2,\ 14.58 for k=0,1,2,3k = 0, 1, 2, 3, which is exactly 20×0.9k20 \times 0.9^k. The bound γk∥V0−V∗∥∞\gamma^k\lVert V_0 - V^* \rVert_\infty is attained here: the worst-case rate γ\gamma really happens.
    6. Steps to accuracy 0.010.01. 20×0.9k<0.0120 \times 0.9^k < 0.01 needs k≥73k \ge 73. 20×0.973=0.009120 \times 0.9^{73} = 0.0091, while 0.972×20=0.01020.9^{72} \times 20 = 0.0102.

    Answer. V∗=(18,20)V^* = (18, 20), and value iteration reaches error below 0.010.01 after 7373 steps. With γ\gamma close to 11 (an agent that cares about the far future) the contraction constant is near 11 and convergence is slow. ■\blacksquare

    Your answerIn the two-state world, value iteration from V0=(0,0)V_0 = (0, 0) gives V1=(1,2)V_1 = (1, 2). What is V2(A)=max⁡(1+0.9 V1(A), 0.9 V1(B))V_2(A) = \max(1 + 0.9\,V_1(A),\ 0.9\,V_1(B))?

    Traps

    Watch out· Distances shrinking is not the same as contracting

    A map with d(Tx,Ty)<d(x,y)d(Tx, Ty) < d(x, y) for all x≠yx \ne y need not be a contraction and need not have a fixed point (x+1xx + \frac1x on [1,∞)[1, \infty)). The constant q<1q < 1 must be the same for all pairs. Also sin⁡x\sin x shrinks distances on R\mathbb R but has q=1q = 1 in the supremum.

    Watch out· The map must send the space into itself

    For cosine, [0,1][0, 1] works because cos⁡[0,1]⊆[0,1]\cos[0, 1] \subseteq [0, 1]. On [0,2][0, 2] it would not: cos⁡2<0\cos 2 < 0. Always check T(X)⊆XT(X) \subseteq X and that XX is complete (closed, for a subset of Rn\mathbb R^n) before using the theorem. Forgetting the first check is the most common error.

    Watch out· Open intervals are not complete

    (0,1)(0, 1) with the usual distance is not complete. A contraction of (0,1)(0, 1) into itself can fail to have a fixed point. The reason to work on a closed interval is not decoration. It is the hypothesis.

    Watch out· A small step does not prove the iteration has converged

    The a posteriori bound q1−qd(xn,xn−1)\frac{q}{1 - q}d(x_n, x_{n-1}) needs the contraction constant. For q=0.99q = 0.99 the factor is 9999: two successive guesses differing by 10−610^{-6} only guarantee an error of 10−410^{-4}. And without a contraction (like n\sqrt n in 1.2, whose neighbouring terms get arbitrarily close) a small step proves nothing at all.

    Watch out· Slope below 1 at the fixed point is local; the theorem needs it on the whole space

    For T(x)=x2T(x) = x^2 the slope at the fixed point 00 is 00, yet iterating from x0=2x_0 = 2 runs off to infinity. The contraction holds only on a small interval such as [0,13][0, \frac13]. When the slope bound holds only near the fixed point, Banach applies to a small closed interval around it, and you must start inside.

    Watch out· Completeness belongs to the metric, not only to the shape of the set

    R\mathbb R with d(x,y)=∣arctan⁡x−arctan⁡y∣d(x, y) = \lvert \arctan x - \arctan y \rvert is a metric space with the same notion of “nearby” as before, but it is not complete: the sequence xn=nx_n = n is Cauchy and has no limit. Completeness is a property of the distance, which is why changing the norm on a function space (sup norm to 2-norm) can destroy it.

    Problems

    check

    Which of these maps of R\mathbb R are contractions, and with what constant: (a) T(x)=0.4x−3T(x) = 0.4x - 3; (b) T(x)=x+0.1T(x) = x + 0.1; (c) T(x)=12cos⁡xT(x) = \frac12\cos x; (d) T(x)=−xT(x) = -x?

    Solution

    (a) Yes, q=0.4q = 0.4. (b) No: TT preserves distances (q=1q = 1) and has no fixed point. (c) Yes: ∣T′(x)∣=12∣sin⁡x∣≤12\lvert T'(x) \rvert = \frac12\lvert \sin x \rvert \le \frac12, so q=12q = \frac12 by the derivative test. (d) No: ∣Tx−Ty∣=∣x−y∣\lvert Tx - Ty \rvert = \lvert x - y \rvert, so q=1q = 1. (It has the fixed point 00 but is not a contraction: iterates bounce between xx and −x-x.)

    check

    For T(x)=x3+5T(x) = \frac x3 + 5, find the fixed point, and starting at x0=0x_0 = 0 compare the true error ∣xn−x∗∣\lvert x_n - x^* \rvert with the a priori bound.

    Solution

    Fixed point: x=x3+5x = \frac x3 + 5 gives x∗=7.5x^* = 7.5. Iterates: x1=5x_1 = 5, so d(x1,x0)=5d(x_1, x_0) = 5 and q=13q = \frac13. The bound is (1/3)n2/3⋅5=7.5 (1/3)n\frac{(1/3)^n}{2/3}\cdot 5 = 7.5\,(1/3)^n. The true error: T(x)−7.5=13(x−7.5)T(x) - 7.5 = \frac13(x - 7.5), so ∣xn−7.5∣=7.5 (1/3)n\lvert x_n - 7.5 \rvert = 7.5\,(1/3)^n. The bound is exactly the true error: it cannot be improved, because here the slope is 13\frac13 everywhere.

    check

    What does a Cauchy sequence look like in the discrete metric? Is a sequence of bit strings under the Hamming distance, in which consecutive terms differ in at most one bit, always Cauchy?

    Solution

    In the discrete metric a Cauchy sequence is eventually constant (take ε=12\varepsilon = \frac12). In the Hamming distance the same holds, because the distance takes whole-number values: take ε=1\varepsilon = 1 to get eventually constant. A sequence that changes one bit at every step is not Cauchy, since dH(xn+1,xn)=1≮1d_H(x_{n+1}, x_n) = 1 \not< 1 for all nn.

    check

    Is (0,1)(0, 1) complete with the distance ∣x−y∣\lvert x - y \rvert? Give a Cauchy sequence that shows your answer, and say which point is missing.

    Solution

    No. The sequence xn=1nx_n = \frac1n is Cauchy in (0,1)(0, 1) (it converges in R\mathbb R) but its limit 00 is not in (0,1)(0, 1). The missing point is 00. The same space with the extra endpoint, [0,1][0, 1], is complete.

    use

    Show that the iteration xn+1=e−xnx_{n+1} = e^{-x_n} converges to the unique solution of x=e−xx = e^{-x} from any starting point in [0.4,0.7][0.4, 0.7]. Starting at x0=0.5x_0 = 0.5, how many steps does the a priori bound guarantee for error below 10−610^{-6}?

    Solution

    Let g(x)=e−xg(x) = e^{-x} on X=[0.4,0.7]X = [0.4, 0.7], a closed interval, hence complete. gg is decreasing, so g(X)=[e−0.7,e−0.4]=[0.4966,0.6703]⊆Xg(X) = [e^{-0.7}, e^{-0.4}] = [0.4966, 0.6703] \subseteq X. And ∣g′(x)∣=e−x≤e−0.4=0.6703=:q<1\lvert g'(x) \rvert = e^{-x} \le e^{-0.4} = 0.6703 =: q < 1. By the derivative test and Banach there is a unique fixed point (about 0.56710.5671) and convergence. With x0=0.5x_0 = 0.5: x1=e−0.5=0.6065x_1 = e^{-0.5} = 0.6065, d(x1,x0)=0.1065d(x_1, x_0) = 0.1065. The bound 0.6703n0.3297(0.1065)≤10−6\frac{0.6703^n}{0.3297}(0.1065) \le 10^{-6} needs n≥32n \ge 32. (In practice 2020 steps suffice.)

    use

    Show that xn+1=1+1xnx_{n+1} = 1 + \dfrac{1}{x_n} converges to the golden ratio 1+52\frac{1 + \sqrt5}{2} from any start in [1.5,2][1.5, 2], and give the contraction constant.

    Solution

    Let g(x)=1+1xg(x) = 1 + \frac1x on X=[1.5,2]X = [1.5, 2]. gg is decreasing, with g(1.5)=53≈1.667g(1.5) = \frac53 \approx 1.667 and g(2)=1.5g(2) = 1.5, so g(X)=[1.5,1.667]⊆Xg(X) = [1.5, 1.667] \subseteq X. ∣g′(x)∣=1x2≤12.25=49=:q\lvert g'(x) \rvert = \frac1{x^2} \le \frac1{2.25} = \frac49 =: q on XX. Banach gives a unique fixed point in XX. A fixed point satisfies x=1+1xx = 1 + \frac1x, i.e. x2−x−1=0x^2 - x - 1 = 0, whose positive root is 1+52≈1.618\frac{1 + \sqrt5}{2} \approx 1.618. The iterates from 1.51.5 are 1.667, 1.6, 1.625, 1.615, …1.667,\ 1.6,\ 1.625,\ 1.615,\ \dots (ratios of consecutive Fibonacci numbers).

    use

    For A=[0.20.30.10.4]A = \begin{bmatrix} 0.2 & 0.3 \\ 0.1 & 0.4 \end{bmatrix} and b=(1,2)b = (1, 2), show that x↦Ax+bx \mapsto Ax + b is a contraction in the max-distance, find qq, and compute x1,x2,x3x_1, x_2, x_3 from x0=(0,0)x_0 = (0, 0). The exact solution is (83,349)(\frac83, \frac{34}9).

    Solution

    Row sums of the entries’ absolute values: 0.50.5 and 0.50.5, so ∥Az∥∞≤0.5 ∥z∥∞\lVert Az \rVert_\infty \le 0.5\,\lVert z \rVert_\infty and q=0.5q = 0.5. Iterates: x1=(1,2)x_1 = (1, 2), x2=(0.2+0.6+1, 0.1+0.8+2)=(1.8,2.9)x_2 = (0.2 + 0.6 + 1,\ 0.1 + 0.8 + 2) = (1.8, 2.9), x3=(0.36+0.87+1, 0.18+1.16+2)=(2.23,3.34)x_3 = (0.36 + 0.87 + 1,\ 0.18 + 1.16 + 2) = (2.23, 3.34). The exact solution is (2.667,3.778)(2.667, 3.778), and the max-error at x3x_3 is 0.4380.438, which is below the a priori bound 0.530.5(2)=0.5\frac{0.5^3}{0.5}(2) = 0.5.

    use

    Show that T(x)=x2T(x) = x^2 is a contraction of [0,13][0, \frac13], find qq, and say what the theorem predicts for the iteration from x0=13x_0 = \frac13.

    Solution

    TT maps [0,13][0, \frac13] into [0,19]⊆[0,13][0, \frac19] \subseteq [0, \frac13]. ∣T′(x)∣=2x≤23=:q\lvert T'(x) \rvert = 2x \le \frac23 =: q. By Banach there is a unique fixed point in [0,13][0, \frac13]; it is 00 (the other solution of x2=xx^2 = x is 11, outside the interval). From x0=13x_0 = \frac13: x1=19x_1 = \frac19, d(x1,x0)=29d(x_1, x_0) = \frac29, so d(xn,0)≤(2/3)n1/3⋅29=23(23)nd(x_n, 0) \le \frac{(2/3)^n}{1/3}\cdot\frac29 = \frac23\left(\frac23\right)^n. (The true error is (13)2n\left(\frac13\right)^{2^n}, much smaller: the slope is 00 at the fixed point.)

    prove

    Prove that every Cauchy sequence in a metric space is bounded: there are a point pp and a number MM with d(xn,p)≤Md(x_n, p) \le M for all nn.

    Solution

    Plan. After some index all terms are within 11 of one term; the finitely many earlier terms are at finite distance.

    Take ε=1\varepsilon = 1: there is NN with d(xm,xn)<1d(x_m, x_n) < 1 for m,n>Nm, n > N. Let p=xN+1p = x_{N+1}. Then d(xn,p)<1d(x_n, p) < 1 for all n>Nn > N. Let M=max⁡(1,d(x1,p),…,d(xN,p))M = \max(1, d(x_1, p), \dots, d(x_N, p)), a maximum of finitely many numbers. Then d(xn,p)≤Md(x_n, p) \le M for every nn. ■\blacksquare

    prove

    Prove that a Cauchy sequence in a metric space that has a convergent subsequence converges (to the same limit).

    Solution

    Plan. This is the last step of the Cauchy criterion proof in 1.2: split the distance through a late term of the subsequence.

    Let (xn)(x_n) be Cauchy and xnk→xx_{n_k} \to x. Let ε>0\varepsilon > 0. Choose NN with d(xm,xn)<ε2d(x_m, x_n) < \frac\varepsilon2 for m,n>Nm, n > N. Choose kk with nk>Nn_k > N and d(xnk,x)<ε2d(x_{n_k}, x) < \frac\varepsilon2. For n>Nn > N: d(xn,x)≤d(xn,xnk)+d(xnk,x)<εd(x_n, x) \le d(x_n, x_{n_k}) + d(x_{n_k}, x) < \varepsilon. So xn→xx_n \to x. ■\blacksquare

    prove

    Prove the a posteriori bound: if TT is a contraction with constant qq on a complete space, then d(xn,x∗)≤q1−q d(xn,xn−1)d(x_n, x^*) \le \frac{q}{1 - q}\,d(x_n, x_{n-1}).

    Solution

    Plan. Compare xnx_n with x∗x^* through xn+1x_{n+1} and use the contraction on the pair (xn,x∗)(x_n, x^*).

    d(xn,x∗)≤d(xn,xn+1)+d(xn+1,x∗)d(x_n, x^*) \le d(x_n, x_{n+1}) + d(x_{n+1}, x^*). Now xn+1=Txnx_{n+1} = T x_n and x∗=Tx∗x^* = T x^*, so d(xn+1,x∗)≤q d(xn,x∗)d(x_{n+1}, x^*) \le q\,d(x_n, x^*). Also d(xn,xn+1)≤q d(xn−1,xn)d(x_n, x_{n+1}) \le q\,d(x_{n-1}, x_n). Hence d(xn,x∗)(1−q)≤q d(xn,xn−1)d(x_n, x^*)(1 - q) \le q\,d(x_n, x_{n-1}), and dividing by 1−q>01 - q > 0 gives the claim. ■\blacksquare

    prove

    Prove: if AA is an n×nn \times n matrix whose largest absolute row sum max⁡i∑j∣Aij∣\max_i \sum_j \lvert A_{ij} \rvert is q<1q < 1, then for every bb the equation x=Ax+bx = Ax + b has exactly one solution in Rn\mathbb R^n, and xk+1=Axk+bx_{k+1} = Ax_k + b converges to it from any start.

    Solution

    Plan. Show Tx=Ax+bT x = Ax + b is a contraction of the complete space (Rn,d∞)(\mathbb R^n, d_\infty), then apply Banach.

    Rn\mathbb R^n with d∞d_\infty is complete (theorem above). For x,yx, y put z=x−yz = x - y. Then Tx−Ty=AzTx - Ty = Az, and for each ii, ∣(Az)i∣=∣∑jAijzj∣≤∑j∣Aij∣ ∣zj∣≤(∑j∣Aij∣)∥z∥∞≤q ∥z∥∞\lvert (Az)_i \rvert = \left\lvert \sum_j A_{ij}z_j \right\rvert \le \sum_j \lvert A_{ij} \rvert\,\lvert z_j \rvert \le \left(\sum_j \lvert A_{ij} \rvert\right)\lVert z \rVert_\infty \le q\,\lVert z \rVert_\infty. Taking the maximum over ii, d∞(Tx,Ty)≤q d∞(x,y)d_\infty(Tx, Ty) \le q\,d_\infty(x, y). The Banach fixed point theorem gives the unique solution and the convergence. ■\blacksquare (Consequently I−AI - A is invertible.)

    prove

    Prove that a contraction on any metric space (complete or not) has at most one fixed point, and that it is continuous.

    Solution

    Plan. Uniqueness is the pull-together argument; continuity follows from the contraction inequality directly.

    If Tx=xTx = x and Ty=yTy = y, then d(x,y)=d(Tx,Ty)≤q d(x,y)d(x, y) = d(Tx, Ty) \le q\,d(x, y), so (1−q) d(x,y)≤0(1 - q)\,d(x, y) \le 0, so d(x,y)=0d(x, y) = 0 and x=yx = y. For continuity: given ε>0\varepsilon > 0 take δ=ε\delta = \varepsilon. If d(x,y)<δd(x, y) < \delta, then d(Tx,Ty)≤q d(x,y)≤d(x,y)<εd(Tx, Ty) \le q\,d(x, y) \le d(x, y) < \varepsilon, because q<1q < 1. So TT is continuous (even uniformly). ■\blacksquare

    stretch

    Suppose T:X→XT : X \to X on a non-empty complete metric space is such that some power S=TmS = T^m (apply TT mm times) is a contraction. Prove that TT has exactly one fixed point. (This is how Picard iteration works on all of [0,∞)[0, \infty) at once: for the operator of the y′=yy' = y example, repeating the integral estimate mm times gives ∣(Tmy)(t)−(Tmz)(t)∣≤tmm! d∞(y,z)\lvert (T^my)(t) - (T^mz)(t) \rvert \le \frac{t^m}{m!}\,d_\infty(y, z), so TmT^m has constant am/m!a^m/m! on [0,a][0, a], which is below 11 for large mm however large aa is.)

    Solution

    Plan. Use Banach for SS, then show the fixed point of SS is also fixed by TT.

    By Banach, SS has a unique fixed point x∗x^*. Then S(Tx∗)=T(Sx∗)=Tx∗S(Tx^*) = T(Sx^*) = T x^* (because S=TmS = T^m commutes with TT), so Tx∗Tx^* is also a fixed point of SS. By uniqueness, Tx∗=x∗Tx^* = x^*. Any fixed point of TT is a fixed point of SS, so it equals x∗x^*. ■\blacksquare

    stretch

    Show that d(x,y)=∣arctan⁡x−arctan⁡y∣d(x, y) = \lvert \arctan x - \arctan y \rvert is a metric on R\mathbb R and that (R,d)(\mathbb R, d) is not complete, although R\mathbb R with ∣x−y∣\lvert x - y \rvert is.

    Solution

    Plan. A metric pulled back through an injective function; then find a Cauchy sequence escaping to infinity.

    (M1): d≥0d \ge 0, and d=0d = 0 iff arctan⁡x=arctan⁡y\arctan x = \arctan y iff x=yx = y (arctan is strictly increasing, so injective). (M2) is clear. (M3): ∣arctan⁡x−arctan⁡z∣≤∣arctan⁡x−arctan⁡y∣+∣arctan⁡y−arctan⁡z∣\lvert \arctan x - \arctan z \rvert \le \lvert \arctan x - \arctan y \rvert + \lvert \arctan y - \arctan z \rvert is the triangle inequality for real numbers. Now take xn=nx_n = n. Since arctan⁡n→π2\arctan n \to \frac\pi2, the real sequence (arctan⁡n)(\arctan n) is Cauchy, so d(xm,xn)=∣arctan⁡m−arctan⁡n∣→0d(x_m, x_n) = \lvert \arctan m - \arctan n \rvert \to 0 as m,n→∞m, n \to \infty: the sequence is Cauchy. It has no limit: for any real xx, d(xn,x)=∣arctan⁡n−arctan⁡x∣→π2−arctan⁡x>0d(x_n, x) = \lvert \arctan n - \arctan x \rvert \to \frac\pi2 - \arctan x > 0. So (R,d)(\mathbb R, d) is not complete. A Cauchy sequence escapes to a point at infinity that this metric does not contain.

    Summary

    • xn→xx_n \to x in a metric space means d(xn,x)→0d(x_n, x) \to 0. In Rn\mathbb R^n it is coordinatewise convergence; in C[a,b]C[a, b] with the sup metric it is uniform convergence.
    • A set is closed iff it contains the limits of all convergent sequences of its points. A closed subset of a complete space is complete, and a complete subset is closed.
    • A space is complete when every Cauchy sequence converges in it. R\mathbb R, Rn\mathbb R^n and C[a,b]C[a, b] with the sup metric are complete; Q\mathbb Q and (0,1](0, 1] are not. The C[a,b]C[a, b] proof builds the limit pointwise, gets a uniform NN from the sup metric, and uses that a uniform limit of continuous functions is continuous.
    • A contraction shrinks every distance by one fixed factor q<1q < 1. The Banach fixed point theorem: on a non-empty complete space a contraction has exactly one fixed point, iteration from any start converges to it, and d(xn,x∗)≤qn1−qd(x1,x0)d(x_n, x^*) \le \frac{q^n}{1 - q}d(x_1, x_0).
    • Using it takes four checks: TT maps a complete set into itself, and ∣Tx−Ty∣≤q∣x−y∣\lvert Tx - Ty \rvert \le q\lvert x - y \rvert for one q<1q < 1 (for a differentiable TT, ∣T′∣≤q\lvert T' \rvert \le q). Then say what qq is and what the bound promises.
    • Applications: cos⁡x=x\cos x = x (q=sin⁡1q = \sin 1); Newton’s method (slope 00 at the root, so qq can be made as small as you like near it); linear systems x=Ax+bx = Ax + b (row sums below 11); Picard iteration for ODEs (the integral operator on C[0,a]C[0, a], preview of 7.1).
    • PageRank is a contraction of the probability vectors in the 1-norm with q=dq = d; value iteration in reinforcement learning is a contraction in the max-norm with q=γq = \gamma.

    Where this sits

    Comes from
    4.1 Metric and normed spaces; open and closed sets
    1.2 Sequences and limits, from zero
    1.4 The derivative as best linear approximation
    1.6 Series, power series, and uniform convergence
    2.11 Markov chains and PageRank
    Leads to
    7.1 Existence and uniqueness for differential equations
    Same idea elsewhere
    MATH 376: Picard iteration for $y' = f(t, y)$ is the contraction mapping theorem applied to the integral operator $(Ty)(t) = y_0 + \int_0^t f(s, y(s))\,ds$ on a space of continuous functions with the sup metric. The existence and uniqueness theorem of 376 is exactly this chapter plus a Lipschitz estimate.
    MATH 521: 521 proves that $C[a, b]$ is complete, the Banach fixed point theorem, and then uses it for the inverse function theorem and for ODEs. This chapter is that sequence of results.
    CS 240 / numerical methods: Every iterative algorithm that stops when successive iterates are close ('converged to tolerance') relies on a contraction or on completeness. The a posteriori error bound below is the stopping rule.
    CS 532 / AI: Value iteration in reinforcement learning, and the fixed-point equations behind Q-learning, converge because the Bellman operator is a contraction in the sup norm.