1. Home
  2. Explore
  3. Mathematics
  4. Introduction to Metric Spaces

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to Metric Spaces

Metric Spaces: Distance, Geometry, and Metrics Induced by Norms

A metric space is a mathematical setting in which it is possible to talk about distance. The setting is intentionally broad: its elements might be real numbers, complex numbers, points in the plane, physical objects, or even a small collection of markers. What matters is not what the elements are, but whether a suitable notion of distance can be defined between them.

A metric space consists of two ingredients:

  1. A set MMM of elements.
  2. A function DDD that assigns a real-valued distance to every ordered pair of elements in MMM.

The distance function is written

D:M×M→R.D:M\times M\to\mathbb{R}.D:M×M→R.

For elements X,Y∈MX,Y\in MX,Y∈M, the value D(X,Y)D(X,Y)D(X,Y) represents the distance from XXX to YYY. To qualify as a metric, the function must satisfy four fundamental properties.

The Four Properties of a Metric

Positivity

Distances cannot be negative. For every pair of elements X,Y∈MX,Y\in MX,Y∈M,

D(X,Y)≥0.D(X,Y)\ge 0.D(X,Y)≥0.

This property is also called nonnegativity. It reflects the ordinary meaning of distance: a separation can be zero or positive, but not negative.

For example, a physical distance might be 333 meters, but it would not make sense for it to be −3-3−3 meters.

Non-degeneracy

The distance between two elements is zero exactly when the elements are the same:

D(X,Y)=0if and only ifX=Y.D(X,Y)=0 \quad\text{if and only if}\quad X=Y.D(X,Y)=0if and only ifX=Y.

This is called non-degeneracy or the identity of indiscernibles. It ensures that the metric can distinguish different elements. If two distinct elements had distance zero, the distance function would be collapsing them together and would fail to represent genuine separation.

The phrase “if and only if” is important because both directions must hold:

  • If X=YX=YX=Y, then D(X,Y)=0D(X,Y)=0D(X,Y)=0.
  • If D(X,Y)=0D(X,Y)=0D(X,Y)=0, then X=YX=YX=Y.

Symmetry

The distance from XXX to YYY must equal the distance from YYY to XXX:

D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).

The order of the two elements does not affect the distance. For instance, the distance from a green marker to an orange marker must be the same as the distance from the orange marker to the green marker.

The Triangle Inequality

For any X,Y,Z∈MX,Y,Z\in MX,Y,Z∈M,

D(X,Y)≤D(X,Z)+D(Z,Y).D(X,Y)\le D(X,Z)+D(Z,Y).D(X,Y)≤D(X,Z)+D(Z,Y).

This property says that traveling directly from XXX to YYY cannot be longer than traveling from XXX to ZZZ and then from ZZZ to YYY.

The point ZZZ represents a possible detour. The direct route from XXX to YYY is never longer than a route that passes through an intermediate point.

In the ordinary Euclidean plane, the triangle inequality says that the length of one side of a triangle cannot exceed the sum of the lengths of the other two sides. If the points are XXX, YYY, and ZZZ, then

length(XY)≤length(XZ)+length(ZY).\text{length}(XY)\le \text{length}(XZ)+\text{length}(ZY).length(XY)≤length(XZ)+length(ZY).

A metric is a rule for measuring distance that is nonnegative, separates distinct points, is symmetric, and obeys the triangle inequality.

Think About It

If a proposed distance function assigns a negative value to some pair of elements, which metric property fails immediately? What if two different elements have distance zero?

The Discrete Metric

The flexibility of the definition becomes clearer through an unusual example. Let MMM be a set containing five markers. The elements of MMM are not numbers or points in a plane; they are simply distinct objects.

Define the discrete metric by

D(X,Y)={0,X=Y,1,X≠Y.D(X,Y)= \begin{cases} 0, & X=Y,\\ 1, & X\ne Y. \end{cases}D(X,Y)={0,1,​X=Y,X=Y.​

Thus, the only possible distances are 000 and 111:

  • An object has distance 000 from itself.
  • Every pair of distinct objects has distance 111.

For example,

D(orange,orange)=0,D(\text{orange},\text{orange})=0,D(orange,orange)=0,

while

D(orange,green)=1.D(\text{orange},\text{green})=1.D(orange,green)=1.

The physical locations of the markers do not matter. Even if two distinct markers are placed very close together or very far apart, their discrete distance is still 111.

Verifying Positivity

The discrete metric only produces the values 000 and 111. Neither value is negative, so

D(X,Y)≥0.D(X,Y)\ge 0.D(X,Y)≥0.

Therefore, positivity holds automatically.

Verifying Non-degeneracy

The definition directly gives

X=Y  ⟹  D(X,Y)=0.X=Y\implies D(X,Y)=0.X=Y⟹D(X,Y)=0.

Conversely, the only way the discrete metric can equal zero is if the two elements are the same. Therefore,

D(X,Y)=0  ⟺  X=Y.D(X,Y)=0\iff X=Y.D(X,Y)=0⟺X=Y.

Non-degeneracy holds.

Verifying Symmetry

If X=YX=YX=Y, then both D(X,Y)D(X,Y)D(X,Y) and D(Y,X)D(Y,X)D(Y,X) equal 000.

If X≠YX\ne YX=Y, then both values equal 111. Hence,

D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).

Symmetry holds.

Verifying the Triangle Inequality

The triangle inequality requires

D(X,Y)≤D(X,Z)+D(Z,Y).D(X,Y)\le D(X,Z)+D(Z,Y).D(X,Y)≤D(X,Z)+D(Z,Y).

For the discrete metric, the left-hand side can only be 000 or 111. Each term on the right-hand side can also only be 000 or 111, so the sum on the right can be 000, 111, or 222.

The only possible way for the inequality to fail would be

D(X,Y)=1andD(X,Z)+D(Z,Y)=0.D(X,Y)=1 \quad\text{and}\quad D(X,Z)+D(Z,Y)=0.D(X,Y)=1andD(X,Z)+D(Z,Y)=0.

For the right-hand side to equal zero, both terms must be zero:

D(X,Z)=0andD(Z,Y)=0.D(X,Z)=0 \quad\text{and}\quad D(Z,Y)=0.D(X,Z)=0andD(Z,Y)=0.

By non-degeneracy, these imply

X=ZandZ=Y.X=Z \quad\text{and}\quad Z=Y.X=ZandZ=Y.

By transitivity of equality,

X=Y.X=Y.X=Y.

But then D(X,Y)D(X,Y)D(X,Y) must equal 000, contradicting the assumption that D(X,Y)=1D(X,Y)=1D(X,Y)=1. Therefore, the failure case is impossible, and the triangle inequality holds.

The marker set equipped with the discrete metric is therefore a metric space.

Geometry in the Discrete Metric

Changing the metric changes the geometry. A circle is defined using distance, so its appearance depends on the chosen distance function.

A circle centered at a point PPP with radius rrr is the set of all points at exactly distance rrr from PPP:

{X∈M:D(X,P)=r}.\{X\in M:D(X,P)=r\}.{X∈M:D(X,P)=r}.

Unit Circles

Consider the discrete metric and a center marker PPP.

The unit circle centered at PPP consists of every other marker:

{X∈M:D(X,P)=1}.\{X\in M:D(X,P)=1\}.{X∈M:D(X,P)=1}.

Since every marker different from PPP has distance 111 from PPP, all of those markers belong to the unit circle.

Circles of Radius Two

No two markers have discrete distance 222. Therefore, the circle centered at PPP with radius 222 is empty:

{X∈M:D(X,P)=2}=∅.\{X\in M:D(X,P)=2\}=\varnothing.{X∈M:D(X,P)=2}=∅.

This differs sharply from Euclidean geometry, where circles with many positive radii contain infinitely many points.

Closed Discs of Radius One

A closed disc of radius 111 centered at PPP consists of all points whose distance from PPP is at most $1:

{X∈M:D(X,P)≤1}.\{X\in M:D(X,P)\le 1\}.{X∈M:D(X,P)≤1}.

Every element of the discrete metric space has distance either 000 or 111 from PPP. Consequently, the closed disc of radius 111 is the entire set MMM.

This example shows that familiar geometric objects do not have universal appearances. Their descriptions depend on the metric being used.

Think About It

In the discrete metric, why is the circle of radius 222 empty while the closed disc of radius 111 contains every element?

The Taxi Cab Metric on the Plane

A second example uses the ordinary plane R2\mathbb{R}^2R2, but gives it a different notion of distance.

For points

U=(U1,U2)andV=(V1,V2),U=(U_1,U_2) \quad\text{and}\quad V=(V_1,V_2),U=(U1​,U2​)andV=(V1​,V2​),

the taxi cab metric, also called the Manhattan metric, is defined by

D(U,V)=∣U1−V1∣+∣U2−V2∣.D(U,V)=|U_1-V_1|+|U_2-V_2|.D(U,V)=∣U1​−V1​∣+∣U2​−V2​∣.

The first absolute value measures the horizontal separation, and the second measures the vertical separation. The two distances are added because movement is restricted to horizontal and vertical directions.

Example of Taxi Cab Distance

Consider

U=(−3,1)andV=(2,3).U=(-3,1) \quad\text{and}\quad V=(2,3).U=(−3,1)andV=(2,3).

The horizontal separation is

∣−3−2∣=5,|-3-2|=5,∣−3−2∣=5,

and the vertical separation is

∣1−3∣=2.|1-3|=2.∣1−3∣=2.

Therefore,

D(U,V)=∣−3−2∣+∣1−3∣=5+2=7.D(U,V)=|-3-2|+|1-3|=5+2=7.D(U,V)=∣−3−2∣+∣1−3∣=5+2=7.

The taxi cab distance is not the length of the straight line segment between the points. The Euclidean distance would measure the direct diagonal route, while the taxi cab metric measures the total horizontal and vertical movement required.

The name comes from a city-grid analogy. A taxi cannot drive directly through buildings. It must follow streets, moving along blocks. The distance is therefore the number of blocks traveled horizontally plus the number traveled vertically.

Verifying Positivity

Absolute values are always nonnegative:

∣U1−V1∣≥0and∣U2−V2∣≥0.|U_1-V_1|\ge 0 \quad\text{and}\quad |U_2-V_2|\ge 0.∣U1​−V1​∣≥0and∣U2​−V2​∣≥0.

Their sum is also nonnegative:

D(U,V)=∣U1−V1∣+∣U2−V2∣≥0.D(U,V)=|U_1-V_1|+|U_2-V_2|\ge 0.D(U,V)=∣U1​−V1​∣+∣U2​−V2​∣≥0.

Thus, positivity follows directly from the definition.

Verifying Non-degeneracy

First, if U=VU=VU=V, then their coordinates are equal:

U1=V1andU2=V2.U_1=V_1 \quad\text{and}\quad U_2=V_2.U1​=V1​andU2​=V2​.

Therefore,

D(U,V)=∣U1−V1∣+∣U2−V2∣=∣0∣+∣0∣=0.D(U,V)=|U_1-V_1|+|U_2-V_2| =|0|+|0|=0.D(U,V)=∣U1​−V1​∣+∣U2​−V2​∣=∣0∣+∣0∣=0.

For the converse, suppose

D(U,V)=0.D(U,V)=0.D(U,V)=0.

Then

∣U1−V1∣+∣U2−V2∣=0.|U_1-V_1|+|U_2-V_2|=0.∣U1​−V1​∣+∣U2​−V2​∣=0.

Both terms are nonnegative. A sum of nonnegative numbers can equal zero only if each term equals zero:

∣U1−V1∣=0and∣U2−V2∣=0.|U_1-V_1|=0 \quad\text{and}\quad |U_2-V_2|=0.∣U1​−V1​∣=0and∣U2​−V2​∣=0.

Thus,

U1=V1andU2=V2,U_1=V_1 \quad\text{and}\quad U_2=V_2,U1​=V1​andU2​=V2​,

which means U=VU=VU=V. Hence,

D(U,V)=0  ⟺  U=V.D(U,V)=0\iff U=V.D(U,V)=0⟺U=V.

Verifying Symmetry

The distance from VVV to UUU is

D(V,U)=∣V1−U1∣+∣V2−U2∣.D(V,U)=|V_1-U_1|+|V_2-U_2|.D(V,U)=∣V1​−U1​∣+∣V2​−U2​∣.

Absolute value is unchanged when the order of subtraction is reversed:

∣V1−U1∣=∣U1−V1∣,∣V2−U2∣=∣U2−V2∣.|V_1-U_1|=|U_1-V_1|, \qquad |V_2-U_2|=|U_2-V_2|.∣V1​−U1​∣=∣U1​−V1​∣,∣V2​−U2​∣=∣U2​−V2​∣.

Therefore,

D(V,U)=∣U1−V1∣+∣U2−V2∣=D(U,V).D(V,U)=|U_1-V_1|+|U_2-V_2|=D(U,V).D(V,U)=∣U1​−V1​∣+∣U2​−V2​∣=D(U,V).

Symmetry holds.

Verifying the Triangle Inequality

Let

U=(U1,U2),V=(V1,V2),W=(W1,W2).U=(U_1,U_2),\quad V=(V_1,V_2),\quad W=(W_1,W_2).U=(U1​,U2​),V=(V1​,V2​),W=(W1​,W2​).

The taxi cab distance from UUU to VVV is

D(U,V)=∣U1−V1∣+∣U2−V2∣.D(U,V)=|U_1-V_1|+|U_2-V_2|.D(U,V)=∣U1​−V1​∣+∣U2​−V2​∣.

Insert W1W_1W1​ and W2W_2W2​ into the coordinate differences:

U1−V1=(U1−W1)+(W1−V1),U_1-V_1=(U_1-W_1)+(W_1-V_1),U1​−V1​=(U1​−W1​)+(W1​−V1​),

and

U2−V2=(U2−W2)+(W2−V2).U_2-V_2=(U_2-W_2)+(W_2-V_2).U2​−V2​=(U2​−W2​)+(W2​−V2​).

Using the triangle inequality for absolute value,

∣a+b∣≤∣a∣+∣b∣,|a+b|\le |a|+|b|,∣a+b∣≤∣a∣+∣b∣,

gives

∣U1−V1∣≤∣U1−W1∣+∣W1−V1∣,|U_1-V_1| \le |U_1-W_1|+|W_1-V_1|,∣U1​−V1​∣≤∣U1​−W1​∣+∣W1​−V1​∣,

and

∣U2−V2∣≤∣U2−W2∣+∣W2−V2∣.|U_2-V_2| \le |U_2-W_2|+|W_2-V_2|.∣U2​−V2​∣≤∣U2​−W2​∣+∣W2​−V2​∣.

Adding these inequalities yields

D(U,V)≤∣U1−W1∣+∣U2−W2∣+∣W1−V1∣+∣W2−V2∣.D(U,V) \le |U_1-W_1|+|U_2-W_2| + |W_1-V_1|+|W_2-V_2|.D(U,V)≤∣U1​−W1​∣+∣U2​−W2​∣+∣W1​−V1​∣+∣W2​−V2​∣.

Recognizing the two groups as taxi cab distances gives

D(U,V)≤D(U,W)+D(W,V).D(U,V)\le D(U,W)+D(W,V).D(U,V)≤D(U,W)+D(W,V).

Thus, the taxi cab metric satisfies the triangle inequality, and R2\mathbb{R}^2R2 equipped with this metric is a metric space.

Shortest Paths in the Taxi Cab Metric

In Euclidean geometry, two points have one straight-line shortest path between them. The taxi cab metric allows many shortest paths.

For example, a route may move horizontally first and vertically second, vertically first and horizontally second, or alternate between the two directions. Every route that moves the required amount horizontally and vertically without unnecessary backtracking has the same total length.

The distance is determined by the total coordinate changes, not by the particular order in which those changes occur.

Circles in the Taxi Cab Metric

Consider the circle of radius 222 centered at the origin (0,0)(0,0)(0,0). A point (x,y)(x,y)(x,y) belongs to this circle when

D((x,y),(0,0))=2.D((x,y),(0,0))=2.D((x,y),(0,0))=2.

Using the taxi cab formula,

∣x∣+∣y∣=2.|x|+|y|=2.∣x∣+∣y∣=2.

This equation produces a diamond rather than the familiar Euclidean circle.

For example, points such as

(2,0),(0,2),(−2,0),(0,−2)(2,0),\quad (0,2),\quad (-2,0),\quad (0,-2)(2,0),(0,2),(−2,0),(0,−2)

lie on the circle. So do points such as

(1.5,0.5)and(0.5,1.5),(1.5,0.5) \quad\text{and}\quad (0.5,1.5),(1.5,0.5)and(0.5,1.5),

because in each case the sum of the absolute coordinate values is 222.

The four line segments connecting these extreme points form a diamond. Therefore, the geometric appearance of a circle depends entirely on the metric used to define “equal distance from the center.”

Think About It

Why does the equation ∣x∣+∣y∣=2|x|+|y|=2∣x∣+∣y∣=2 produce a diamond, while a Euclidean circle is described by an equation involving x2+y2x^2+y^2x2+y2?

Norms Induce Metrics

A major connection exists between normed vector spaces and metric spaces.

A normed vector space VVV already has a function ∥ ⋅ ∥\|\,\cdot\,\|∥⋅∥ that measures the size or magnitude of vectors. From this norm, a distance can be defined by

D(V,W)=∥V−W∥.D(V,W)=\|V-W\|.D(V,W)=∥V−W∥.

This is called the metric induced by the norm. The set underlying the metric space is the set of vectors in the normed vector space.

The reason this construction works is that the four metric properties follow from the corresponding properties of the norm.

Positivity from Norm Positivity

A norm is always nonnegative, so

∥V−W∥≥0.\|V-W\|\ge 0.∥V−W∥≥0.

Therefore,

D(V,W)≥0.D(V,W)\ge 0.D(V,W)≥0.

The metric inherits positivity directly from the norm.

Non-degeneracy from Norm Non-degeneracy

A norm equals zero exactly when its argument is the zero vector:

∥X∥=0  ⟺  X=0.\|X\|=0\iff X=\mathbf{0}.∥X∥=0⟺X=0.

For the induced metric,

D(V,W)=0  ⟺  ∥V−W∥=0.D(V,W)=0 \iff \|V-W\|=0.D(V,W)=0⟺∥V−W∥=0.

By non-degeneracy of the norm,

∥V−W∥=0  ⟺  V−W=0.\|V-W\|=0 \iff V-W=\mathbf{0}.∥V−W∥=0⟺V−W=0.

Adding WWW to both sides gives

V=W.V=W.V=W.

Thus,

D(V,W)=0  ⟺  V=W.D(V,W)=0\iff V=W.D(V,W)=0⟺V=W.

Symmetry from Norm Multiplicativity

To prove symmetry, begin with

D(W,V)=∥W−V∥.D(W,V)=\|W-V\|.D(W,V)=∥W−V∥.

Since

W−V=−(V−W),W-V=-(V-W),W−V=−(V−W),

this becomes

D(W,V)=∥−(V−W)∥.D(W,V)=\|-(V-W)\|.D(W,V)=∥−(V−W)∥.

The norm is absolutely homogeneous, meaning

∥αX∥=∣α∣ ∥X∥.\|\alpha X\|=|\alpha|\,\|X\|.∥αX∥=∣α∣∥X∥.

Using α=−1\alpha=-1α=−1 gives

∥−(V−W)∥=∣−1∣ ∥V−W∥=∥V−W∥.\|-(V-W)\| = |-1|\,\|V-W\| = \|V-W\|.∥−(V−W)∥=∣−1∣∥V−W∥=∥V−W∥.

Therefore,

D(W,V)=∥V−W∥=D(V,W).D(W,V)=\|V-W\|=D(V,W).D(W,V)=∥V−W∥=D(V,W).

Symmetry comes from the norm’s behavior under multiplication by the scalar −1-1−1.

The Triangle Inequality from the Norm Triangle Inequality

For any U,V,W∈VU,V,W\in VU,V,W∈V,

V−W=(V−U)+(U−W).V-W=(V-U)+(U-W).V−W=(V−U)+(U−W).

Therefore,

D(V,W)=∥V−W∥=∥(V−U)+(U−W)∥.D(V,W)=\|V-W\| = \|(V-U)+(U-W)\|.D(V,W)=∥V−W∥=∥(V−U)+(U−W)∥.

Applying the triangle inequality for the norm gives

∥(V−U)+(U−W)∥≤∥V−U∥+∥U−W∥.\|(V-U)+(U-W)\| \le \|V-U\|+\|U-W\|.∥(V−U)+(U−W)∥≤∥V−U∥+∥U−W∥.

Recognizing the two terms as induced distances,

D(V,W)≤D(V,U)+D(U,W).D(V,W)\le D(V,U)+D(U,W).D(V,W)≤D(V,U)+D(U,W).

Thus, the induced function is a metric.

Every normed vector space automatically becomes a metric space when distance is defined by D(V,W)=∥V−W∥D(V,W)=\|V-W\|D(V,W)=∥V−W∥.

The Hierarchy: Inner Products, Norms, and Metrics

These constructions form a one-way chain:

inner product⟶norm⟶metric.\text{inner product}\longrightarrow\text{norm}\longrightarrow\text{metric}.inner product⟶norm⟶metric.

An inner product can induce a norm, and a norm can induce a metric. For example, an inner product can produce the Euclidean magnitude of a vector, and that magnitude can then define distance between two vectors by taking the norm of their difference.

The reverse implications do not generally hold.

A metric space does not necessarily have:

  • An origin.
  • Vector addition.
  • Scalar multiplication.
  • A vector-space structure.
  • An inner product.

The discrete metric on a set of markers illustrates this point. The markers form a metric space because a valid distance function has been defined, but they do not automatically form a vector space. There is no specified vector addition, scalar multiplication, or distinguished zero vector. Consequently, a norm and an inner product cannot be inferred from the discrete metric alone.

A Normed Vector Space Can Have More Than One Metric

The induced metric

D(V,W)=∥V−W∥D(V,W)=\|V-W\|D(V,W)=∥V−W∥

is a natural metric on a normed vector space, but it is not necessarily the only possible metric.

For instance, even on a normed vector space, one could define the discrete metric:

D(V,W)={0,V=W,1,V≠W.D(V,W)= \begin{cases} 0, & V=W,\\ 1, & V\ne W. \end{cases}D(V,W)={0,1,​V=W,V=W.​

This would be a valid metric, although it would ignore the vector-space norm and treat every pair of distinct elements as equally far apart.

Thus, saying that a norm induces a metric means that the norm provides one guaranteed and useful way to define distance. It does not mean that the induced metric is the unique metric available.

Comprehensive Review

A metric space is a set MMM together with a real-valued distance function DDD. The distance must satisfy four conditions:

  1. Positivity:
    D(X,Y)≥0.D(X,Y)\ge 0.D(X,Y)≥0.

  2. Non-degeneracy:
    D(X,Y)=0  ⟺  X=Y.D(X,Y)=0\iff X=Y.D(X,Y)=0⟺X=Y.

  3. Symmetry:
    D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).D(X,Y)=D(Y,X).

  4. Triangle inequality:
    D(X,Y)≤D(X,Z)+D(Z,Y).D(X,Y)\le D(X,Z)+D(Z,Y).D(X,Y)≤D(X,Z)+D(Z,Y).

The discrete metric demonstrates that a metric space can be built on a set of arbitrary objects, with distance 000 for identical elements and 111 for distinct elements. In that geometry, a unit circle contains every point except its center, a radius-two circle is empty, and a closed disc of radius one contains the whole space.

The taxi cab metric on R2\mathbb{R}^2R2 measures horizontal plus vertical separation:

D(U,V)=∣U1−V1∣+∣U2−V2∣.D(U,V)=|U_1-V_1|+|U_2-V_2|.D(U,V)=∣U1​−V1​∣+∣U2​−V2​∣.

It models travel along a city grid, permits many shortest paths, and produces diamond-shaped circles.

Finally, every normed vector space becomes a metric space through

D(V,W)=∥V−W∥.D(V,W)=\|V-W\|.D(V,W)=∥V−W∥.

The metric’s positivity, non-degeneracy, symmetry, and triangle inequality come respectively from positivity, non-degeneracy, absolute homogeneity, and the triangle inequality of the norm. The central structural relationship is that inner products induce norms, norms induce metrics, and general metrics do not necessarily recover either a norm or an inner product.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent