Book 2B

© 2026 Neckpinch · www.neckpinch.com · All rights reserved.

Course 2Book 2B: Spaces, Functions and ChangeChapter 1

Metric Spaces

Distance between points, strings, functions and places on Earth, and the topology it defines.

59 min read · Updated Nov 16, 2026

Read with Tao, Analysis II, chapter "Metric spaces": the definitions and examples, "Some point-set topology of metric spaces" and "Relative topology". The sections on Cauchy sequences and compact metric spaces go with chapters 2B.2 and 2B.3.

In this chapter · 9 sections
  1. 1.1Distance, in general
  2. 1.2A zoo of metric spaces
  3. 1.2.1Three metrics on Rn\mathbb{R}^nRn
  4. 1.2.2The sphere
  5. 1.2.3Discrete spaces, codes and strings
  6. 1.2.4Networks and distributions
  7. 1.3Spaces of functions
  8. 1.4Open and closed sets
  9. 1.5Continuous maps
  10. 1.6Subspaces and relative topology
  11. 1.7Equivalent and inequivalent metrics
  12. 1.8History
  13. 1.9Exercises
  14. ↗Free resources

Book 2A was about one space, the real line, and one way of measuring distance in it, ∣x−y∣|x - y|. Almost everything proved there used only a few properties of that distance: it is never negative, it is zero only between a point and itself, it is symmetric, and it obeys the triangle inequality. This chapter takes those four properties as a definition. Anything that satisfies them is a metric, and a set with a metric is a metric space.

The gain is enormous. Points on the Earth, strings of letters, binary codewords, continuous functions and (much later) whole geometric shapes all carry natural metrics. Once they do, convergence, continuity, open and closed sets, completeness and compactness all make sense for them, with the same definitions and often the same proofs as on R\mathbb{R}. The route to Perelman runs through several such spaces: spaces of functions in Courses 3, 4 and 6, a Riemannian manifold viewed as a metric space in 9A.3 Geodesics and the Exponential Map, and finally a space whose points are themselves metric spaces, in which limits of Ricci flows are taken (9B.4 Convergence of Manifolds).

By the end of this chapter you will be able to:

  • check the four axioms of a metric, and recognise the standard metrics on Rn\mathbb{R}^n, on spheres, on strings and on function spaces;
  • define open and closed balls, open and closed sets, interior, closure and boundary, and prove the basic facts that connect them to convergent sequences;
  • compute interior, closure and boundary of concrete sets, and use their basic properties;
  • define continuity between metric spaces, and use its four equivalent forms (ε–δ, sequences, open sets, closed sets);
  • work with subsets of a metric space, and tell "open in YY" from "open in XX";
  • decide whether two metrics on the same set are equivalent, and show that two natural metrics on continuous functions are not;
  • compute great-circle, taxicab, Hamming and edit distances, and say what the triangle inequality buys in each case.

Distance, in general

In the world Data New York to Hong Kong over the Arctic

John F. Kennedy airport in New York is at about 40.64° N, 73.78° W, and Hong Kong International at about 22.31° N, 113.92° E. On a flat Mercator map the obvious route runs west across North America and the Pacific. But the shortest path along the surface of the Earth is an arc of a great circle, the intersection of the sphere with a plane through its centre. Treating the Earth as a sphere of radius 63716371 km, that arc is about 12,97012{,}970 km long, and it passes within about 6° of the North Pole (Figure 1.3).

Airlines know this. When Cathay Pacific announced its nonstop Hong Kong–New York service in 2001, the announcement said it would fly over the North Polar region, saving more than two hours each way compared with the North Pacific routing. (Real routes also bend to follow winds and airspace, so an actual flight track is close to the great circle, not on it.)

The distance an aircraft cares about is not the distance in any map. It is measured on the sphere, and it differs from the straight-line distance through the Earth and from the distance a ruler measures on a chart. Each of these is a legitimate way of measuring distance between the same pairs of points, and each obeys the same four rules.

Definition 1.1 Metric space

A metric space (X,d)(X, d) is a set XX with a function d:X×X→[0,∞)d : X \times X \to [0, \infty), the metric or distance, such that for all x,y,z∈Xx, y, z \in X:

  1. d(x,x)=0d(x, x) = 0;
  2. (positivity) d(x,y)>0d(x, y) > 0 if x≠yx \neq y;
  3. (symmetry) d(x,y)=d(y,x)d(x, y) = d(y, x);
  4. (triangle inequality) d(x,z)≤d(x,y)+d(y,z)d(x, z) \leq d(x, y) + d(y, z).

The triangle inequality carries nearly all of the weight. It says that a detour through yy can't be shorter than going directly. In every argument of 2A.6 Sequences and 2A.9 Continuous Functions that split ∣a−c∣|a - c| into ∣a−b∣+∣b−c∣|a - b| + |b - c|, the triangle inequality for dd does the same job here, and those arguments carry over word for word.

A useful consequence, the reverse triangle inequality, says that distances to a fixed point change no faster than the point moves:

∣d(x,z)−d(y,z)∣≤d(x,y).|d(x, z) - d(y, z)| \leq d(x, y).

(Apply the triangle inequality twice, once with yy as the detour and once with xx.)

What each axiom rules out. Each of the four rules excludes something that occurs in practice, and seeing the exclusions makes the rules less arbitrary.

  • Without positivity, distinct points can be at distance 00. On continuous functions, d(f,g)=∣f(0)−g(0)∣d(f, g) = |f(0) - g(0)| satisfies every axiom except positivity: it cannot tell apart two functions with the same value at 00. Such a pseudometric is repaired by declaring points at distance 00 to be the same point, which produces a genuine metric on the classes (2A.2 Sets, Functions and Equivalence). This is exactly how the Lebesgue spaces of Course 3 are built, where functions that differ only on a set of length zero are identified (3A.7 Lᵖ Spaces and Jensen’s Inequality).
  • Without symmetry, the distance from xx to yy can differ from the distance back. Travel time in a city with one-way streets, or on foot up and down a hill, is like this. Such quasi-metrics are useful, but this guidebook never needs them.
  • Without the triangle inequality, almost nothing of this chapter survives. Squared Euclidean distance ∣x−y∣2|x - y|^2 is positive and symmetric, but on the line the points 00, 11, 22 give ∣0−2∣2=4>1+1|0 - 2|^2 = 4 > 1 + 1: a detour through 11 is "shorter" than going directly. The square is a natural quantity, and it appears in least squares and in energies, but it is not a distance. Its square root is.
Definition 1.2 Convergence

A sequence (xn)(x_n) in a metric space (X,d)(X, d) converges to x∈Xx \in X if d(xn,x)→0d(x_n, x) \to 0 as a sequence of real numbers; that is, for every ε>0\varepsilon > 0 there is an NN with d(xn,x)≤εd(x_n, x) \leq \varepsilon for all n≥Nn \geq N.

Limits are unique: if xn→xx_n \to x and xn→yx_n \to y, then d(x,y)≤d(x,xn)+d(xn,y)→0d(x, y) \leq d(x, x_n) + d(x_n, y) \to 0, so d(x,y)=0d(x, y) = 0 and x=yx = y by positivity. This is the first place positivity is used. Without it, "the limit" would not make sense.

A zoo of metric spaces

Three metrics on Rn\mathbb{R}^n

For points x=(x1,…,xn)x = (x_1, \dots, x_n) and y=(y1,…,yn)y = (y_1, \dots, y_n) of Rn\mathbb{R}^n there are three standard distances:

dℓ2(x,y)=(∑i=1n(xi−yi)2)1/2,dℓ1(x,y)=∑i=1n∣xi−yi∣,dℓ∞(x,y)=max⁡i∣xi−yi∣.d_{\ell^2}(x, y) = \Big(\sum_{i=1}^n (x_i - y_i)^2\Big)^{1/2}, \quad d_{\ell^1}(x, y) = \sum_{i=1}^n |x_i - y_i|, \quad d_{\ell^\infty}(x, y) = \max_{i} |x_i - y_i|.

The first is the Euclidean metric, the ruler distance. The second is the taxicab metric, the distance travelled along a grid of streets. The third is the sup (or maximum) metric, the largest disagreement in any one coordinate.

For dℓ1d_{\ell^1} and dℓ∞d_{\ell^\infty}, the triangle inequality follows coordinate by coordinate from the one on R\mathbb{R}. For the Euclidean metric it needs one idea.

Lemma 1.3 Cauchy–Schwarz

For u,v∈Rnu, v \in \mathbb{R}^n, ∣∑iuivi∣≤(∑iui2)1/2(∑ivi2)1/2\big|\sum_i u_i v_i\big| \leq \big(\sum_i u_i^2\big)^{1/2}\big(\sum_i v_i^2\big)^{1/2}.

Proof. Write u⋅v=∑uiviu \cdot v = \sum u_i v_i and ∥u∥=(u⋅u)1/2\|u\| = (u \cdot u)^{1/2}. If v=0v = 0 there is nothing to prove. Otherwise, for every real tt,

0≤∥u−tv∥2=∥u∥2−2t (u⋅v)+t2∥v∥2.0 \leq \|u - t v\|^2 = \|u\|^2 - 2t\,(u \cdot v) + t^2\|v\|^2.

A quadratic in tt that is never negative has discriminant at most 00: 4(u⋅v)2−4∥u∥2∥v∥2≤04(u\cdot v)^2 - 4\|u\|^2\|v\|^2 \leq 0.

With u=x−yu = x - y and v=y−zv = y - z, expanding ∥u+v∥2=∥u∥2+2 u⋅v+∥v∥2≤(∥u∥+∥v∥)2\|u + v\|^2 = \|u\|^2 + 2\,u\cdot v + \|v\|^2 \leq (\|u\| + \|v\|)^2 gives dℓ2(x,z)≤dℓ2(x,y)+dℓ2(y,z)d_{\ell^2}(x, z) \leq d_{\ell^2}(x, y) + d_{\ell^2}(y, z).

The three metrics give the same answer on the real line, and different answers in the plane. The clearest way to see the difference is to draw each one's unit ball, the set of points at distance less than 11 from the origin.

Figure 1.1. The unit balls of dℓ1d_{\ell^1} (diamond), dℓ2d_{\ell^2} (disc) and dℓ∞d_{\ell^\infty} (square) in R2\mathbb{R}^2. They are nested because dℓ∞≤dℓ2≤dℓ1d_{\ell^\infty} \leq d_{\ell^2} \leq d_{\ell^1}: a smaller distance means a larger ball.

Whatever their differences, the three metrics agree about which sequences converge, and convergence turns out to be something you can check one coordinate at a time.

Proposition 1.4 Convergence in Rn\mathbb{R}^n is coordinatewise

Let x(k)=(x1(k),…,xn(k))x^{(k)} = (x^{(k)}_1, \dots, x^{(k)}_n) be a sequence in Rn\mathbb{R}^n and x∈Rnx \in \mathbb{R}^n. The following are equivalent: x(k)→xx^{(k)} \to x in dℓ2d_{\ell^2}; in dℓ1d_{\ell^1}; in dℓ∞d_{\ell^\infty}; and xi(k)→xix^{(k)}_i \to x_i in R\mathbb{R} for each coordinate i=1,…,ni = 1, \dots, n.

Proof. For each ii, ∣xi(k)−xi∣≤dℓ∞(x(k),x)≤dℓ2(x(k),x)≤dℓ1(x(k),x)|x^{(k)}_i - x_i| \leq d_{\ell^\infty}(x^{(k)}, x) \leq d_{\ell^2}(x^{(k)}, x) \leq d_{\ell^1}(x^{(k)}, x). So convergence in dℓ1d_{\ell^1} implies convergence in dℓ2d_{\ell^2}, which implies convergence in dℓ∞d_{\ell^\infty}, which implies convergence of every coordinate. Conversely, suppose every coordinate converges, and let ε>0\varepsilon > 0. For each ii choose NiN_i with ∣xi(k)−xi∣≤ε/n|x^{(k)}_i - x_i| \leq \varepsilon/n for k≥Nik \geq N_i, and let N=max⁡(N1,…,Nn)N = \max(N_1, \dots, N_n). For k≥Nk \geq N, dℓ1(x(k),x)=∑i∣xi(k)−xi∣≤εd_{\ell^1}(x^{(k)}, x) = \sum_i |x^{(k)}_i - x_i| \leq \varepsilon.

The step "N=max⁡(N1,…,Nn)N = \max(N_1, \dots, N_n)" uses that there are finitely many coordinates. In a space of infinite sequences it fails: the sequences e(k)=(0,…,0,1,0,… )e^{(k)} = (0, \dots, 0, 1, 0, \dots), with a single 11 in position kk, converge to 00 in every coordinate, yet each is at sup-distance 11 from 00 (Exercise 1.28). This is the first of many places where finite and infinite dimensions part company.

In the world Model The taxicab metric in Manhattan

On a grid of streets, a pedestrian or a taxi can't cut across blocks, so the distance that matters is the taxicab distance, measured along the grid's two directions. Most of Manhattan is laid out on the grid of the Commissioners' Plan of 1811, whose avenues run about 29° east of true north, roughly along the island. So the taxicab metric that describes Manhattan is dℓ1d_{\ell^1} in coordinates rotated by 29° from north and east, not in map coordinates. Between two corners, the walking distance is between 11 and 2≈1.41\sqrt2 \approx 1.41 times the straight-line distance: equal when both corners are on the same street, and largest when the straight line runs at 45° to the grid (Exercise 1.22). Every shortest walk is a staircase, and there are usually very many of them (Figure 1.2).

Figure 1.2. On a street grid, every staircase path from AA to BB that never doubles back has the same length, dℓ1(A,B)=6+4=10d_{\ell^1}(A, B) = 6 + 4 = 10 blocks. The straight line (dashed) has length 52≈7.2\sqrt{52} \approx 7.2 blocks, but nothing can travel along it.

The sphere

Put the Earth's centre at the origin and represent a place by its unit vector x∈S2={x∈R3:∥x∥=1}x \in S^2 = \{x \in \mathbb{R}^3 : \|x\| = 1\}. The great-circle distance on a sphere of radius RR is RR times the angle between the vectors:

dS2(x,y)=R arccos⁡(x⋅y).d_{S^2}(x, y) = R\,\arccos(x \cdot y).

Positivity and symmetry are immediate. The triangle inequality, which says that angles between directions obey ∠(x,z)≤∠(x,y)+∠(y,z)\angle(x, z) \leq \angle(x, y) + \angle(y, z), is Exercise 1.23.

The arccos formula loses precision when xx and yy are close, because arccos⁡\arccos is very steep near 11. Navigation software uses an equivalent form, the haversine formula, which with latitudes φi\varphi_i and longitudes λi\lambda_i reads

d=2Rarcsin⁡sin⁡2φ2−φ12+cos⁡φ1cos⁡φ2sin⁡2λ2−λ12.d = 2R\arcsin\sqrt{\sin^2\tfrac{\varphi_2 - \varphi_1}{2} + \cos\varphi_1\cos\varphi_2\sin^2\tfrac{\lambda_2 - \lambda_1}{2}}.

For New York and Hong Kong this gives the 12,97012{,}970 km above.

Figure 1.3. New York to Hong Kong. The rhumb line (constant compass bearing) is straight on a Mercator chart; the great circle is the shortest path on the sphere, and on the chart it curves up to about 84° N. Seen from above the pole (right), the great circle looks nearly straight. Computed on a sphere of radius 63716371 km: the great circle is 12,97012{,}970 km, the rhumb line about 16,35016{,}350 km.

The Mercator map is a function from (most of) the sphere to the plane, and it does not preserve distance. No map can: there is no way to flatten any piece of a sphere onto the plane while keeping every distance (Gauss's Theorema Egregium, 8A.9 The Curvature of Surfaces). That is the first sign of curvature, the subject of Book 9A.

Discrete spaces, codes and strings

On any set, the discrete metric d(x,y)=1d(x, y) = 1 for x≠yx \neq y (and 00 for x=yx = y) satisfies the axioms. (For the triangle inequality: if x≠zx \neq z, then yy differs from at least one of them, so the right side d(x,y)+d(y,z)d(x, y) + d(y, z) is at least 11.) It is useful mainly as a test case: it shows what can go wrong when a space has no notion of "nearby". For instance, a sequence converges in the discrete metric only if it is eventually constant: taking ε=12\varepsilon = \frac12 in the definition of convergence forces d(xn,x)=0d(x_n, x) = 0, that is xn=xx_n = x, from some point on.

More interesting discrete spaces come from information.

Definition 1.5 Hamming distance

For two strings x,yx, y of the same length nn over an alphabet, the Hamming distance dH(x,y)d_H(x, y) is the number of positions in which they differ.

The triangle inequality holds because a position in which xx and zz differ must be one in which xx differs from yy or yy differs from zz. For binary strings of length 33, the space is the eight corners of a cube, and dHd_H counts edges along a shortest path between corners (Figure 1.4).

Proposition 1.6 Error correction is disjointness of balls

Let CC be a set of codewords of length nn whose pairwise Hamming distances are all at least 2t+12t + 1. Then the closed balls of radius tt around the codewords are disjoint. So if a codeword is sent and at most tt symbols are corrupted, the received string is closer to the sent codeword than to any other, and decoding to the nearest codeword recovers it.

Proof. If a string rr had dH(r,c)≤td_H(r, c) \leq t and dH(r,c′)≤td_H(r, c') \leq t for codewords c≠c′c \neq c', the triangle inequality would give dH(c,c′)≤2td_H(c, c') \leq 2t, a contradiction.

Figure 1.4. The Hamming cube {0,1}3\{0,1\}^3. The code {000,111}\{000, 111\} has minimum distance 3=2⋅1+13 = 2\cdot 1 + 1, so the balls of radius 11 around the codewords (shaded) are disjoint and cover the cube: any single flipped bit is corrected by majority vote.
In the world In use QR codes survive damage

A QR code stores its data as bytes protected by Reed–Solomon codes, as specified in the international standard ISO/IEC 18004. The symbols are bytes rather than bits, but the principle is Proposition 1.6: the codewords are chosen far apart in Hamming distance, so a damaged code is still closer to the right message than to any other. The standard offers four error-correction levels, L, M, Q and H, which can recover roughly 7%7\%, 15%15\%, 25%25\% and 30%30\% of the codewords respectively. Higher levels place the codewords farther apart, at the cost of more redundant bytes. That is why a QR code still scans with a logo printed over its middle.

For strings of different lengths, Hamming distance is useless: "kitten" and "sitting" don't even line up. The edit distance (or Levenshtein distance) between two strings is the least number of single-character insertions, deletions and substitutions that turn one into the other. From "kitten" to "sitting" it is 33: substitute k→s, substitute e→i, insert g. It is a metric. The triangle inequality holds because an edit sequence from xx to yy followed by one from yy to zz is an edit sequence from xx to zz.

In the world In use The triangle inequality prunes a search

A spell checker must find the dictionary words within edit distance 22 of a misspelling, without comparing it to every word in the dictionary. A BK-tree (Burkhard and Keller, 1973) stores the dictionary in a tree where each child of a word ww is filed under its distance from ww. To search for words within distance rr of a query qq, compute k=d(q,w)k = d(q, w) at the root. The reverse triangle inequality says that a word vv with d(q,v)≤rd(q, v) \leq r must have ∣d(v,w)−k∣≤r|d(v, w) - k| \leq r, so only the children filed under distances from k−rk - r to k+rk + r need to be explored. The rest of the tree is skipped without being looked at. The same pruning, valid in any metric space, is used in nearest-neighbour search for images, sounds and DNA sequences. It fails for "distances" that violate the triangle inequality, which is one practical reason the axiom matters.

Networks and distributions

Two more kinds of metric space are worth meeting early, because they are everywhere in applications and both return later in the route.

Shortest paths. In a connected network (a road map, a computer network, a social network) with a positive length attached to each link, let d(x,y)d(x, y) be the length of the shortest route from xx to yy. This is a metric. Positivity and symmetry are clear for two-way links, and the triangle inequality holds because following a shortest route from xx to yy and then one from yy to zz is a route from xx to zz, so the shortest one is no longer. Satellite navigation computes this metric, by Dijkstra's algorithm and its refinements, and the triangle inequality is what lets those refinements discard most of the map without looking at it, as the BK-tree above does for words. The great-circle distance on the sphere is the same idea for a continuum of routes: the length of the shortest path, which is how every Riemannian manifold becomes a metric space (9A.3 Geodesics and the Exponential Map).

Distances between distributions. How far apart are two piles of sand of equal mass, or two probability distributions? One answer, going back to Gaspard Monge's 1781 memoir on moving earth for fortifications and made precise by Leonid Kantorovich in 1942, is the least cost of turning one pile into the other, where moving an amount of mass mm a distance ℓ\ell costs mℓm\ell. On distributions over a metric space XX this defines the Wasserstein distance W1W_1 (also called the earth mover's distance). Two piles concentrated at single points xx and yy are at Wasserstein distance exactly d(x,y)d(x, y), so XX sits inside the space of distributions without any distortion of distances. The triangle inequality holds because a transport from the first pile to the second, followed by one from the second to the third, is a transport from the first to the third. In data science the earth mover's distance compares histograms and images; in geometry it turned out to know about curvature. Lower bounds on Ricci curvature can be characterised by how entropy behaves along shortest paths in this space of distributions, the theory of John Lott, Cédric Villani and Karl-Theodor Sturm, and Robert McCann and Peter Topping showed in 2010 that Ricci flow itself can be recognised by how the heat flow contracts Wasserstein distances (6D.5 Diffusions on Manifolds and Curvature).

Spaces of functions

The most important metric spaces in this guidebook are spaces whose points are functions.

Definition 1.7 The sup metric

Let XX be any set, and let B(X)B(X) be the set of bounded functions f:X→Rf : X \to \mathbb{R}. The sup metric is

d∞(f,g)=sup⁡x∈X∣f(x)−g(x)∣.d_\infty(f, g) = \sup_{x \in X} |f(x) - g(x)|.

It is a metric: the supremum is finite because ff and gg are bounded, and the triangle inequality holds pointwise and then for the supremum. Two functions are within ε\varepsilon in this metric exactly when the graph of one lies in a band of height ε\varepsilon around the graph of the other, everywhere. Convergence in d∞d_\infty is uniform convergence, the subject of 2B.5 Uniform Convergence and Arzelà–Ascoli. On a compact interval, every continuous function is bounded (2A.9 Continuous Functions), so C([a,b])C([a, b]), the continuous functions on [a,b][a, b], is a metric space with d∞d_\infty.

On C([a,b])C([a, b]) there is another natural metric, the area between the graphs:

d1(f,g)=∫ab∣f(x)−g(x)∣ dx.d_1(f, g) = \int_a^b |f(x) - g(x)|\,dx.

The triangle inequality comes from ∣f−h∣≤∣f−g∣+∣g−h∣|f - h| \leq |f - g| + |g - h| and monotonicity of the integral (2A.11 The Riemann Integral). Positivity is the interesting axiom: if f≠gf \neq g, then ∣f−g∣|f - g| is positive at some point, hence (by continuity) at least some δ>0\delta > 0 on a small interval around it, so the integral is positive. For merely integrable functions this fails. A function that is 11 at one point and 00 elsewhere has integral 00. Course 3 deals with this by agreeing to identify functions that differ on a negligible set (3A.3 The Lebesgue Integral).

Open and closed sets

From here on, (X,d)(X, d) is a metric space. The definitions are those of 2A.9 Continuous Functions for the real line, with ∣x−y∣|x - y| replaced by d(x,y)d(x, y).

Definition 1.8 Balls

The open ball of radius r>0r > 0 about x0x_0 is B(x0,r)={x∈X:d(x,x0)<r}B(x_0, r) = \{x \in X : d(x, x_0) < r\}. The closed ball is {x∈X:d(x,x0)≤r}\{x \in X : d(x, x_0) \leq r\}.

Balls depend on the metric. In R2\mathbb{R}^2 they are diamonds, discs or squares (Figure 1.1). In C([a,b])C([a, b]) with d∞d_\infty, the ball of radius ε\varepsilon around ff is the set of continuous functions whose graphs stay inside the band of half-width ε\varepsilon around the graph of ff, with some room to spare (the supremum of ∣g−f∣|g - f| is attained on [a,b][a, b], so it must be strictly less than ε\varepsilon). In the discrete metric, the ball of radius 12\tfrac12 around xx is just {x}\{x\}.

Definition 1.9 Interior, boundary, open and closed sets

Let E⊆XE \subseteq X and x0∈Xx_0 \in X.

  • x0x_0 is an interior point of EE if some ball B(x0,r)B(x_0, r) lies inside EE; an exterior point if some ball around x0x_0 misses EE entirely; and a boundary point if it is neither, that is, if every ball around x0x_0 meets both EE and its complement.
  • x0x_0 is an adherent point of EE if every ball around x0x_0 meets EE. The set of adherent points is the closure E‾\overline{E}.
  • EE is open if it contains none of its boundary points (equivalently, every point of EE is interior). EE is closed if it contains all of its boundary points (equivalently, E‾=E\overline{E} = E).

The "equivalently" clauses in the definition deserve a check, since they are how openness and closedness are usually tested. Every point is exactly one of interior, exterior or boundary, by definition. A point of EE can't be exterior (every ball around it contains the point itself, which is in EE), so each point of EE is interior or boundary. Hence EE contains no boundary points exactly when every point of EE is interior. Likewise, the adherent points are exactly the points that are not exterior, that is, the interior points together with the boundary points. Since interior points of EE lie in EE, E‾=E\overline{E} = E exactly when EE contains its boundary points.

Open balls are open. If x∈B(x0,r)x \in B(x_0, r), let s=r−d(x,x0)>0s = r - d(x, x_0) > 0. Then B(x,s)⊆B(x0,r)B(x, s) \subseteq B(x_0, r) by the triangle inequality: d(y,x0)≤d(y,x)+d(x,x0)<s+d(x,x0)=rd(y, x_0) \leq d(y, x) + d(x, x_0) < s + d(x, x_0) = r. So every point of an open ball is an interior point. In the same way, closed balls are closed (Exercise 1.24).

Sets need not be either open or closed: [0,1)[0, 1) in R\mathbb{R} is neither. And a set can be both: XX and ∅\varnothing always are, and in the discrete metric every set is both, since every ball of radius 12\tfrac12 is a single point.

Figure 1.5. The set E={(x,y):x2+y2<1, y≥0}E = \{(x, y) : x^2 + y^2 < 1,\ y \geq 0\} (left) contains its flat edge but not its arc. Its interior (middle) drops the flat edge; its closure (right) adds the arc. The boundary, closure minus interior, is the arc together with the flat edge: EE contains part of its boundary, so it is neither open nor closed.
Proposition 1.10 Interior, closure and boundary

For any E⊆XE \subseteq X, writing int⁡E\operatorname{int} E for the set of interior points and ∂E\partial E for the set of boundary points:

  1. int⁡E⊆E⊆E‾\operatorname{int} E \subseteq E \subseteq \overline{E}, and ∂E=E‾∖int⁡E\partial E = \overline{E} \setminus \operatorname{int} E.
  2. int⁡E\operatorname{int} E is open, and it contains every open set U⊆EU \subseteq E. So it is the largest open subset of EE.
  3. E‾\overline{E} is closed, and it is contained in every closed set F⊇EF \supseteq E. So it is the smallest closed set containing EE.

Proof. (1) An interior point of EE lies in EE; a point of EE is adherent to EE. The adherent points are the interior and boundary points (as just shown), and these two kinds don't overlap, so removing the interior points from E‾\overline{E} leaves exactly ∂E\partial E.

(2) If xx is interior, with B(x,r)⊆EB(x, r) \subseteq E, then every y∈B(x,r)y \in B(x, r) has a ball B(y,s)⊆B(x,r)⊆EB(y, s) \subseteq B(x, r) \subseteq E (open balls are open), so yy is interior too. Thus B(x,r)⊆int⁡EB(x, r) \subseteq \operatorname{int} E, and int⁡E\operatorname{int} E is open. If U⊆EU \subseteq E is open, each x∈Ux \in U has a ball inside UU, hence inside EE, so x∈int⁡Ex \in \operatorname{int} E.

(3) Let xx be adherent to E‾\overline{E}, and r>0r > 0. The ball B(x,r/2)B(x, r/2) contains some y∈E‾y \in \overline{E}, and B(y,r/2)B(y, r/2) contains some z∈Ez \in E; then d(x,z)<rd(x, z) < r. So every ball around xx meets EE, and x∈E‾x \in \overline{E}: the closure is closed. If F⊇EF \supseteq E is closed and x∈E‾x \in \overline{E}, every ball around xx meets EE, hence meets FF, so xx is adherent to FF and lies in FF.

Example 1.11 Computing interior, closure and boundary

(a) E={(x,y):x2+y2<1, y≥0}E = \{(x, y) : x^2 + y^2 < 1,\ y \geq 0\} in R2\mathbb{R}^2 (Figure 1.5). A point with x2+y2<1x^2 + y^2 < 1 and y>0y > 0 has a small disc around it satisfying both strict inequalities (by continuity, below), so it is interior. A point (x,0)(x, 0) with ∣x∣<1|x| < 1 is in EE, but every disc around it contains points with y<0y < 0, outside EE: a boundary point. A point with x2+y2=1x^2 + y^2 = 1 and y≥0y \geq 0 is not in EE, but is the limit of (rx,ry)(rx, ry) with r↑1r \uparrow 1, which are in EE (when y>0y > 0; for (±1,0)(\pm 1, 0) use (±r,0)(\pm r, 0)): an adherent point. So int⁡E\operatorname{int} E is the open half-disc, E‾={x2+y2≤1,y≥0}\overline{E} = \{x^2 + y^2 \leq 1, y \geq 0\}, and ∂E\partial E is the arc together with the diameter.

(b) Q\mathbb{Q} in R\mathbb{R}. Every interval contains rationals and irrationals (2A.4 The Real Numbers). So no point is interior (no interval fits inside Q\mathbb{Q}), and every real is adherent. Hence int⁡Q=∅\operatorname{int}\mathbb{Q} = \varnothing, Q‾=R\overline{\mathbb{Q}} = \mathbb{R}, and ∂Q=R\partial\mathbb{Q} = \mathbb{R}: the boundary of a set can be much bigger than the set.

(c) A closed set in the discrete metric: every set. Its boundary is empty, since every set is also open.

The most-used fact connects closedness to sequences. It is what lets us prove a set is closed by taking limits.

Proposition 1.12 Closed sets contain their limits

Let E⊆XE \subseteq X. A point xx is in E‾\overline{E} if and only if some sequence in EE converges to xx. Hence EE is closed if and only if every sequence in EE that converges in XX has its limit in EE.

Proof. If x∈E‾x \in \overline{E}, then for each nn the ball B(x,1n)B(x, \tfrac1n) meets EE; choose xnx_n in it. Then d(xn,x)<1n→0d(x_n, x) < \tfrac1n \to 0. Conversely, if xn∈Ex_n \in E and xn→xx_n \to x, then every ball B(x,r)B(x, r) contains xnx_n for large nn, so it meets EE, and x∈E‾x \in \overline{E}. The second sentence follows because EE is closed exactly when E‾=E\overline{E} = E.

Proposition 1.13 Open and closed are complementary

EE is open if and only if its complement X∖EX \setminus E is closed. Any union of open sets is open, and any intersection of finitely many open sets is open. Correspondingly, any intersection of closed sets is closed, and any finite union of closed sets is closed.

Proof. EE and X∖EX \setminus E have the same boundary points, by the symmetric definition. So EE contains none of them exactly when X∖EX \setminus E contains all of them. If each UαU_\alpha is open and x∈⋃Uαx \in \bigcup U_\alpha, then xx lies in some UαU_\alpha, which contains a ball around xx; so the union does too. If U1,…,UkU_1, \dots, U_k are open and xx lies in all of them, with B(x,ri)⊆UiB(x, r_i) \subseteq U_i, then the ball of radius min⁡iri\min_i r_i lies in all of them. (The minimum of finitely many positive numbers is positive. For infinitely many it may be 00: ⋂n(−1n,1n)={0}\bigcap_n (-\tfrac1n, \tfrac1n) = \{0\} is not open.) The statements about closed sets follow by taking complements.

Note

These properties of open sets are all that is needed to define continuity and convergence, and they are what survives when the metric is thrown away. A collection of subsets of XX that contains ∅\varnothing and XX and is closed under arbitrary unions and finite intersections is called a topology. Topological spaces are the subject of 7A.1 Topological Spaces and Quotients. Until then, every space we meet has a metric, and the metric is the easiest way to work.

Continuous maps

Continuity, defined in 2A.9 Continuous Functions for functions of one real variable, makes sense between any two metric spaces, and so do all its equivalent forms. This is the version used for the rest of the guidebook.

Definition 1.14 Continuity between metric spaces

Let (X,dX)(X, d_X) and (Y,dY)(Y, d_Y) be metric spaces. A function f:X→Yf : X \to Y is continuous at x0∈Xx_0 \in X if for every ε>0\varepsilon > 0 there is δ>0\delta > 0 such that dY(f(x),f(x0))<εd_Y(f(x), f(x_0)) < \varepsilon whenever dX(x,x0)<δd_X(x, x_0) < \delta. It is continuous if it is continuous at every point.

In terms of balls: every ball B(f(x0),ε)B(f(x_0), \varepsilon) around the image point contains the image f(B(x0,δ))f(B(x_0, \delta)) of some ball around x0x_0. The next theorem gives three other ways to say the same thing. The third, about open sets, is the one that survives when the metric is thrown away (7A.1 Topological Spaces and Quotients).

Theorem 1.15 Four forms of continuity

For f:X→Yf : X \to Y between metric spaces, the following are equivalent:

  1. ff is continuous (ε–δ, at every point);
  2. ff preserves limits: whenever xn→xx_n \to x in XX, f(xn)→f(x)f(x_n) \to f(x) in YY;
  3. for every open V⊆YV \subseteq Y, the preimage f−1(V)f^{-1}(V) is open in XX;
  4. for every closed F⊆YF \subseteq Y, the preimage f−1(F)f^{-1}(F) is closed in XX.

Proof. (1 ⇒ 2) Let xn→xx_n \to x and ε>0\varepsilon > 0. Take δ\delta from continuity at xx, then NN with dX(xn,x)<δd_X(x_n, x) < \delta for n≥Nn \geq N; for those nn, dY(f(xn),f(x))<εd_Y(f(x_n), f(x)) < \varepsilon.

(2 ⇒ 1) Contrapositive. If ff is not continuous at xx, then (negating, 2A.5 Quantifiers and the Shape of a Proof) some ε>0\varepsilon > 0 has, for each nn, a point xnx_n with dX(xn,x)<1nd_X(x_n, x) < \frac1n but dY(f(xn),f(x))≥εd_Y(f(x_n), f(x)) \geq \varepsilon. Then xn→xx_n \to x while f(xn)↛f(x)f(x_n) \not\to f(x).

(1 ⇒ 3) Let VV be open and x∈f−1(V)x \in f^{-1}(V). Since f(x)∈Vf(x) \in V and VV is open, some ball B(f(x),ε)⊆VB(f(x), \varepsilon) \subseteq V. Continuity gives δ\delta with f(B(x,δ))⊆B(f(x),ε)⊆Vf(B(x, \delta)) \subseteq B(f(x), \varepsilon) \subseteq V, that is, B(x,δ)⊆f−1(V)B(x, \delta) \subseteq f^{-1}(V). So every point of f−1(V)f^{-1}(V) is interior.

(3 ⇒ 1) Let x∈Xx \in X and ε>0\varepsilon > 0. The ball V=B(f(x),ε)V = B(f(x), \varepsilon) is open, so f−1(V)f^{-1}(V) is open, and it contains xx. So some ball B(x,δ)B(x, \delta) lies in f−1(V)f^{-1}(V), which says dY(f(y),f(x))<εd_Y(f(y), f(x)) < \varepsilon whenever dX(y,x)<δd_X(y, x) < \delta.

(3 ⇔ 4) Preimages respect complements (2A.2 Sets, Functions and Equivalence): f−1(Y∖V)=X∖f−1(V)f^{-1}(Y \setminus V) = X \setminus f^{-1}(V). A set is closed exactly when its complement is open (Proposition 1.13).

Form 3 explains why 2A.2 Sets, Functions and Equivalence made a point of preimages: they respect unions, intersections and complements, the operations that open sets are built from. Notice that the theorem is about preimages. Images of open sets need not be open: x↦x2x \mapsto x^2 is continuous on R\mathbb{R} and sends the open interval (−1,1)(-1, 1) to [0,1)[0, 1), which is not open.

Definition 1.16 Lipschitz maps

f:X→Yf : X \to Y is Lipschitz with constant KK if dY(f(x),f(y))≤K dX(x,y)d_Y(f(x), f(y)) \leq K\,d_X(x, y) for all x,yx, y. A Lipschitz map is continuous: take δ=ε/K\delta = \varepsilon/K.

Example 1.17 Continuous maps, and how to recognise open and closed sets

(a) Distance to a point. For fixed x0x_0, the function x↦d(x,x0)x \mapsto d(x, x_0) is Lipschitz with constant 11, by the reverse triangle inequality. So open balls, the preimages of (−∞,r)(-\infty, r), are open, and closed balls, the preimages of (−∞,r](-\infty, r], are closed: a one-line proof of facts proved by hand above.

(b) Coordinates and arithmetic. On Rn\mathbb{R}^n, each coordinate function x↦xix \mapsto x_i is 11-Lipschitz, since ∣xi−yi∣≤dℓ2(x,y)|x_i - y_i| \leq d_{\ell^2}(x, y). Sums, products and quotients (with nonzero denominator) of continuous real-valued functions on any metric space are continuous, by form 2 and the limit laws of 2A.6 Sequences. So every polynomial in the coordinates is continuous on Rn\mathbb{R}^n.

(c) Reading off openness. Now sets defined by strict inequalities between continuous functions are open, and sets defined by non-strict inequalities or equations are closed. The open unit disc is the preimage of (−∞,1)(-\infty, 1) under x2+y2x^2 + y^2; the hyperbola region {xy≥1}\{xy \geq 1\} is the preimage of [1,∞)[1, \infty) under xyxy; the unit sphere S2S^2 is the preimage of {1}\{1\} under x2+y2+z2x^2 + y^2 + z^2. In (a) of Example 1.11, the interior points of EE were found exactly this way.

(d) Continuity depends on the metrics. On C([0,1])C([0, 1]), the evaluation map ev(f)=f(12)\mathrm{ev}(f) = f(\tfrac12) is continuous for d∞d_\infty, being 11-Lipschitz: ∣f(12)−g(12)∣≤d∞(f,g)|f(\tfrac12) - g(\tfrac12)| \leq d_\infty(f, g). It is not continuous for d1d_1: tents of height 11 centred at 12\frac12 with base width 2n\frac2n tend to 00 in d1d_1, but their values at 12\frac12 stay 11. On the other hand, the integral f↦∫01ff \mapsto \int_0^1 f is 11-Lipschitz for d1d_1, and hence also for d∞d_\infty (which is larger on [0,1][0, 1]).

Compositions of continuous maps are continuous (form 2 makes it a one-line proof: xn→xx_n \to x gives f(xn)→f(x)f(x_n) \to f(x) gives g(f(xn))→g(f(x))g(f(x_n)) \to g(f(x))). A continuous bijection whose inverse is also continuous is a homeomorphism; homeomorphic spaces have the same open sets, matched by the bijection, and are "the same" for the purposes of topology (7A.1 Topological Spaces and Quotients).

Subspaces and relative topology

Any subset Y⊆XY \subseteq X is a metric space with the same distance, restricted to pairs of points of YY. This is how the sphere S2S^2 inherits the straight-line (chordal) distance from R3\mathbb{R}^3, and how [0,1][0, 1] inherits its metric from R\mathbb{R}.

Being open is then a statement relative to the space you are in. In Y=[0,1]Y = [0, 1], the set [0,12)[0, \tfrac12) is open: the ball of radius 12\tfrac12 around 00 in YY is {y∈[0,1]:∣y∣<12}=[0,12)\{y \in [0, 1] : |y| < \tfrac12\} = [0, \tfrac12). But [0,12)[0, \tfrac12) is not open in R\mathbb{R}, because no interval around 00 fits inside it.

Proposition 1.18 Relatively open sets

Let Y⊆XY \subseteq X. A set E⊆YE \subseteq Y is open in (Y,d)(Y, d) if and only if E=V∩YE = V \cap Y for some set VV that is open in XX. The same holds with "closed" in place of "open".

Proof. A ball in YY is the intersection of YY with the ball in XX of the same centre and radius. If EE is open in YY, then for each y∈Ey \in E choose ryr_y with BY(y,ry)⊆EB_Y(y, r_y) \subseteq E, and let V=⋃y∈EBX(y,ry)V = \bigcup_{y \in E} B_X(y, r_y). This is open in XX, and V∩Y=⋃yBY(y,ry)=EV \cap Y = \bigcup_y B_Y(y, r_y) = E. Conversely, if E=V∩YE = V \cap Y with VV open in XX, then each y∈Ey \in E has a ball BX(y,r)⊆VB_X(y, r) \subseteq V, so BY(y,r)=BX(y,r)∩Y⊆EB_Y(y, r) = B_X(y, r) \cap Y \subseteq E. For closed sets, take complements within YY.

Relative topology will matter as soon as we work on a manifold, which lives inside some larger space but is studied as a space in its own right (8A.1 Smooth Structures).

Equivalent and inequivalent metrics

The three metrics on Rn\mathbb{R}^n give different numbers but, it turns out, the same convergent sequences and the same open sets. The reason is that each is bounded by a constant multiple of each other:

dℓ∞(x,y)≤dℓ2(x,y)≤dℓ1(x,y)≤n dℓ∞(x,y).d_{\ell^\infty}(x, y) \leq d_{\ell^2}(x, y) \leq d_{\ell^1}(x, y) \leq n\, d_{\ell^\infty}(x, y).

(The first two inequalities compare a largest term, a root-sum-of-squares and a sum of non-negative terms; the last bounds each of nn terms by the largest.)

Definition 1.19 Equivalent metrics

Two metrics dd and d′d' on the same set XX are equivalent if they have the same convergent sequences with the same limits. They are uniformly equivalent (or bi-Lipschitz equivalent) if there are constants c,C>0c, C > 0 with c d(x,y)≤d′(x,y)≤C d(x,y)c\,d(x, y) \leq d'(x, y) \leq C\,d(x, y) for all x,yx, y.

Uniformly equivalent metrics are equivalent: d(xn,x)→0d(x_n, x) \to 0 if and only if d′(xn,x)→0d'(x_n, x) \to 0. By Proposition 1.12, equivalent metrics have the same closed sets, hence the same open sets. So on Rn\mathbb{R}^n, one can use whichever of the three is convenient for the problem at hand: ℓ∞\ell^\infty to handle coordinates one at a time, ℓ2\ell^2 for geometry, ℓ1\ell^1 for counting.

In infinite-dimensional spaces, this freedom disappears.

Example 1.20 Two inequivalent metrics on C([0,1])C([0, 1])

Let fnf_n be the "tent" that rises linearly from 00 at x=0x = 0 to height 11 at x=1nx = \tfrac1n, falls back to 00 at x=2nx = \tfrac2n, and is 00 on [2n,1][\tfrac2n, 1] (for n≥2n \geq 2). Then

d1(fn,0)=12⋅2n⋅1=1n→0,d∞(fn,0)=1 for every n.d_1(f_n, 0) = \tfrac12 \cdot \tfrac2n \cdot 1 = \tfrac1n \to 0, \qquad d_\infty(f_n, 0) = 1 \text{ for every } n.

So fn→0f_n \to 0 in the d1d_1 metric but not in the sup metric. The metrics are not equivalent. The general inequality d1(f,g)≤d∞(f,g)d_1(f, g) \leq d_\infty(f, g) (on an interval of length 11) holds, but no inequality in the other direction can, because a tall narrow tent has small area.

Figure 1.6. The tents fnf_n for n=2,4,8n = 2, 4, 8. Their areas 1n\tfrac1n tend to 00, so fn→0f_n \to 0 in the d1d_1 metric. Their heights stay 11, so they don't converge to 00 uniformly. "Close" depends on the metric.

Which metric is right depends on the question. For a sensor that must never exceed a threshold, the worst case matters, and the sup metric is the right one. For the total energy delivered by a signal, the area metric (or its square-integral cousin) is the right one. 2B.5 Uniform Convergence and Arzelà–Ascoli develops the sup metric, and Courses 3 and 4 develop the integral metrics. A whole family of them, one for each exponent pp, will be needed (3A.7 Lᵖ Spaces and Jensen’s Inequality), and the inequalities that relate them, the Sobolev inequalities of 4A.11 Sobolev Embeddings and Critical Exponents, are among the main tools of geometric analysis.

Where this goes Metric spaces of metric spaces

Once a Riemannian manifold is turned into a metric space (9A.3 Geodesics and the Exponential Map), we can ask how far apart two whole spaces are. For two subsets A,BA, B of a metric space, the Hausdorff distance is the least rr such that each set lies within distance rr of the other (Exercise 1.32). Gromov's extension, the Gromov–Hausdorff distance, compares two metric spaces that don't sit inside a common space, by asking how well they can be placed inside one. It makes "the space of all compact metric spaces" into a metric space (9B.4 Convergence of Manifolds). That is the setting in which one says that a sequence of rescaled Ricci flows converges to a limit, and the limits obtained this way, the blow-ups at a singularity, are how Perelman classified singularities (11B.5 Singularities, 12B.3 The Structure of κ-Solutions).

History

The idea of an abstract distance came from analysis, not geometry. Maurice Fréchet's 1906 thesis studied sets of functions and curves on which only a notion of distance was given, and showed that much of the theory of limits carried over to them. Felix Hausdorff named and systematised these "metric spaces" in his Grundzüge der Mengenlehre (1914), the founding text of general topology. The examples that drove both were spaces of functions, exactly the spaces that differential equations need. Hamming distance came from engineering: Richard Hamming introduced it in his 1950 paper on error-detecting and error-correcting codes, written at Bell Labs for computers that had to keep running despite occasional single-bit errors.

Recall Where we stand

A metric space is a set with a distance obeying four axioms, the decisive one being the triangle inequality. Convergence, open and closed sets, closure and boundary are defined exactly as on R\mathbb{R}, and a set is closed precisely when it contains the limits of its convergent sequences. Subsets inherit a metric, and openness is relative to the ambient space. On Rn\mathbb{R}^n the standard metrics are uniformly equivalent, but on spaces of functions natural metrics can disagree about which sequences converge. 2B.2 Completeness and Contraction asks which metric spaces are complete, and proves the theorem that makes completeness pay: the contraction mapping principle.

Exercises

Exercise 1.21 Which are metrics?

Decide which of these are metrics on R\mathbb{R}, and for each that isn't, name an axiom that fails: (a) d(x,y)=(x−y)2d(x, y) = (x - y)^2; (b) d(x,y)=∣x−y∣1/2d(x, y) = |x - y|^{1/2}; (c) d(x,y)=∣x2−y2∣d(x, y) = |x^2 - y^2|; (d) d(x,y)=∣x−y∣1+∣x−y∣d(x, y) = \frac{|x - y|}{1 + |x - y|}.

Hint

For (b) and (d), use that ϕ(t)=t1/2\phi(t) = t^{1/2} and ϕ(t)=t1+t\phi(t) = \frac{t}{1 + t} are increasing with ϕ(s+t)≤ϕ(s)+ϕ(t)\phi(s + t) \leq \phi(s) + \phi(t) for s,t≥0s, t \geq 0.

Solution

(a) Not a metric: d(0,2)=4>2=d(0,1)+d(1,2)d(0, 2) = 4 > 2 = d(0, 1) + d(1, 2), so the triangle inequality fails. (b) A metric: ∣x−z∣1/2≤(∣x−y∣+∣y−z∣)1/2≤∣x−y∣1/2+∣y−z∣1/2|x - z|^{1/2} \leq (|x - y| + |y - z|)^{1/2} \leq |x - y|^{1/2} + |y - z|^{1/2}, squaring the last inequality to check it. (c) Not a metric: d(1,−1)=0d(1, -1) = 0 although 1≠−11 \neq -1, so positivity fails. (d) A metric, by the hint. It is bounded by 11 but has the same convergent sequences as ∣x−y∣|x - y|: so every metric is equivalent to a bounded one.

Exercise 1.22 Walking versus flying

Show that for x,y∈R2x, y \in \mathbb{R}^2, dℓ2(x,y)≤dℓ1(x,y)≤2 dℓ2(x,y)d_{\ell^2}(x, y) \leq d_{\ell^1}(x, y) \leq \sqrt2\, d_{\ell^2}(x, y), with equality on the right exactly when the segment from xx to yy makes an angle of 45° with the axes. What are the best constants in Rn\mathbb{R}^n?

Solution

With a=∣x1−y1∣a = |x_1 - y_1| and b=∣x2−y2∣b = |x_2 - y_2|: (a+b)2=a2+b2+2ab≥a2+b2(a + b)^2 = a^2 + b^2 + 2ab \geq a^2 + b^2 gives the left inequality, and (a+b)2≤2(a2+b2)(a + b)^2 \leq 2(a^2 + b^2), which is (a−b)2≥0(a - b)^2 \geq 0, gives the right one, with equality when a=ba = b. In Rn\mathbb{R}^n, dℓ2≤dℓ1≤n dℓ2d_{\ell^2} \leq d_{\ell^1} \leq \sqrt n\, d_{\ell^2}, the right one by Cauchy–Schwarz applied to (1,…,1)(1, \dots, 1) and (∣xi−yi∣)i(|x_i - y_i|)_i.

Exercise 1.23 The triangle inequality on the sphere

For unit vectors x,y,z∈R3x, y, z \in \mathbb{R}^3, let α=arccos⁡(x⋅y)\alpha = \arccos(x \cdot y) and β=arccos⁡(y⋅z)\beta = \arccos(y \cdot z), both in [0,π][0, \pi]. Write x=cos⁡α y+sin⁡α ux = \cos\alpha\, y + \sin\alpha\, u and z=cos⁡β y+sin⁡β vz = \cos\beta\, y + \sin\beta\, v with u,vu, v unit vectors perpendicular to yy. Show that x⋅z≥cos⁡(α+β)x \cdot z \geq \cos(\alpha + \beta), and deduce that arccos⁡(x⋅z)≤α+β\arccos(x \cdot z) \leq \alpha + \beta. This proves the triangle inequality for great-circle distance.

Solution

x⋅z=cos⁡αcos⁡β+sin⁡αsin⁡β (u⋅v)≥cos⁡αcos⁡β−sin⁡αsin⁡β=cos⁡(α+β)x \cdot z = \cos\alpha\cos\beta + \sin\alpha\sin\beta\,(u \cdot v) \geq \cos\alpha\cos\beta - \sin\alpha\sin\beta = \cos(\alpha + \beta), using u⋅v≥−1u \cdot v \geq -1 (Cauchy–Schwarz) and sin⁡α,sin⁡β≥0\sin\alpha, \sin\beta \geq 0. If α+β≤π\alpha + \beta \leq \pi, then since arccos⁡\arccos is decreasing on [−1,1][-1, 1], arccos⁡(x⋅z)≤arccos⁡(cos⁡(α+β))=α+β\arccos(x \cdot z) \leq \arccos(\cos(\alpha + \beta)) = \alpha + \beta. If α+β>π\alpha + \beta > \pi, then arccos⁡(x⋅z)≤π<α+β\arccos(x \cdot z) \leq \pi < \alpha + \beta anyway.

Exercise 1.24 Closed balls and closures

(a) Show that a closed ball {x:d(x,x0)≤r}\{x : d(x, x_0) \leq r\} is a closed set, using Proposition 1.12 and the reverse triangle inequality. (b) In the discrete metric on a set with at least two points, show that the closure of the open ball B(x0,1)B(x_0, 1) is not the closed ball of radius 11. (So "closure of the open ball" and "closed ball" can differ.)

Solution

(a) If d(xn,x0)≤rd(x_n, x_0) \leq r and xn→xx_n \to x, then ∣d(xn,x0)−d(x,x0)∣≤d(xn,x)→0|d(x_n, x_0) - d(x, x_0)| \leq d(x_n, x) \to 0, so d(x,x0)=lim⁡d(xn,x0)≤rd(x, x_0) = \lim d(x_n, x_0) \leq r. (b) B(x0,1)={x0}B(x_0, 1) = \{x_0\}, which is closed, so its closure is {x0}\{x_0\}. The closed ball of radius 11 is the whole space.

Exercise 1.25 Open relative to what?

Let Y=[0,1]∪[2,3]Y = [0, 1] \cup [2, 3] with the metric from R\mathbb{R}. Show that [0,1][0, 1] is both open and closed in YY. (In 2B.4 Connectedness this is exactly what it means for YY to be disconnected.)

Solution

[0,1]=Y∩(−12,32)[0, 1] = Y \cap (-\tfrac12, \tfrac32), the intersection of YY with an open set of R\mathbb{R}, so it is open in YY by Proposition 1.18. And [0,1]=Y∩[0,1][0, 1] = Y \cap [0, 1], the intersection with a closed set of R\mathbb{R}, so it is closed in YY. Directly: the ball of radius 12\frac12 in YY around any point of [0,1][0, 1] is contained in [0,1][0, 1], because YY has no points in (1,2)(1, 2).

Exercise 1.26 Interior, closure, boundary

Find the interior, closure and boundary of: (a) {(x,y):0<x≤1}\{(x, y) : 0 < x \leq 1\} in R2\mathbb{R}^2; (b) Z\mathbb{Z} in R\mathbb{R}; (c) {1n:n≥1}\{\frac1n : n \geq 1\} in R\mathbb{R}; (d) the set of rational points Q2\mathbb{Q}^2 in R2\mathbb{R}^2.

Solution

(a) Interior {0<x<1}\{0 < x < 1\}, closure {0≤x≤1}\{0 \leq x \leq 1\}, boundary the two lines x=0x = 0 and x=1x = 1. (b) Interior ∅\varnothing (no interval fits in Z\mathbb{Z}), closure Z\mathbb{Z} (it is closed), boundary Z\mathbb{Z}. (c) Interior ∅\varnothing, closure {1n}∪{0}\{\frac1n\} \cup \{0\}, boundary the same. (d) Interior ∅\varnothing, closure R2\mathbb{R}^2, boundary R2\mathbb{R}^2, since every disc contains points with rational and with irrational coordinates.

Exercise 1.27 Distance to a set

For a nonempty A⊆XA \subseteq X, let d(x,A)=inf⁡a∈Ad(x,a)d(x, A) = \inf_{a \in A} d(x, a). Show that ∣d(x,A)−d(y,A)∣≤d(x,y)|d(x, A) - d(y, A)| \leq d(x, y), so x↦d(x,A)x \mapsto d(x, A) is continuous, and that d(x,A)=0d(x, A) = 0 exactly when x∈A‾x \in \overline{A}. Deduce that every closed set is the zero set of a continuous function.

Solution

For every a∈Aa \in A, d(x,A)≤d(x,a)≤d(x,y)+d(y,a)d(x, A) \leq d(x, a) \leq d(x, y) + d(y, a). Taking the infimum over aa, d(x,A)≤d(x,y)+d(y,A)d(x, A) \leq d(x, y) + d(y, A); swapping xx and yy gives the other half. Next, d(x,A)=0d(x, A) = 0 means that for every r>0r > 0 some a∈Aa \in A has d(x,a)<rd(x, a) < r (the ε\varepsilon-characterisation of the infimum), which is exactly the statement that xx is adherent to AA. So a closed AA is {x:d(x,A)=0}\{x : d(x, A) = 0\}. This function is used constantly later: it measures how far a point is from a set, continuously.

Exercise 1.28 Coordinatewise is not enough in infinite dimensions

Let ℓ∞\ell^\infty be the set of bounded real sequences a=(a1,a2,… )a = (a_1, a_2, \dots) with d∞(a,b)=sup⁡i∣ai−bi∣d_\infty(a, b) = \sup_i |a_i - b_i|, and let e(k)e^{(k)} have a 11 in position kk and 00 elsewhere. Show that ei(k)→0e^{(k)}_i \to 0 as k→∞k \to \infty for every fixed ii, but d∞(e(k),0)=1d_\infty(e^{(k)}, 0) = 1 for every kk. Where does the proof of Proposition 1.4 break?

Solution

For fixed ii, ei(k)=0e^{(k)}_i = 0 as soon as k>ik > i. But sup⁡i∣ei(k)∣=1\sup_i |e^{(k)}_i| = 1. In the proof, N=max⁡(N1,N2,… )N = \max(N_1, N_2, \dots) would be a maximum of infinitely many thresholds, here Ni=i+1N_i = i + 1, which has no maximum. The sequence (e(k))(e^{(k)}) will reappear in 2B.3 Compactness as a bounded sequence in a complete space with no convergent subsequence.

Exercise 1.29 Proving sets open or closed with continuity

Use Theorem 1.15 to show: (a) {(x,y)∈R2:x2<y<1}\{(x, y) \in \mathbb{R}^2 : x^2 < y < 1\} is open; (b) for continuous f,g:X→Rf, g : X \to \mathbb{R}, the set {x:f(x)≤g(x)}\{x : f(x) \leq g(x)\} is closed; (c) the graph {(x,f(x)):x∈R}\{(x, f(x)) : x \in \mathbb{R}\} of a continuous f:R→Rf : \mathbb{R} \to \mathbb{R} is closed in R2\mathbb{R}^2.

Solution

(a) It is the intersection of the preimages of (0,∞)(0, \infty) under y−x2y - x^2 and under 1−y1 - y, both continuous; a finite intersection of open sets is open. (b) It is the preimage of (−∞,0](-\infty, 0] under f−gf - g. (c) It is the preimage of {0}\{0\} under (x,y)↦y−f(x)(x, y) \mapsto y - f(x), which is continuous as a composition and difference of continuous maps.

Exercise 1.30 How many codewords fit?

A binary code of length nn has minimum distance 2t+12t + 1. Show that the number of codewords is at most 2n/∑k=0t(nk)2^n \big/ \sum_{k=0}^t \binom{n}{k} (the Hamming bound), by counting the points in the disjoint balls of Proposition 1.6. For n=7n = 7 and t=1t = 1 the bound is 1616; the Hamming (7,4)(7, 4) code attains it, so its balls tile the whole cube.

Solution

A closed ball of radius tt in {0,1}n\{0,1\}^n contains ∑k=0t(nk)\sum_{k=0}^t \binom nk strings (choose which kk positions to flip). The balls around distinct codewords are disjoint and all lie in a set of 2n2^n strings. For n=7n = 7, t=1t = 1: 27/(1+7)=16=242^7/(1 + 7) = 16 = 2^4.

Exercise 1.31 Comparing the function metrics

(a) Show that d1(f,g)≤(b−a) d∞(f,g)d_1(f, g) \leq (b - a)\,d_\infty(f, g) for f,g∈C([a,b])f, g \in C([a, b]), so that uniform convergence implies convergence in d1d_1. (b) Use Example 1.20 to show that the open ball {f:d∞(f,0)<1}\{f : d_\infty(f, 0) < 1\} is open for d∞d_\infty but not for d1d_1. (So the two metrics have different open sets, not only different convergent sequences.)

Solution

(a) ∫ab∣f−g∣≤∫abd∞(f,g)=(b−a) d∞(f,g)\int_a^b |f - g| \leq \int_a^b d_\infty(f, g) = (b - a)\,d_\infty(f, g). (b) The zero function is in the set. Every d1d_1-ball around 00, of radius rr, contains 2fn2f_n for n>2/rn > 2/r, since d1(2fn,0)=2nd_1(2f_n, 0) = \tfrac2n; but d∞(2fn,0)=2d_\infty(2f_n, 0) = 2, so 2fn2f_n is not in the set. Hence 00 is not a d1d_1-interior point.

Exercise 1.32 Rehearsal: the Hausdorff distance

For non-empty closed bounded subsets A,BA, B of Rn\mathbb{R}^n, let Ar={x:d(x,a)≤r for some a∈A}A_r = \{x : d(x, a) \leq r \text{ for some } a \in A\} and define dH(A,B)=inf⁡{r≥0:A⊆Br and B⊆Ar}d_{\mathcal{H}}(A, B) = \inf\{r \geq 0 : A \subseteq B_r \text{ and } B \subseteq A_r\}. (a) Compute dHd_{\mathcal{H}} between the unit circle and the closed unit disc in R2\mathbb{R}^2, and between [0,1][0, 1] and {0,1n,2n,…,1}\{0, \tfrac1n, \tfrac2n, \dots, 1\}. (b) Show that dHd_{\mathcal{H}} satisfies the triangle inequality. (c) Show that a sequence of finite sets can converge in dHd_{\mathcal{H}} to an interval. This is how a sequence of discrete approximations, or of shrinking and rescaled shapes, can converge to a continuum. The Gromov–Hausdorff version of this metric is the one used for limits of Riemannian manifolds in 9B.4 Convergence of Manifolds.

Solution

(a) Every point of the disc is within 11 of the circle, and the centre is exactly 11 away, so dH=1d_{\mathcal{H}} = 1. For the grid, every point of [0,1][0, 1] is within 12n\tfrac1{2n} of a grid point, and the midpoint of a gap is exactly that far, so dH=12nd_{\mathcal{H}} = \tfrac1{2n}. (b) If A⊆BrA \subseteq B_r and B⊆CsB \subseteq C_s, then A⊆Cr+sA \subseteq C_{r+s} by the triangle inequality in Rn\mathbb{R}^n; similarly in the other direction. (c) By (a), the grids converge to [0,1][0, 1].

Free resources for this chapter

Chosen for what this chapter covers, and all free to read or watch. Links checked Nov 6, 2026.

Read

Watch 3 lectures and talks

© 2026 Neckpinch (www.neckpinch.com). All content in the guidebook (text, mathematics, figures and exercises) is protected by copyright. All rights reserved. No part may be copied, republished or redistributed without written permission.