---
title: Completeness and the contraction mapping theorem
heading: One theorem behind every iteration that settles down
eyebrow: A14 · Lesson 33 · Completeness and the contraction mapping theorem
xp: 40
---

::: hook
Fixed-point iteration for a diode, Jacobi sweeps on a resistor network, Picard's method for a differential equation: each repeats a map until the answer stops changing. The **contraction mapping theorem** (Banach's fixed-point theorem) explains all of them at once. If a map shrinks every distance by at least a factor q < 1, and the space it acts on is complete, then it has exactly one fixed point, iteration from anywhere converges to it, and you can bound the error before you start. The ingredients are lesson 4's geometric tail and lesson 32's metric spaces; the space can be numbers, vectors or functions.
:::

::: play
- The map scales the plane toward the orange point by q and rotates it by θ. Every distance shrinks by q, so it's a contraction, and the dots (the iterates from $x_0$) spiral into the fixed point.
- The readouts compare the actual distance after 5 steps with the a priori bound $\frac{q^5}{1 - q}d(x_1, x_0)$, which uses only the first step.
- Push q toward 1: convergence slows and the bound loosens by the factor $\frac{1}{1 - q}$.
:::
:::

```sim plot
view: complex
range: 3
slider: q = 0.2..0.95 step 0.05 = 0.7
slider: t = 0..180 step 5 = 60 °
dot: 1 + j | label: fixed point | color: ch3
dot: 1 + j + (q*exp(j*t*pi/180))^0*(-2.5 - 1.5*j) | label: x₀
dot: 1 + j + (q*exp(j*t*pi/180))^1*(-2.5 - 1.5*j) | label: x₁
dot: 1 + j + (q*exp(j*t*pi/180))^2*(-2.5 - 1.5*j) | label: x₂
dot: 1 + j + (q*exp(j*t*pi/180))^3*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^4*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^5*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^6*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^7*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^8*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^9*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^10*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^11*(-2.5 - 1.5*j)
dot: 1 + j + (q*exp(j*t*pi/180))^12*(-2.5 - 1.5*j)
readout: actual distance after 5 steps = q^5*abs(-2.5 - 1.5*j)
readout: a priori bound after 5 steps = q^5/(1 - q)*abs((q*exp(j*t*pi/180) - 1)*(-2.5 - 1.5*j))
```

::: predict
## $T(x) = 0.5x + 3$ on ℝ. What's its fixed point, and how fast does iteration approach it?

- [ ] 3, halving the error each step
- [x] 6, halving the error each step
- [ ] 6, but only from a good start
- [ ] There's no fixed point

::: reveal
6, from any start: x = 0.5x + 3 gives x = 6, and $\lvert T(x) - 6\rvert = 0.5\lvert x - 6\rvert$, so every step halves the error. The contraction constant is the factor every distance shrinks by.
:::
:::

::: nameit
## Complete spaces

A metric space is **complete** if every Cauchy sequence converges to a point of the space.

- Complete: ℝ, $\mathbb R^n$ with any p-norm, closed subsets of them, and continuous functions on [a, b] with the sup metric (a uniform limit of continuous functions is continuous).
- Not complete: ℚ; (0, 1]; continuous functions with the $L^1$ metric (a Cauchy sequence can converge to a step).

## The contraction mapping theorem

Let (X, d) be complete and T: X → X a **contraction**: $d(Tx, Ty) \le q\,d(x, y)$ for all x, y, with q < 1. Then:

1. T has exactly one fixed point $x^*$.
2. For any $x_0$, the iterates $x_{n+1} = Tx_n$ converge to $x^*$.
3. **A priori bound:** $d(x_n, x^*) \le \frac{q^n}{1 - q}d(x_1, x_0)$.
4. **A posteriori bound:** $d(x_n, x^*) \le \frac{q}{1 - q}d(x_n, x_{n-1})$.

Proof sketch: the steps shrink geometrically, so the iterates are Cauchy (lesson 4); completeness gives a limit; continuity of T makes it a fixed point; and two fixed points would satisfy $d(x, y) \le q\,d(x, y)$, forcing them equal.

## Checking the hypotheses

- On an interval, a differentiable g with $\lvert g'\rvert \le q < 1$ is a contraction, but it must also map the interval **into itself**.
- For a linear map $x \mapsto Ax + b$, any norm with $\lVert A\rVert < 1$ works; Jacobi's method converges when $\lVert D^{-1}(L + U)\rVert_\infty < 1$, which is diagonal dominance (A13, lesson 27).
:::

::: example
## Show $g(x) = \frac x2 + \frac1x$ is a contraction on [1, 2] and find its fixed point.

::: solution
1. **Bound the derivative.**
   $$g'(x) = \frac12 - \frac{1}{x^2}$$
   lies between −½ and ¼ on [1, 2], so q = ½.
2. **Check it maps into itself.** g maps [1, 2] into [1.414, 1.5], inside [1, 2].
3. **Find the fixed point.** So there's one fixed point, where
   $$x = \frac x2 + \frac1x$$
   that is, $x = \sqrt2$.
4. **What it is.** This is Newton's method for $x^2 = 2$, which converges even faster than the contraction constant suggests.

**Answer:** g is a contraction with q = ½, and its fixed point is $\sqrt2$.
:::
:::

::: example
## With q = 0.7 and a first step of length 0.4, how many iterations guarantee an error below $10^{-6}$?

::: solution
1. **Set up the a priori bound.** Need
   $$\frac{0.7^n}{0.3} \times 0.4 < 10^{-6}$$
2. **Simplify.**
   $$0.7^n < 7.5 \times 10^{-7}$$
3. **Take logs.**
   $$\begin{aligned} n &> \frac{\ln(7.5 \times 10^{-7})}{\ln 0.7} \\ &= 39.5 \end{aligned}$$
   so 40 iterations.
4. **The a posteriori bound.** If after 12 steps the last step was 0.002, it gives right away
   $$\frac{0.7}{0.3} \times 0.002 = 0.0047$$

**Answer:** 40 iterations guarantee an error below $10^{-6}$.
:::
:::

::: example
## Iterate $T(x) = \frac12\cos x$ from 0. Compare the a priori and a posteriori error bounds after three steps.

::: solution
1. **Contraction constant.**
   $$\lvert T'(x)\rvert = \frac12\lvert\sin x\rvert \le \frac12$$
   so q = ½.
2. **Iterate.** The iterates are 0.5, 0.438791, 0.452633, and the fixed point is 0.450184; the actual error after three steps is 0.00245.
3. **A priori bound.**
   $$\begin{aligned} \frac{q^3}{1 - q}\lvert x_1 - x_0\rvert &= \frac{0.125}{0.5} \times 0.5 \\ &= 0.125 \end{aligned}$$
4. **A posteriori bound.**
   $$\begin{aligned} \frac{q}{1 - q}\lvert x_3 - x_2\rvert &= 1 \times 0.0138 \\ &= 0.0138 \end{aligned}$$
5. **Compare.** The a posteriori bound, using the last step, is nine times sharper and is the one to stop on.

**Answer:** after three steps the a priori bound is 0.125 and the a posteriori bound is 0.0138, against an actual error of 0.00245.
:::
:::

::: check
given: q = 0.3 | 0.8; b = 2 | -5
answer: b/(1 - q)
tolerance: 0.01%

## Where's the fixed point of $T(x) = \given{q}x + (\given{b})$?

::: right
Right. $x = \frac{b}{1 - q}$ = {answer}.
:::

::: misses
- [b] Solve x = qx + b.
- [any] Not yet. $x(1 - q) = b$.
:::
:::

::: check
given: q = 0.5 | 0.9; d = 0.2 | 3; n = 10 | 30
answer: q^n/(1 - q)*d
tolerance: 0.5%

## A contraction with constant {q} first moves x by {d}. What's the a priori error bound after {n} steps?

::: right
Right. $\frac{q^n}{1 - q}d(x_1, x_0)$ = {answer}.
:::

::: misses
- [q^n*d] Include $\frac{1}{1 - q}$ for all the later steps.
- [any] Not yet. The geometric tail of the steps.
:::
:::

::: check
given: q = 0.6 | 0.8 | 0.95; s = 0.001 | 0.02
answer: q/(1 - q)*s
tolerance: 0.5%

## A contraction with constant {q} just took a step of {s}. What's the a posteriori bound on the remaining error?

::: right
Right. $\frac{q}{1 - q}d(x_n, x_{n-1})$ = {answer}.
:::

::: misses
- [s] The remaining steps add up to more than the last one: multiply by $\frac{q}{1 - q}$.
- [any] Not yet. $\frac{q}{1 - q}$ times the last step.
:::
:::

::: check
given: c = 0.3 | 0.6 | 0.9
answer: c
tolerance: 0.1%

## What's the smallest contraction constant valid on all of ℝ for $g(x) = \given{c}\cos x$?

::: right
Right. $\sup\lvert g'\rvert = \sup\lvert c\sin x\rvert$ = {answer}.
:::

::: misses
- [any] Not yet. Bound $\lvert g'\rvert$.
:::
:::

::: check
given: q = 0.6 | 0.85; d = 0.3 | 2; e = 0.000001 | 0.00000002
answer: ceil(ln(e*(1 - q)/d)/ln(q))
tolerance: 0

## How many iterations guarantee an error below {e} for q = {q} and a first step of {d}?

::: right
Right. {answer}.
:::

::: misses
- [any] Not yet. Smallest n with $\frac{q^nd}{1 - q} < \varepsilon$.
:::
:::

::: check
kind: choice

## $g(x) = x^2/4$ has $\lvert g'\rvert \le \frac12$ on [−1, 1]. Is it a contraction of [−1, 1] into itself, and what's its fixed point there?

- [x] Yes; its only fixed point in [−1, 1] is 0
- [ ] No, because it doesn't map [−1, 1] into itself
- [ ] Yes; its fixed point is 4
- [ ] No, because g′ can be 0

::: misses
- [2] Its values lie in [0, ¼], inside [−1, 1].
- [3] 4 is a fixed point, but not in [−1, 1].
- [4] A small derivative only helps.
:::
:::

::: check
kind: order

## Put the steps of the proof that a contraction has at most one fixed point in order.

1. Suppose Tx = x and Ty = y.
2. Then d(x, y) = d(Tx, Ty).
3. Since T is a contraction, d(Tx, Ty) ≤ q d(x, y).
4. So (1 − q) d(x, y) ≤ 0, and since q < 1, d(x, y) = 0.
5. Hence x = y.

::: right
Right. Uniqueness needs only the contraction; existence needs completeness too.
:::
:::

::: check
kind: parts
given: a = 0.5 | -0.3; b = 1 | 2; c = 0.4 | 0.6; d = -1 | 0.5

## $T(x, y) = (\given{a}y + \given{b},\; \given{c}x + \given{d})$ is a contraction in the max norm.

::: part
answer: (a*d + b)/(1 - a*c)
tolerance: 0.5%

### What is the fixed point's x?

::: misses
- [b] Substitute $y = cx + d$ into $x = ay + b$.
- [any] Solve $x = a(cx + d) + b$.
:::
:::

::: part
answer: c*(a*d + b)/(1 - a*c) + d
tolerance: 0.5%

### And its y?

::: misses
- [any] $y = cx + d$.
:::
:::
:::

::: check
kind: derivation
vars: q = -0.9..0.9, b = -2..2, x = -3..3, n = 1..20

## Iterate $T(x) = qx + b$ from $x_0 = x$.

::: step
answer: b/(1 - q)

### What is the fixed point?
:::

::: step
answer: q^n*(x - b/(1 - q))

### What is $x_n$ minus the fixed point?
:::

::: right
Right. The error shrinks by exactly q each step, which is what the contraction bound promises.
:::
:::

::: explain
## Why does the contraction mapping theorem need the space to be complete?

::: model
A contraction makes its iterates a Cauchy sequence: the steps shrink geometrically, so all later iterates lie in smaller and smaller regions. But a Cauchy sequence only converges if the space has a point for it to converge to. In an incomplete space it might be heading toward a hole: on the rationals, $g(x) = \frac x2 + \frac1x$ is a contraction near $\sqrt2$, yet it has no rational fixed point, because the limit $\sqrt2$ isn't there. Completeness guarantees the limit exists in the space, and continuity of the map then makes that limit the fixed point.
:::
:::

::: practice

::: check
given: q = 0.25 | 0.9; b = 3 | -1
answer: b/(1 - q)
tolerance: 0.01%

## Fixed point of $\given{q}x + (\given{b})$?

::: misses
- [any] $\frac{b}{1 - q}$.
:::
:::

::: check
given: q = 0.4 | 0.99; s = 0.0005 | 0.01
answer: q/(1 - q)*s
tolerance: 0.5%

## A posteriori bound, q = {q}, last step {s}?

::: misses
- [any] $\frac{q}{1 - q}s$.
:::
:::

::: check
given: q = 0.3 | 0.7; d = 1 | 0.05; n = 15 | 40
answer: q^n/(1 - q)*d
tolerance: 0.5%

## A priori bound, q = {q}, first step {d}, n = {n}?

::: misses
- [any] $\frac{q^n}{1 - q}d$.
:::
:::
:::
