Metric spaces, compactness and the Banach fixed-point theorem
Generalize convergence and continuity to metric spaces to reason simultaneously about ℝⁿ, function spaces and policy spaces. Covers topology of ℝⁿ, compactness and its consequences (extreme values and uniform continuity), completeness and Banach's fixed-point theorem, which later proves the inverse function and Picard–Lindelöf theorems and explains value iteration convergence.
After this lesson you can
- Verify metric and norm axioms and compare metrics induced by ℓ1, ℓ2 and ℓ∞.
- Characterize open, closed and compact sets in ℝⁿ (Heine–Borel) and explain why the characterization fails in infinite dimensions.
- Prove the extreme value and Heine–Cantor theorems.
- Prove Banach's fixed-point theorem with a priori and a posteriori error bounds.
- Implement fixed-point iterations with an error certificate and detect when a map is not contractive in the chosen norm.
Before you start
Motivation: iterate until it stops changing
Four problems that look nothing alike:
- Kepler. A planet’s position in its elliptical orbit at time requires solving , where is proportional to and is eccentricity. There is no closed formula for . The simplest approach iterates .
- Square roots. The Babylonian method calculates by iterating . After four steps from it has eleven correct decimal places.
- Value iteration. In a Markov decision process, optimal value function satisfies Bellman equation , where . The solving algorithm, foundational to dynamic programming and much of reinforcement learning, iterates .
- Differential equations. The solution of , , is the function satisfying . Picard proposed iterating that equality: the unknown is no longer a number or vector, but an entire function.
All four are the same problem: find a fixed point, an with , in a set that is , , the space of functions on states or a space of continuous functions. All four use the same algorithm, iterating . The questions are also the same: does a fixed point exist, is it unique, does iteration converge from any starting point, how fast, and when can I stop knowing my error?
Banach’s fixed-point theorem answers all five with one assumption: brings points closer by a fixed factor , in a space without holes. To state it once for all cases requires talking about distances without specifying the objects. That is a metric space. Along the way appears the other great existence argument in analysis, compactness, guaranteeing a continuous function attains its maximum and underlying existence of minimizers in optimization. We will see why both ideas, nearly free in , fail instructively in infinite dimensions, where functions live.
Metrics and norms
Three axioms, and almost everything you know about limits in survives. A sequence converges to in if , the sequence limit notion with replaced by . The limit is unique because if and , the triangle inequality gives . Examples we will use:
- with for .
- Any subset with restricted distance: , or the unit sphere are metric spaces in their own right.
- The discrete metric, if : every set is a metric space with it.
- Hamming distance between bit strings of length : the number of positions where they differ. It is the metric of error-correcting codes.
- , continuous functions on , with : the largest vertical separation between graphs. This is the space of Picard iteration.
- Bounded functions on a state set , with : the value-iteration space.
Nearly all these metrics come from a norm: a function on a vector space with only if , and . Every norm induces metric , also invariant under translations and scaling with homotheties. The discrete metric does not come from a norm: for , .
The norms and why
In , and , the limit of as . For the triangle inequality is Minkowski’s. For the expression still makes sense, but fails: with and ,
There is a geometric way to see which condition fails.
Proof
If is a norm and , for we have . Conversely, suppose convex and take nonzero (if one is zero there is nothing to prove). Points and lie in , and with their convex combination is
By homogeneity, .
∎The figure shows more than convexity. The three metrics , and always order the distance between two points the same way and never differ by more than a fixed factor:
The first inequality follows from ; the second from expanding , containing all and nonnegative cross terms; the third is Cauchy–Schwarz applied to and ; the fourth follows because each . All are optimal: gives equality in the first two and in the last two.
Two norms and are equivalent if there exist constants with for every . Equivalent norms have the same convergent sequences, Cauchy sequences and, as we will see, open sets: qualitatively they are interchangeable. In this is not a coincidence of the norms. Once we have compactness, we will prove all norms on are equivalent. But the constants depend on : in , can be a thousand times . For quantitative matters such as a contraction constant, the norm matters greatly, and in infinite dimensions equivalence disappears entirely.
Topology of : open and closed sets, continuity
In a metric space, the open ball with center and radius is , and the closed ball is .
Open balls are open: if , with the triangle inequality gives . A similar argument shows closed balls are closed. Open and closed are not opposites: is neither, and and are both. In , has empty interior (every interval contains irrationals) and closure (every interval contains rationals), so its boundary is all . Arbitrary unions of open sets are open, and finite intersections too, but not infinite ones: .
The most used characterization of closed sets is sequential: a closed set cannot be left by taking limits.
Proof
Suppose closed, and . If , since is open there is a ball disjoint from ; but for large , contradiction. Conversely, suppose contains limits of its sequences and is not open. Then there is such that every ball contains a point . That sequence converges to , contradiction. The assertion about uses the same argument: if and only if each contains some .
∎Continuity without epsilons
A function between metric spaces is continuous at if for each there is with whenever ; as in , this is equivalent to preserving sequence limits (continuity in lesson 1). Every Lipschitz function, , is continuous with . The global reformulation without or uses the preimage.
Proof
Suppose continuous, open and . Since , there is with , and continuity gives with , that is, . Conversely, given and , set is open and contains , so contains a ball : this is . The closed-set version follows from .
∎This theorem makes trivial what would be tedious with sequences. If is continuous, is open and and are closed. Thus the feasible set of a problem with continuous constraints , is closed; probability simplex is closed; sphere is closed.
Compactness
In , Bolzano–Weierstrass says every bounded sequence has a convergent subsequence. To prevent the limit escaping the set, the set must be closed. Sets with no possible escape are compact.
In any metric space, compact implies closed and bounded. Closed, because if converges to , the compactness subsequence converges to a point of , and uniqueness makes that point . Bounded, because otherwise there would be with and no subsequence could converge (a convergent sequence is bounded). In the converse holds.
Proof
We have seen the forward implication. If is closed and bounded and is a sequence in , Bolzano–Weierstrass in (applied coordinate by coordinate, extracting successive subsequences) gives a subsequence converging to some , and since is closed, .
∎Thus the closed ball, sphere, simplex and every bounded set with continuous are compact. The next figure shows what breaks when each assumption is removed. Its animation follows the Bolzano–Weierstrass proof: bisect the interval, retain the half containing infinitely many terms (in the figure, the one containing more of the first 600) and choose a term inside, repeatedly. Nested intervals close onto a point; the question is whether that point lies in the set.
Why it fails in infinite dimensions
Space consists of real sequences with , and its norm is . It is the analogue of with infinitely many coordinates and a model of function spaces: Fourier coefficients of a square-integrable function form an element of . Its closed unit ball is closed (it is the preimage of under the continuous norm) and bounded. But it is not compact. Canonical basis vectors lie in it and satisfy
No subsequence can converge, because any two terms are distance apart: it is not even Cauchy. In infinite dimensions there is room for infinitely many mutually distant directions inside a bounded ball. This is general (Riesz’s theorem): the closed unit ball of a normed space is compact if and only if its dimension is finite.
The practical consequence is that existence in function spaces cannot be proved by “closed and bounded.” The set of continuous functions on with is closed and bounded in , but has no uniformly convergent subsequence (the pointwise limit is 0 on and 1 at , and is not continuous). Compactness in function spaces requires more, the equicontinuity of Arzelà–Ascoli, appearing with uniform convergence.
Consequences of compactness
Compactness is useful because continuous functions preserve it.
The proof has three lines and you will do it in a guided exercise at the end. Its corollary is analysis’s most-used existence result.
This is the extreme value theorem. By the preceding theorem, is a compact subset of , hence closed and bounded; its supremum exists by real completeness and is a limit of points of , so belongs to because it is closed. The guided exercise reconstructs this step too. Notice what the preceding figure says: every assumption is necessary. On , and there are continuous, even bounded, functions without maxima, and so on the ball of : is continuous (indeed by Cauchy–Schwarz), equals at and never reaches 1, because if and .
All norms on are equivalent
Proof
Upper bound. Write . By the triangle inequality and Cauchy–Schwarz, with . In particular, , so is a continuous (Lipschitz) function on .
Lower bound. Sphere is closed and bounded, hence compact by Heine–Borel. By the extreme value theorem, attains a minimum on , and because . For , , and by homogeneity .
If and are two norms, compare both with .
∎Compactness was only used for the lower bound, precisely what fails in infinite dimensions. In the space of finitely supported sequences, with ones has and : no satisfies .
The same scheme proves existence of minimizers in optimization. If is continuous and coercive ( as ), sublevel set is closed (preimage of a closed set) and bounded (by coercivity), hence compact, and attains its minimum there, the global minimum. Least-squares loss with regularization is coercive; logistic loss on linearly separable data is not, and indeed has no minimizer: weights grow without bound.
Uniform continuity
In the definition of continuity, may depend on the point. For on , the closer to 0, the smaller must be for the same , and no works for every point at once.
Every Lipschitz function is uniformly continuous, with . The converse is false: on is uniformly continuous because , but is not Lipschitz because its slope is infinite at 0. And on is continuous but not uniformly: , so points distance apart have images more than 2 apart. In both examples of continuous functions not uniformly continuous, on and on , the domain is not compact, and the next theorem says this is no coincidence.
Proof
Otherwise there would be such that for each there are points with and . By compactness, a subsequence converges to some , and since , so does . By continuity at , and , so , contradicting .
∎Uniform continuity enables discretization. If is continuous on , for every tolerance there is a mesh of step whose piecewise-linear interpolation of is within of at every point: this is the argument for integrability of continuous functions in the Riemann integral and the simplest idea behind universal approximation theorems.
Completeness
You already know Cauchy sequences: in a metric space, is Cauchy if for each there is with for all . Every convergent sequence is Cauchy because . The converse depends on the space.
Completeness lets us prove something exists without knowing where in advance: prove a sequence stabilizes, and the space supplies its limit. Examples:
- is complete: another form of its supremum axiom. is not: Babylonian iterations from are all rational, Cauchy and converge to .
- is complete under any norm. With , if is Cauchy, each coordinate is because ; each coordinate converges in and the vector of limits is the limit. For another norm use equivalence.
- A subset of a complete space is complete if and only if closed. Thus and any compact subset of are complete, and is not.
- with is complete: the uniform limit of continuous functions is continuous. This is supremum-norm completeness, proved in lesson 14 and making Picard iteration work. With distance , however, is not complete: increasingly steep ramps are Cauchy and approach a step function, which is not continuous.
- Every compact space is complete: if a Cauchy sequence has a convergent subsequence, the whole sequence converges to the same limit.
Banach’s fixed-point theorem
This is the Banach fixed-point theorem, also called the contraction mapping principle. Besides the four opening problems, it is the tool you will use to prove the inverse function theorem (lesson 10) and Picard–Lindelöf for differential equations. You will prove existence and uniqueness step by step in the guided exercise; the idea is that steps decrease geometrically, so the sequence is Cauchy, completeness supplies its limit, and continuity of makes it a fixed point. Here we prove the bounds, what you will use in code.
Proof
(5) Since , .
(4) By the triangle inequality and (5), , giving . Applying (5) once more, .
(3) By induction, . Substituting in (4), .
∎The two bounds play different roles. The a priori bound says before starting how many iterations suffice: gives
The a posteriori bound is a certificate calculated during iteration using what you already have, and is usually much tighter. Both depend on knowing a valid , and linear convergence guarantees the number of correct digits grows at least like : with you gain at least one digit per 22 iterations; with , one per 3.3. This is linear convergence from lesson 3.
Every assumption is necessary
- Completeness. maps into itself (its image is in ) and is contractive with , because on . But it has no fixed point in : the only candidate is .
- The uniform constant . on , which is complete, satisfies for , because . But always: no fixed point exists. Ratio approaches 1 as , and no works for every pair.
- must map into . To apply the theorem on a closed of check . Forgetting this is the most common mistake when using it on an interval.
The local version and speed
In practice a global contraction is unnecessary. If is class near a fixed point with , continuity gives a closed interval on which . By the mean value theorem, on , and in particular , so . is complete and Banach applies: iteration converges from any close enough. The mean value theorem also says with between and , so
The actual rate is , possibly much smaller than global constant . If , the fixed point repels: nearby errors grow. And if and is class , Taylor expansion gives : quadratic convergence, doubling correct digits each step. Newton’s method, , does this: at a simple root of . Babylonian iteration is Newton for (studied as Newton–Raphson).
Logistic map is the classic example of what happens without contraction. Its nonzero fixed point is , with . For , and iteration converges in a zigzag because the derivative is negative. For , : the fixed point exists but repels, and the orbit falls into an attracting period-4 cycle (). For there is not even an attracting cycle: this is the chaotic regime, where two very close starting points separate exponentially. No fixed-point theorem says anything useful there, and that is a lesson: when iteration fails to converge, first check contractivity.
In Kepler’s equation, satisfies throughout , so is a global contraction with constant and iteration converges for every elliptical eccentricity from any . For near 1 convergence is slow and Newton is used, but Banach’s fixed-point theorem guarantees the solution exists and is unique.
Contractivity depends on the norm
In all norms give the same limits but not the same contractions. The clearest example is the affine case, , the model for every linear iterative method. For any norm,
where is the induced norm, . The bound is exact (some attains it), so is a contraction in that norm if and only if , and the best constant is . Three easy ones are , largest absolute column sum; , largest absolute row sum; and , largest singular value. Geometrically, means maps the norm’s unit ball inside itself.
They can disagree. has and : none of the three certifies anything. Yet its only eigenvalue is , and . What decides convergence is not any particular norm but the spectral radius.
Proof
(2) ⇒ (3) is Banach, because is complete under any norm.
(3) ⇒ (1). With , the assumption says converges for every , and limit satisfies . If is an eigenvalue with eigenvector , both limits and exist, so converges. This requires or . To exclude use : if with nonzero real and you take and , iterates are , which do not converge.
(1) ⇒ (2). Choose with . By Gelfand’s formula, , so for some and the following series converges:
It is a norm: a sum of seminorms with first term . And . Thus .
∎Norm is tailored to : it weights directions initially stretches more heavily. In practice something simpler sometimes suffices. With and , the induced norm is . For the earlier matrix, , which contracts in once : with , .
The Bellman operator contracts in the supremum norm
For a fixed policy , the Bellman evaluation equation is affine: , where is transition probability from to . Rows of are nonnegative and sum to 1, so and : is a contraction with constant in for any transition matrix. In there is no guarantee. With and two states both leading to the second with probability , has : two value functions can move farther apart in after one evaluation step.
The optimality operator, with its , is no longer affine but remains a contraction in the same norm. The key is an elementary inequality: for functions on a finite action set, . (If the first maximum is attained at and is the larger of the two, ; the other case is symmetric.) With and similarly with ,
Taking the supremum over , . Bounded functions on with supremum norm form a complete space (even if is infinite), and Banach gives existence and uniqueness of , convergence of value iteration from any and its stopping criterion at once. This is Bellman operator contraction, the foundation of value iteration.
The same analysis certifies iterative linear-system methods. Jacobi’s method for iterates , with the diagonal of . If is strictly row diagonally dominant, each row of has absolute sum below 1, iteration is a contraction in and converges (see stationary iterative methods).
Implementation from scratch
The following function iterates and stops when the a posteriori bound drops below tolerance. It returns point, iteration count and bound, an error certificate if really is a contraction with constant in the chosen metric. Apply it to Kepler’s equation with and .
import math
import numpy as np
import matplotlib.pyplot as plt
def fixed_point(g, x0, q, tol=1e-10, max_iter=10_000, dist=None):
"""Itera x_{k+1} = g(x_k) hasta que la cota a posteriori q/(1-q) d(x_k, x_{k-1}) baje de tol.
Devuelve (x, k, cota, historial). La cota solo es un certificado si g es una contracción
de constante q en la métrica dist sobre un conjunto cerrado que g deja invariante."""
if not 0 <= q < 1:
raise ValueError("q debe estar en [0, 1)")
if dist is None: # por defecto, la distancia del supremo (|x - y| para escalares)
dist = lambda a, b: float(np.max(np.abs(np.asarray(a) - np.asarray(b))))
x, historial = x0, [x0]
for k in range(1, max_iter + 1):
x_nuevo = g(x)
paso = dist(x_nuevo, x)
historial.append(x_nuevo)
x = x_nuevo
cota = q / (1 - q) * paso
if cota < tol:
return x, k, cota, historial
raise RuntimeError(f"sin certificado tras {max_iter} iteraciones (cota {cota:.2e})")
def iteraciones_a_priori(q, d01, tol):
"""Menor k con q^k/(1-q) d(x1, x0) < tol."""
return max(0, math.ceil(math.log(tol * (1 - q) / d01) / math.log(q)))
# Ecuación de Kepler: E = M + e sen E, contracción en R con q = e
e, M, tol = 0.5, 1.0, 1e-10
g = lambda E: M + e * math.sin(E)
E, k, cota, hist = fixed_point(g, M, q=e, tol=tol)
k_prev = iteraciones_a_priori(e, abs(g(M) - M), tol)
E_ref = hist[-1]
for _ in range(50):
E_ref = g(E_ref) # referencia: iterar hasta el punto fijo en coma flotante
k_real = next(i for i, x in enumerate(hist) if abs(x - E_ref) < tol)
print(f"E* = {E:.12f} residuo |g(E) - E| = {abs(g(E) - E):.1e}")
print(f"a priori: {k_prev} iteraciones a posteriori: se detiene en k = {k} error real < tol desde k = {k_real}")
print(f"cota certificada {cota:.1e} error real {abs(E - E_ref):.1e}")
errs = [abs(x - E_ref) for x in hist[:8]]
print("cocientes e_k/e_(k-1):", [round(errs[i + 1] / errs[i], 4) for i in range(1, 6)], " e cos E* =", round(e * math.cos(E_ref), 4))
ks = np.arange(len(hist))
d01 = abs(hist[1] - hist[0])
plt.semilogy(ks, [max(abs(x - E_ref), 1e-17) for x in hist], "o-", label="error real")
plt.semilogy(ks, e**ks / (1 - e) * d01, "--", label="cota a priori")
plt.semilogy(ks[1:], [e / (1 - e) * abs(hist[i] - hist[i - 1]) for i in ks[1:]], "s-", label="cota a posteriori")
plt.axhline(tol, color="gray", lw=0.8)
plt.xlabel("iteración k"); plt.ylabel("|E_k − E*|"); plt.legend(); plt.show()The a priori bound requires 33 iterations; the a posteriori bound certifies error at the ninth, and actual error was already below at the eighth. The difference has a precise cause: the bound uses global constant , worst-case over all , while near the solution the actual rate is , as error ratios show. The a posteriori bound benefits from small actual steps despite still using pessimistic . That is its value: it adapts to reality and remains a guarantee.
Now a Bellman operator in a three-state, two-action MDP with . Iteration lives in with the supremum norm, the default distance of fixed_point.
# MDP de 3 estados y 2 acciones. P[a][s, s'] = probabilidad de pasar de s a s' con la acción a.
P = np.array([
[[0.9, 0.1, 0.0], # a = 0, «esperar»: casi siempre se queda donde está
[0.0, 0.9, 0.1],
[0.0, 0.0, 1.0]],
[[0.1, 0.9, 0.0], # a = 1, «avanzar»: empuja hacia el estado 2... salvo desde el 2,
[0.0, 0.1, 0.9], # que vuelve al 0
[0.9, 0.0, 0.1]],
])
R = np.array([[0.0, -1.0], # R[s, a]: avanzar cuesta, estar en el estado 2 paga
[0.0, -1.0],
[2.0, 0.0]])
gamma, tol = 0.9, 1e-6
def bellman(V):
Q = R + gamma * np.einsum("ast,t->sa", P, V) # Q[s, a] = R[s, a] + γ Σ_s' P[a][s, s'] V[s']
return Q.max(axis=1)
V0 = np.zeros(3)
V, k, cota, hist = fixed_point(bellman, V0, q=gamma, tol=tol)
k_prev = iteraciones_a_priori(gamma, np.max(np.abs(bellman(V0) - V0)), tol)
# referencia exacta: con la política voraz, V* resuelve el sistema lineal (I - γ P_π) V = R_π
pi = (R + gamma * np.einsum("ast,t->sa", P, V)).argmax(axis=1)
P_pi = P[pi, np.arange(3)]
R_pi = R[np.arange(3), pi]
V_star = np.linalg.solve(np.eye(3) - gamma * P_pi, R_pi)
k_real = next(i for i, W in enumerate(hist) if np.max(np.abs(W - V_star)) < tol)
print("política óptima:", ["esperar" if a == 0 else "avanzar" for a in pi])
print("V* =", np.round(V_star, 6))
print(f"a priori: {k_prev} a posteriori: k = {k} error real < tol desde k = {k_real}")
print(f"cota certificada {cota:.2e} error real {np.max(np.abs(V - V_star)):.2e}")
paso = [np.max(np.abs(hist[i + 1] - hist[i])) for i in range(len(hist) - 1)]
print("cociente de pasos al final:", round(paso[-1] / paso[-2], 4))
print(f"‖γ P_π‖_∞ = {np.abs(gamma * P_pi).sum(axis=1).max():.3f} ‖γ P_π‖_2 = {np.linalg.norm(gamma * P_pi, 2):.3f}")Here all three numbers agree: 160 iterations a priori, 160 a posteriori and 160 actual, and the certified bound equals actual error. This is no coincidence. The optimal policy stays forever in state 2, paying 2 per step, so and error in that state is exactly , what both bounds say. This MDP is the theorem’s worst case: actual rate is and the bounds cannot be improved. The last line confirms that policy evaluation is a contraction in with constant but not in , where the induced norm is .
With libraries: scipy.optimize.fixed_point
SciPy provides scipy.optimize.fixed_point(func, x0, xtol=1e-08, maxiter=500, method='del2'). By default it does not merely iterate : it applies Steffensen acceleration. At each step it calculates and and jumps to
Aitken’s extrapolation, exact if errors decreased in an exact geometric progression. If is class near and , convergence order is 2, at the price of two evaluations of per step. It stops when relative step falls below xtol. Measure observed order by recording where is evaluated.
from scipy.optimize import fixed_point as fixed_point_scipy
def registrar(g):
"""Envuelve g para guardar cada punto en el que se evalúa."""
llamadas = []
def h(x):
llamadas.append(float(x))
return g(x)
return h, llamadas
def orden_observado(errores):
"""p_k = log(e_{k+1}/e_k) / log(e_k/e_{k-1}): tiende al orden de convergencia."""
e = [x for x in errores if x > 0]
return [round(math.log(e[i + 1] / e[i]) / math.log(e[i] / e[i - 1]), 2) for i in range(1, len(e) - 1)]
kepler = lambda E: 1.0 + 0.5 * math.sin(E) # E_ref viene de la primera celda
for metodo in ["iteration", "del2"]:
h, llamadas = registrar(kepler)
E = fixed_point_scipy(h, 1.0, xtol=1e-14, method=metodo)
paso = 1 if metodo == "iteration" else 2 # Steffensen evalúa g dos veces por paso
errores = [abs(x - E_ref) for x in llamadas[::paso]]
print(f"{metodo:9s} evaluaciones de g: {len(llamadas):2d} error final {abs(E - E_ref):.1e}")
print(" errores:", [f"{x:.1e}" for x in errores[:6]])
print(" orden observado:", orden_observado(errores[:6]))
# Steffensen no necesita una contracción: converge al punto fijo repulsor de la logística
logistica = lambda x: 3.5 * x * (1 - x)
x = fixed_point_scipy(logistica, 0.3, xtol=1e-12)
print(f"\nlogística r = 3.5, del2: x = {x:.12f} (1 - 1/r = {1 - 1/3.5:.12f}, |g'(x*)| = 1.5)")
# ... y puede «converger» donde no hay ningún punto fijo
g_sin = lambda x: x + 1 / x
x_falso = fixed_point_scipy(g_sin, 1.0)
print(f"x + 1/x, del2: devuelve x = {x_falso:.2f} con g(x) - x = {g_sin(x_falso) - x_falso:.1e}")Three results, each with a lesson:
- Order. For Kepler, simple iteration has observed order 1 (errors divide by about 27 each step, the reciprocal of ) and Steffensen order 2: it goes from to to . With 8 evaluations of it reaches machine precision; simple iteration needs 11 for the same tolerance. When is expensive (a simulation step, policy evaluation), the difference matters.
- The logistic map with . Simple iteration never reaches because it repels, and falls into the period-4 cycle from the cobweb. Steffensen converges to it. Acceleration is not fixed-point iteration of but a secant-type method applied to , and does not require to contract. In exchange it loses Banach’s global guarantee.
- , which has no fixed point. SciPy returns without warning. Steffensen iterates roughly double each step until denominator rounds to 0 in floating point; SciPy then takes , the relative step is and the criterion is satisfied. A small step is not a certificate. times the step is one, and only if is a proven contraction constant.
For systems, fixed_point accepts arrays and accelerates each component separately. For large problems (Picard on a grid, fixed points of implicit networks), Anderson acceleration combines several earlier iterates and is available in scipy.optimize.anderson. Their analysis is in fixed-point iterations in numerical methods.
Common mistakes
Exercises
Step 1 of 4. How do you control distance between consecutive iterates?
More than one answer may be correct.
More than one answer may be correct.
Step 1 of 3. Take a sequence in . What is the first step?
is_contraction_affine(A, norm), deciding whether is a contraction in norm , or of (norm is 1, 2 or np.inf). Return a tuple (es_contraccion, q) with induced norm q of and q < 1. Compute each induced norm using its formula (column sums, singular values, row sums) rather than calling np.linalg.norm(A, ord). If A is not square or norm is not one of the three, raise ValueError.import numpy as np
def is_contraction_affine(A, norm):
"""Devuelve (es_contraccion, q), con q la norma inducida de A en l1, l2 o linf."""
A = np.asarray(A, dtype=float)
# tu código: comprueba la forma, calcula q según norm y compáralo con 1
q = max(abs(np.linalg.eigvals(A))) # ¡el radio espectral no es una norma inducida!
return bool(q < 1), float(q)Summary
- A metric space is a set with a distance satisfying separation, symmetry and triangle inequality. norms with induce metrics; for the ball ceases to be convex and the triangle inequality fails. In all norms are equivalent, with constants depending on .
- Closed sets contain limits of their sequences, and is continuous if and only if preimages of open sets are open.
- Compact means every sequence has a subsequence converging inside. In it is equivalent to closed and bounded (Heine–Borel); in the unit ball is closed and bounded but not compact.
- On a compact set every continuous function attains a maximum and minimum (Weierstrass) and is uniformly continuous (Heine–Cantor). With coercivity this gives existence of minimizers.
- Complete means Cauchy sequences converge: and with supremum norm are complete; and are not.
- Banach: a contraction on a complete space implies a unique fixed point, linear convergence with rate and bounds and . The local rate is ; if 0, convergence is quadratic, as in Newton.
- contracts in a norm if and only if the induced norm is below 1, and such a norm exists if and only if . The Bellman operator contracts by factor in the supremum norm, so value iteration converges.