JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

What Is a Metric?

A metric is a single function d(x, y) obeying four axioms. We motivate them, state them precisely, and check several genuinely different examples on the same underlying set.

Keeping only distance

On the real line we measure how far apart two numbers are with absolute value: the distance from x to a is |x − a|. Almost everything in elementary analysis — limits, continuity, convergence — is phrased through that single quantity. The big idea of a metric space is to keep the notion of distance and throw away everything else. We ask: what are the bare properties of |x − a| that the whole theory actually used?

The answer is short. We need distance to be never negative, to be zero exactly when the two points coincide, to be symmetric, and to satisfy the triangle inequality. A metric is any function that obeys those four rules. The remarkable fact, which the rest of this track unfolds, is that those four rules are enough to rebuild open sets, convergence, and completeness — for spaces of functions, sequences, codewords, even fractals.

The four axioms

Let X be a set of points. A metric on X is a function d : X × X → R assigning a real number to each pair of points, subject to the following, for all x, y, z in X:

  1. Non-negativity: d(x, y) ≥ 0. Distances are never negative.
  2. Identity of indiscernibles: d(x, y) = 0 if and only if x = y. Distance zero pins down a point exactly.
  3. Symmetry: d(x, y) = d(y, x). The distance from x to y equals the distance back.
  4. Triangle inequality: d(x, z) ≤ d(x, y) + d(y, z). A detour through y is never shorter than going straight.

Examples, and one verification

On the plane R^2 the familiar Euclidean metric is d2(x, y) = sqrt((x1 − y1)^2 + (x2 − y2)^2). But the taxicab metric d1(x, y) = |x1 − y1| + |x2 − y2| and the max metric d∞(x, y) = max(|x1 − y1|, |x2 − y2|) are also metrics on the very same plane. On any set whatsoever the discrete metric — d(x, y) = 1 when x ≠ y, and 0 when x = y — quietly satisfies all four axioms. Let us prove the discrete metric obeys the triangle inequality, the only axiom with any content here.

Claim: the discrete metric d satisfies d(x, z) <= d(x, y) + d(y, z).

Recall d takes only the values 0 and 1.

Case 1: x = z.
  Then d(x, z) = 0, and the right side is >= 0,
  so 0 <= d(x, y) + d(y, z) holds trivially.

Case 2: x != z.
  Then d(x, z) = 1. We must show d(x, y) + d(y, z) >= 1.
  The point y cannot equal BOTH x and z (since x != z),
  so at least one of x != y or y != z holds.
  Whichever it is contributes a 1 to the right side, hence
      d(x, y) + d(y, z) >= 1 = d(x, z).

Both cases hold, so the triangle inequality holds.   QED
The discrete metric: the triangle inequality reduces to a two-case argument.