Metric Spaces
How far apart are two points? On the real line the answer is . But the same question makes sense for pairs of functions, pairs of matrices, or pairs of cities on a curved earth. Each setting demands its own notion of distance. A metric space is the precise abstraction that captures what all reasonable notions of "distance" have in common. It is stripped down to four axioms that a distance function must satisfy. This single idea lets us transport the entire vocabulary of real analysis — convergence, continuity, open and closed sets, compactness — into wildly different worlds, from spaces of sequences to spaces of shapes. The importance of this abstraction is hard to overstate. Once you know that a set carries a metric, you automatically know several things. You know what it means for a sequence in to converge. You know what it means for a function on to be continuous. You also know what it means for a subset of to be open. None of these notions require to look anything like . They only require the four metric axioms. This is the first deliberate step of point-set topology: isolating the minimal structure needed to do analysis. That way, the same theorems apply equally to , to , to spaces of continuous functions, and beyond. The big picture is that metric spaces sit between concrete Euclidean geometry and the fully general notion of a topological space. A metric gives you a quantitative sense of closeness (a number measuring distance). Topology only retains the qualitative shadow of that structure (which sets are open). Every metric space generates a topology, but not every topology comes from a metric. This fact becomes important once you meet spaces that are "too big" or "too exotic" to be measured by a single distance function. This article gives the rigorous definition of a metric. It proves the basic inequalities that make the theory work. It walks through canonical examples: Euclidean space, the discrete metric, the sup-metric on function spaces, and the -adic-flavored world of sequence spaces. It shows precisely how a metric induces a geometry of balls, neighborhoods, and distances-between-sets. It sets the stage for Open and Closed Sets in Metric Spaces and for the completeness theory built on Completeness and Cauchy Sequences.
- A metric space is a set with a distance function satisfying positivity, symmetry, identity of indiscernibles, and the triangle inequality.
- Familiar spaces ( with Euclidean distance, function spaces with sup-distance) are metric spaces once you check the four axioms.
- The triangle inequality is the load-bearing axiom: nearly every estimate in analysis is secretly an application of it.
- Balls are the basic building blocks of the geometry a metric induces.
- Different metrics on the same set can produce different — or surprisingly identical — notions of closeness.
- Key idea: a metric turns "distance" into a genuine mathematical object, letting analysis be done on any set, not just on .
Where this lives today
Metric spaces are the working environment for virtually all of modern analysis. In functional analysis, spaces of functions (continuous functions with the sup-metric, square-integrable functions with an -metric) are metric spaces whose completeness — see Completeness and Cauchy Sequences — underlies the existence theory for differential equations via fixed-point arguments. In geometry, Riemannian manifolds carry a metric induced by their curvature, and the study of "metric geometry" (Gromov-Hausdorff distances between spaces themselves) extends the idea to comparing entire spaces rather than points. In computer science, metric spaces model similarity search: nearest-neighbor algorithms, clustering, and recommendation systems all depend on choosing an appropriate distance function on data (Euclidean distance on vectors, edit distance on strings, cosine distance on embeddings). In statistics and machine learning, metrics on probability distributions (Wasserstein distance, total variation distance) quantify how different two distributions are, feeding directly into generative modeling and hypothesis testing. In cryptography and coding theory, the Hamming metric on binary strings measures how many bits two codewords differ in, driving error-correction design. Physics uses metric structures both literally (spacetime intervals in relativity, though there the "distance" can be negative, a genuinely different structure called a pseudo-Riemannian metric) and analogically (phase-space distances in dynamical systems). All of this rests on the same four axioms introduced here, and all of it feeds forward into the topological machinery of Open and Closed Sets in Metric Spaces and eventually the fully abstract setting of Topological Spaces and Open Sets.
Ask the tutor: Can you show me exactly how open balls in a metric space generate a topology, and why not every topology can arise this way?
Let be a nonempty set. A metric on is a function
satisfying, for all : 1. (Non-negativity) . 2. (Identity of indiscernibles) if and only if . 3. (Symmetry) . 4. (Triangle inequality) . The pair is called a metric space. When the metric is clear from context we simply say "the metric space ." For and , the open ball of radius centered at is
Intuition
Think of the four axioms as encoding exactly what you would demand of any sensible "distance" before trusting it. Non-negativity says distances are never negative — you cannot be a negative amount of effort away from somewhere. Identity of indiscernibles says the only point at distance zero from is itself; distance is a genuine separator of points, not a fuzzy approximate one. Symmetry says the distance from to equals the distance from to — a strong assumption in some real-world settings (a one-way street violates this!), but built into the mathematical notion of metric. The triangle inequality is the deepest axiom: it says that going directly from to is never longer than detouring through . Geometrically, in the plane, this is just the fact that any side of a triangle is at most the sum of the other two. Once you accept these four rules, an entire geometry crystallizes around the set . The open balls play the role that "intervals around a point" play on the real line: they are the neighborhoods that will be used to define limits, continuity, and open sets. Crucially, the shape of a ball depends entirely on the metric, not just on the underlying set. In with the usual Euclidean distance, a ball is a round disk; with a different but equally legitimate metric, the "ball" of the same radius can be a diamond or a square. The figure below shows three different unit balls around the origin in , all valid metric-space geometries living on the exact same underlying set of points.
Let be a metric space. Then for all :
(a) Reverse triangle inequality.
(b) Quadrilateral inequality.
(c) For every fixed , the function defined by is continuous, in the sense that (meaning ) implies .
Proof technique: direct algebraic manipulation of the defining triangle inequality (axiom 4), applied twice with cleverly chosen intermediate points, followed by an -argument for continuity.
(a) By the triangle inequality applied to the three points ,
which rearranges to
Now apply the triangle inequality again, to the three points (using symmetry, axiom 3, to write ):
which rearranges to
Combining (i) and (ii), both and its negative are , so
proving (a).
(b) Apply the ordinary triangle inequality (axiom 4) twice, inserting the intermediate points and :
where the second step used the triangle inequality on . Using symmetry (, ) this reads
By the identical argument with the roles of and swapped,
using symmetry once more. Combining (iii) and (iv) as in part (a) gives
proving (b).
(c) Fix and suppose , i.e. as . By part (a) applied with in place of and in place of :
Since , the squeeze theorem for real sequences forces
i.e. . This proves (c).
∎For fixed , the map satisfies for all (this is exactly part (a) of the theorem, reread). Consequently for every , choosing gives , so is uniformly continuous on .
Worked examples
Example 1: The sup-metric on bounded functions, and a genuine triangle-inequality check with unequal terms. Let be the set of all bounded real-valued functions on . Define
This is finite since are bounded (so for all , giving a finite upper bound, hence a finite supremum). Let's verify all four axioms and then do a genuinely asymmetric numerical check. Non-negativity: for every , so the sup of these values is . Identity of indiscernibles: if then for all , so the sup is . Conversely if then forces for every (if it were positive at some , the sup would be at least that positive value), so for all , i.e. . Symmetry: pointwise, so the sups agree. Triangle inequality: for every ,
using the ordinary triangle inequality for real numbers pointwise, then bounding each term by its supremum. The right side does not depend on , so it is an upper bound for the set , hence
Now a concrete, deliberately asymmetric numerical check. Let
Compute . The function has derivative on , so is strictly decreasing; its extreme values on occur at the endpoints: , . So is maximized at an endpoint, giving . Compute . At : . At : . At : . Since throughout and ranges over , the maximum gap is at , giving (checking nearby points confirms the maximum of the increasing-ish expression occurs at , since its derivative is positive whenever , true for all close enough to , and one checks the derivative is positive throughout except possibly very near where it's still ; so the expression is increasing and its max is at ). Compute . At : . At : . At : , , difference . The maximum magnitude on is at , giving . The triangle inequality claims , i.e.
which indeed holds — with plenty of room to spare, illustrating that the inequality need not be tight.
Example 2: The discrete metric and a non-Euclidean ball structure. Let be any nonempty set (say , four abstract symbols with no numerical structure at all), and define
Check the axioms: non-negativity and symmetry are immediate from the definition, and identity of indiscernibles holds by construction ( exactly when ). For the triangle inequality, take any . If , then automatically since the right side is a sum of non-negative numbers. If , then ; we must show . If then since we get , so the sum is at least . If , then already, so the sum is at least . Either way , so the triangle inequality holds in every case. Now compute balls. For any and , , since the only point at distance from is itself (any other point is at distance exactly ). For , , since every point (including ) is at distance . So in the discrete metric every ball is either a single point or the entire space — there is no "shrinking gradually," unlike Euclidean balls, which illustrates how differently the same four axioms can behave on different spaces.
Consider and define
Check non-negativity: yes, . Identity of indiscernibles: , yes. Symmetry: , yes. So three of the four axioms hold — but the triangle inequality fails. Take , , . Then
Since , we have , violating the triangle inequality. So is not a metric on , even though it satisfies the other three axioms and is a perfectly reasonable-looking non-negative symmetric function vanishing exactly on the diagonal. This matters because without the triangle inequality, none of the "closeness propagates" arguments used throughout analysis survive: continuity proofs, Cauchy sequence arguments, and the very notion of "balls forming a basis for neighborhoods" all rely on being able to bound by a detour through . Dropping this one axiom breaks the entire analytic machinery that metric spaces are built to support — it is not a cosmetic weakening but a structural one. (As an aside: is a metric — the ordinary one — showing that a non-metric "squared distance" can still be repaired by taking a square root; this is a special case of a general phenomenon but the repair is not automatic for arbitrary non-metrics.)
Scope, edge cases & common traps
| Situation | What to watch for |
|---|---|
| Checking a candidate is a metric | All four axioms must be verified; symmetry and non-negativity are usually easy, the triangle inequality is where errors hide |
| Distance between sets, | This is not a metric on subsets: distinct sets can have (e.g. , in ), violating identity of indiscernibles |
| Balls in non-Euclidean metrics | need not be round, or even bounded-looking the way you expect; in the discrete metric it is either or all of |
| "Distance zero implies equal" | Only guaranteed by axiom 2; pseudometrics deliberately drop this and allow for |
| Triangle inequality direction | It bounds the direct distance by the detour, never the other way; do not misapply it as |
The mathematician behind it
Origins · 1 minMaurice René Fréchet and how this was discovered
Fréchet introduced the general notion of a metric space (which he initially called an "écart," meaning "gap" or "spread," in his 1906 doctoral thesis) in order to unify convergence phenomena that analysts had been studying separately in different concrete settings: sequences of numbers, sequences of functions, and sequences of curves. His thesis, written under Jacques Hadamard, is widely regarded as a founding document of general topology, since it isolated the abstract properties of distance needed to make sense of limits and continuity without reference to any particular ambient space like .
Is every distance-like function automatically a metric?
No. A function must satisfy all four axioms — non-negativity, identity of indiscernibles, symmetry, and the triangle inequality — to qualify as a metric. It is common for a natural-looking candidate to fail exactly one axiom. The squared-distance function on satisfies three of the four axioms but fails the triangle inequality, as shown explicitly in the counterexample above. Similarly, "distance between subsets" fails identity of indiscernibles because two distinct but touching or overlapping sets can have infimum distance zero. Always check all four conditions for arbitrary points before declaring something a metric.
What is the difference between a metric and a norm?
A norm is defined on a vector space and measures the "size" of a single vector, written , satisfying positivity, homogeneity (), and the triangle inequality for vectors. Every norm induces a metric via , and one can check this satisfies all four metric axioms using the norm axioms. However, not every metric comes from a norm: a metric only requires a set (no vector space structure, no addition or scalar multiplication needed), so metrics can be defined on sets with no linear structure at all, such as finite sets or spaces of shapes.
Can a metric take the value zero for two different points?
No — this is precisely ruled out by axiom 2, identity of indiscernibles, which requires if and only if . A function satisfying the other three axioms but allowing for some is called a pseudometric, not a metric; pseudometrics are useful in some constructions (for instance, before quotienting by an equivalence relation that identifies points at distance zero) but are a genuinely weaker structure.
Does every set admit at least one metric?
Yes. Every nonempty set admits the discrete metric, if and otherwise, which was verified to satisfy all four axioms in the worked example above. So "being metrizable" is never an obstruction for a bare set; the interesting metrizability questions arise only once is equipped with additional structure, such as a topology, and one asks whether that existing topology can be realized by some metric.
Why does the triangle inequality matter so much more than the other three axioms?
The other three axioms are largely bookkeeping: they ensure distance is a sensible, symmetric, non-negative quantity that vanishes only trivially. The triangle inequality is the axiom that actually does analytic work — it is what allows you to control the distance between two points by routing through a third, which is exactly the mechanism behind convergence arguments, continuity proofs, and the very definition of Cauchy sequences. Nearly every " + " argument in analysis is a disguised triangle inequality application.
Are open balls in a general metric space always "round" like Euclidean disks?
No. The shape of depends entirely on the metric. Under the Euclidean metric on balls are round disks, but under the (taxicab) metric they are diamonds, and under the sup-metric they are squares, as shown in the figure. In the discrete metric, balls are either a single point or the whole space, with no intermediate shapes at all. "Ball" is topological terminology borrowed from the familiar Euclidean picture, but the term applies to the possibly very different set in any metric space.
How does a metric space relate to a topological space?
A metric space automatically generates a topology: declare a set open if it is a union of open balls, or equivalently if every point has some ball around it contained in the set. This satisfies the axioms of a topology (arbitrary unions and finite intersections of open sets are open), making every metric space a topological space. The reverse is not always true — some topological spaces cannot arise from any metric, a phenomenon studied under the heading of metrizability, which becomes central once you meet Topological Spaces and Open Sets in full generality.