An Introduction to Metric Spaces Content from the guide to life, the universe and everything

An Introduction to Metric Spaces

1 Conversation

Many branches of mathematics are concerned with the continuity and convergence of functions. The study of metric spaces allows mathematicians to put this in a more general setting - the concepts involved in metric spaces are, on the whole, totally abstract. This entry aims to lay the foundations for the study of metric spaces...

What is a Metric Space?

In general terms, a metric space is a space (which could be a plane, the surface of a sphere, three-dimensional space, etc) in which we have a notion of 'distance' which fits in with our geometrical intuition. Formally, we say that:

A metric space M = {Ad} consists of a non-empty set A together with a distance function1 dA×A → R2 which satisfies:
  1. d(xy) ≥ 0; d(xy) = 0 if and only if x = y
  2. d(xy) = d(yx) for all xy in A
  3. d(xy) + d(yz) ≥ d(xz) for all xyz in A

So, what does this actually mean? To start with, we must have a non-empty set A - basically a collection of one or more points. We also need a distance function, d, which can be used to calculate the distance between any two points of A. d must also follow certain rules.

The first rule says that we cannot have a negative distance - and the distance between two points can only be zero if the two points are, in fact, in exactly the same place. The second rule states that the distance between two points must be the same whichever direction we measure - going from x to y covers the same distance as going from y to x. Finally, we get the 'triangle inequality' - the combined distance of two sides of a triangle must not be less than the length of the third side.

Examples of Metric Spaces

Let us start with the most familiar metric space - the Euclidean metric in the plane. This is our intuitive distance function on flat surfaces - to measure a distance between two points, we take a straight line between them, and measure its length. Put formally, we use the distance function

d2(xy) = [(x1 - y1)2 + (x2 - y2)2]½

where x = (x1x2) and y = (y1y2).

This is not the only metric space, though. There are some much less intuitive metrics that we can use. For instance, the so-called 'Manhattan metric' on the plane. To measure a distance, we now measure the horizontal and vertical distances, and add the two together. In formal terms:

d1(xy) = |x1 - y1| + |x2 - y2|

Even more unusual is the 'infinity' metric - again we measure the vertical and horizontal distances, but the overall distance is the maximum of these two. That is:

d(xy) = Max {|x1 - y1|, |x2 - y2|}

Using these different definitions of 'distance', think what a 'circle' would look like in each of them. By 'circle', we mean 'the set of all points lying at a given distance from a fixed point'. Look at the diagram - you should see that using the d1 metric, the circle is in fact a diamond, and with the d metric we get a square.

We can also have 'discrete' metric spaces. Our set A may be any collection of points - as many or few as we wish. We now define our metric d by:

d(xy) = { 1  if x ≠ y
0  if x = y

We must check that this satisfies our three rules. Clearly rules one and two hold for all points x & y, so it remains only to check rule three, the triangle inequality.

If x = z then d(xz) = 0, so d(xy) + d(yz) ≥  d(xz). If x ≠ z (and therefore d(xz) = 1) then at least one of x ≠ y, y ≠ z must be true. Then we must have d(xy) + d(yz) = 1 or 2, so the rule holds.

Taking things to extremes, we can have a metric space, which contains just one point. It will not make any difference which metric (d) we use on this space, for reasons which will become apparent. Let us examine the three rules for a metric space:

  1. d(xy) ≥ 0; d(xy) = 0 if and only if x = y
  2. Since d is a metric, the first part of this statement must be true. For the second part, we must remember that our set A has only one point - so x = y is always true. Therefore d(xy) = 0.

  3. d(xy) = d(yx) for all xy in A
  4. Since we only have one point x in our set, this reduces to 'd(xx) = d(xx) for all x in A', which is trivially true.

  5. d(xy) + d(yz) ≥ d(xz) for all xyz in A
  6. This reduces to 'd(xx) + d(xx) ≥ d(xx) for all x in A' which is again trivially true.

And so our single-point set is indeed a metric space.


Let M = {Ad} be a metric space, and let H be a non-empty subset of A. Let dHH×H → R be the restriction of d to points of H (ie dH(xy) = d(xy) for all points xy in H).

Since M is a metric space, the three rules for distance functions must hold for all points in A, and therefore for all points in H. Hence dH satisfies our earlier definition of a metric.

The resultant metric space {HdH} is called a subspace of M, and dH is the metric on H induced by d.


In analysis of metric spaces, the concept of an open space is particularly important. In order to properly define this idea, it is useful to first examine boundedness.

A subset S of a metric space M = {Ad} is said to be bounded if there exist a in A and K in R such that d(xa) ≤ K for all x in S.

Put simply, if there is a point a in A such that all the points of A are within a circle of radius K, centred on a (remember how different 'circles' can be depending on the metric being used), then A is bounded.

Notice that if S satisfies this definition for some a in A and K in R, then it will also satisfy the definition with a replaced by any other point a' of A, and K replaced by K' = K + d(aa').

To prove this, let us examine a point x of A. If d(xa) ≤ K (our first definition of boundedness) then:

d(xa')d(xa) + d(aa') (By the triangle inequality)
 K + d(aa') (Because A bounded implies d(xa) ≤ K)
 =K' (By substitution)

It is interesting to see that the union of any finite number of bounded subsets of a metric space is itself bounded. Note that we only need to prove that the union of two such subsets is bounded, since we may build the union of a finite number of subsets by forming a union of two subsets, then forming a union of our new subset with a third subset, etc.

Let S1S2 be two bounded subsets of a metric space M = {Ad}, and let a1a2 in A and K1K2 in R be such that d(xa1) ≤ K1 for all x in S1, and d(xa2) ≤ K2 for all x in S2.

Let a = a1, and K = Max {K1K2 + d(a1a2)}. Then for any xin the union of S1 and S2 there are two possibilities. Either x is in S1, in which case d(xa) ≤ K1 ≤ K, or x is in S2, in which case

d(xa)=d(xa1) (By substitution)
 d(xa2) + d(a2a1) (Using the triangle inequality)
 K2 + d(a2a1) (Since S2 is bounded)
 K (By definition of K)

Hence our union is indeed bounded.

Open Balls

Let M = {Ad} be a metric space, let a be in A, and let ε > 0. The ε-ball of a in M is defined to be:

Bε(a) = {x in A | d(xa) < ε}

That is, the collection of points x in A within distance ε of a.

It is worth emphasising that Bε(a) does not include the boundary. It consists only of the interior of the 'ball'. If we were to include the boundary, it would become a closed ball.

One consequence of the non-inclusion of the boundary of our open balls is the way in which they can be nested. Let Bε(x) be an open ball in a metric space, and let y be a point in Bε(x). Then there is a δ > 0 for which Bδ(y) is contained completely within Bε(x). In R2 this means that we can draw a disc centred on y which lies entirely within the larger disc, centred on x. A look at the diagram should convince you that any δ satisfying δ + d(xy) ≤ ε will do.

For a formal proof of this, let δ = ε - d(xy). This must be greater than zero, since y is a point in Bε(x).

If z is in Bδ(y) then d(yz) < δ, and:

d(xz)d(xy) + d(yz) (By the triangle inequality)
 <d(xy) + δ (Since z is in Bδ(y))
 =ε (By definition of δ)

So z is in Bε(x), and hence Bδ(y) must be contained within Bε(x).

Examples of Open Balls

In R, Bε(a) = (a - ε, a + ε). That is, the collection of points x satisfying a - ε < x < a + ε.

In R2 (the plane), Bε(a) is the interior of a disc of radius ε centred on a.

In R3 (three-dimensional space), Bε(a) is the interior of a solid ball of radius ε centred on a.

The previous three examples have all used the Euclidean metric, that is, our intuitive notion of distance. Let us now look at some examples using other metrics.

In R2, using the d metric, Bε(a) is the interior of a square centred on a, with sides of length 2ε parallel to the co-ordinate axes.

In a discrete metric space M = {Ad}, we have

Bε(a) = { {a}  if ε ≤ 1
A  if ε > 1

In other words, if ε ≤ 1, Bε(a) is just the single point a. If ε > 1, Bε(a) is the whole space A.

Open Sets

Let U be a subset of a metric space M. U is open in M if given any point y in U there is a ε(y) > 0 such that Bε(y)(y) is contained entirely in U. Note that for different points y in U the value of ε(y) is allowed to be different. Also, it is important to specify which metric space we are operating in - the reasons will be explained later.

We have already shown that an open ball in a metric space M is open in M, since we can fit another open ball inside it, centred on any point we choose.

Examples (and Non-examples) of Open Sets

Let us look at the 'real line', R, also known as the number line. An open interval (ab)3 is open in R - around any point y in the interval we can fit another open interval, of the form (y - ε, y + ε) for some value of ε.

On the other hand, a closed (or half-closed) interval is not open in R. To see this, let [ab] be a closed interval. We now attempt to find an open interval Bε(a) around point a. By definition, a is in [ab], but no matter how small we take ε to be, Bε(a) would always include points less than the value of a - so Bε(a) is not contained within [ab].

It is important to note that not all open sets are open balls. Let our metric space be R2 with the Euclidean metric, and let U be the interior of a rectangle:

U = {(x1x2) | a < x1 < bc < x2 < d}

U is not an open ball in the Euclidean metric, but U is open in R2. This is easy to check: if x = (x1x2) is in U then Bε(x) is contained in U, where ε = Min{x1 - ab - x1x2 - cd - x2}.

It should be becoming clear that open sets do not include any 'boundary' points - from any point in the set, you can move some distance in M without going outside the set. As with open balls, if the set did include the boundary, it would be a closed set.

In any metric space M, the empty set Ø4 and the whole space M are open in M. Ø is open since it contains no points - so there is nowhere to centre our open ball. M is open since any open ball in M can only contain points of M.

In a discrete metric space, any set U is open in M. If x is in U, we can choose ε ≤ 1 to make certain that Bε(x) = {x} which is contained in U.

By the above, a closed interval [ab] is open in [ab], although (as we have already seen) it is not open in R.

Unions and Finite Intersections of Open Sets

The union of any collection of open sets in ametric space M is open in M. To prove this, let I be an indexing set, and suppose that Ui is open in M for every i in I. Let x be in the union of all the sets Ui. Then x must be in Uk for some k in I, and since Uk is open in M there exists ε > 0 such that Bε(x) is contained in Uk, which is in the union of the Ui as required.

If U1, U2,..., Um are open in a metric space M, then the intersection of these m sets is also open in M.

To prove this, let x be in the intersection of our m open sets. For each i = 1, 2,..., m we must have x in Ui and Ui is open in M, so there exists an εi > 0 such that Bεi(x) is contained in Ui.

Now let ε = Min{ε1, ε2,..., εm}. Then Bε(x) is contained in Bεi(x) which is itself contained in Ui for i = 1, 2,..., m, so Bε(x) is in the intersecion, as required.

Taking Things Further

This entry is only a brief introduction to the world of metric spaces. Other topics within this subject include the continuity and convergence of functions, the Hausdorff condition, compactness, connectedness and completeness. One excellent book on Metric Spaces is Introduction to Metric and Topological Spaces, by WA Sutherland.

1Also known as a metric.2That is, a function which takes two points from our set A, does something with them, and produces as a result a number in R, the set of real numbers.3This set consists of all points x satisfying a < x < b. The interval [ab] consists of all points x which satisfy a ≤ x ≤ b. Notice the use of different brackets to denote the exclusion/inclusion of the endpoints.4The set which contains no points.

Bookmark on your Personal Space

Conversations About This Entry

Edited Entry


Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Categorised In:

Edited by

h2g2 Editors

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more