Metric Spaces

Topology usually starts with the idea of a metric space. A metric space is a set of values with some concept of distance. We need to define that first, before we can get into anything really interesting.

Metric Spaces and Distance

What does distance mean?

Let’s look at a set, S, consisting of elements s1, s2, s3,…,sn. What does it mean to measure a distance from si to sj?

We’ll start by looking at a simple number-line, with the set of real numbers. What’s the distance between two numbers x and y? It’s a measure of how far over the number-line you have to go to get from x to y. But that’s really circular; we’ve defined distance as “how far you have to go”, which is defined by distance. Let’s try again. Take a blank ruler, and put it next to the numberline, so that the left edge of the ruler is on X, and then draw a mark on the ruler where it touches Y. The length of the ruler up to that mark is the distance from x to y. The reason that this one isn’t circular is because now, you can take that ruler, and use it to answer the question: is the number v farther from the number w than x is from y? Because the ruler gives you a *metric* that you can use *that is separate from* the number-line itself.


A metric over S is a function that takes two elements si and sj, and returns a *real number* which measure the distance between those two elements. To be a proper metric, it needs to have a set of required properties. To be formal, a function d : S × S → ℜ is a *metric function over S* if/f:

  1. ∀ si, sj ∈ S: d(si,sj) = 0 if/f i=j. (the identity property)
  2. ∀ si, sj ∈ S: d(si,sj) = d(sj,si) (the symmetry property)
  3. ∀ si, sj, sk ∈ S: d(si,sk) ≤ d(si,sj) + d(sj,sj) (the triangle inequality property)
    Some people also add a fourth property, called the non-negativity property; I prefer to leave it out, because it can be inferred from the others. But for completeness, here it is: ∀ si, sj ∈ S: d(si,sj) ≥ 0.
    A metric space is just the pair (S,d) of a set S, and a metric function d over the set.
    For example:
  4. The real numbers are a metric space with the ruler-metric function. You can easily verify that properties of a metric function all work with the ruler-metric. In fact, they are are all things that you can easily check with a ruler and a number-line, to see that they work. The function that you’re creating with the ruler is: d(x,y) = |x-y| (the absolute value of x – y). So the ruler-metric distance from 1 to 3 is 2.
  5. A cartesian plane is a metric space whose distance function is the euclidean distance:
    d((ax,ay), (bx,by)) = ((ax-bx)2 + (ay-by)2 )1/2.
  6. In fact, for every n, the euclidean n-space is a metric space using the euclidean distance.
  7. A checkerboard is a metric space if you use the number of kings moves as the distance function.
  8. The Manhattan street grid is a metric space where the distance function between two intersections is the sum of the number of horizontal blocks and the number of vertical blocks between them.

Open and Closed Sets in Metric Spaces

You can start moving from metric spaces to topological spaces by looking at open sets. Take a metric space, (S,d), and a point p∈S. An open ball B(p,r) (a ball of radius r around point p) in S is the set of points x such that d(p,x) 0, B(p,r)∩T≠∅. The closure of T (usually written as T with a horizontal line over it; sometimes written as T by computer scientists, because that’s the closure notation in many CS subjects). is the set of all points adherent to T. *(note: a typo was corrected in this paragraph. Thanks to the commenter who caught it!)
A subset T of S is called a closed subset if/f T=T. Intuitively, T is closed if it *contains the surface that forms its boundary. So in 3-space, a solid sphere is a closed space. The contents of the sphere (think of the shape formed by the air in a spherical balloon) is not a closed space; it’s bounded by a surface, but that surface is not part of the space.

0 thoughts on “Metric Spaces

  1. Canuckistani

    Typo watch:
    – the last term in property 3 of a metric reads d(sj,sj), but should read d(sj,sk)
    – the definition of the open ball didn’t use the strict inequality

  2. Xanthir

    Also, I assume that when you’re defining the adherent property, you meant to say “We can say that a point p is adherent to T if for all r > 0, B(p,r)∩T≠∅”. You didn’t define any set O, and T is the only part that makes sense anyway.
    You may want to expand that line a touch in any case, to really indicate what you’re trying to say. I knew what a closed set was, but I didn’t immediately get it from your definition. Basically, without my existing knowledge of sets that do/do not contain their own boundaries, I wouldn’t have understood the significance of the adherence property.

  3. Alon Levy

    The most intuitive definition of open and closed sets that I know is based on boundaries: an open set contains none of its boundary, while a closed set contains it all. It takes a bit of work to prove equivalence, though. If you define an open set using the usual metric definition, then I think the easiest way to define closed sets is as co-open sets.
    By the way, is it common to say that a point is adherent to T? Before reading this post, I’d only encountered the terms limit/accumulation/cluster point, i.e. a point is an accumulation point of T.

  4. elspi

    You shouldn’t use subscripts with the definition of metric
    $d(s_i,s_j)$ etc. The metric space is usually not countable. It’s cleaner without em anyway.
    For all $x,y,z in S$
    1. $d(x,x) =0$
    2. $d(x,y) =d(y,x)$
    3. $d(x,y)+d(y,z) ge d(x,z)$

  5. crf

    The arguments here are similar to ones in the first few pages of principles of mathematical analysis of Rudin.
    It’s a small book, and is popular as text book I think (at least, I used it at university not so long ago 😉 ). But I now see that it is very expensive at the online shops like amazon (115$), but still a very good deal on ebay (~5$ + shipping … ). Probably it would be at the public library as well.

  6. billb

    @ Mark: Just to reiterate Canuckistani’s point, you’ve described the closed ball not the open one. The open ball radius r at p in S is all points x such that d(p,x) i} if ∀ ε>0 ∃ N(ε) such that n > N ⇒ d(x,xn) < ε).

  7. billb

    Dagnabbit! Whenever you put in a less-than sign using html entities and do a preview, it actually converts everything in the text entry box into those entities, so the AMPERSAND-L-T-SEMICOLN gets literally replaced with a regular < which if you don’t convert back to AMPERSAND-L-T-SEMICOLN will screw up the markup everywhere.
    The last bit of my first paragraph should be “d(p,x) < r”.

  8. numerophile

    Andy: I would recommend “Topology” by James Munkres. It was used as a text in a point-set topology course I took last year and I found it to be quite good. (The second edition, published in 2000, has two parts; Part I is all you really need from that book. Part II is on algebraic topology, but it’s an incomplete treatment, and once you’ve made it that far, you’d be better served by a more advanced text.)
    Alon is right about Rudin’s books. His lower-level book, Principles of Mathematical Analysis, has a chapter on metric topology and that’s about it. His higher-level book, Real + Complex Analysis, defines a topological space and proves one relevant lemma (Urysohn’s), and that’s it.

  9. carey allen

    Rosenlicht’s book Introduction to Analysis is a very readable text, done using metric spaces, and costs a mere $10. I highly recommend it.

  10. Alon Levy

    Billb, I think you defined a cluster point wrongly. As it stands, you’ve defined the limit of a sequence. A cluster point of a sequence a(n) is a point x such that for every e > 0, there exists i such that d(x, a(i))

  11. Torbjörn Larsson

    “4. A checkerboard is a metric space if you use the number of kings moves as the distance function.”
    But a king moves one square in any direction. Since d((1,1),(2,1)) + d((2,1),(2,2)) – d((2,2),(1,1)) = 1 + 1 – 1 = 1 ≠ 0 = d((1,1),(1,1)), I can’t see how an ambigious d can be a metric function.
    “By the way, is it common to say that a point is adherent to T?”
    I’m with you and billb here, limit point it was. (IIRC, I haven’t that book handy.)

  12. Markk

    ” Since d((1,1),(2,1)) + d((2,1),(2,2)) – d((2,2),(1,1)) = 1 + 1 – 1 = 1 ≠ 0 = d((1,1),(1,1)), I can’t see how an ambigious d can be a metric function.”
    Ahh…I don’t get that. For Euclidean distance the fact that
    d(1,1),(2,1) + d(2,1)(2,2) – d(2,2)(1,1) isn’t 0 and not equal d(1,1)(1,1) is of course also true.

  13. Torbjörn Larsson

    Yes, of course, I initially saw that the king/checkerboard metric fulfilled the triangle inequality property. Indeed, I should have checked my calculation on the normal metric.
    It is of course a discrete metric, I see that now. Cute.

  14. Alon Levy

    It doesn’t have to be a discrete metric, Torbjörn. Just like the taxicab metric can be made continuous by letting d((x1, y1), (x2, y2)) = |x2 – x1| + |y2 – y1|, so you the checkerboard metric be made continuous by, intuitively, making the metric distance between two points the shortest total length of horizontal, vertical, and 45-degree-diagonal lines connecting them. More precisely, if you define m to be min{|x2 – x1|, |y2 – y1|} and M to be max{|x2 – x1|, |y2 – y1|}, then d = m*SQRT(2) + (M – m).

  15. Torbjörn Larsson

    Ummm, it awakes some distant memories, and again I wish I had my topology book handy. Of course you can transform the metric, but I can’t see that either of those two topologies gets continuous metrics unless the | | function makes some fancy moves when moving from one square to another.
    This example of discrete to non-discrete I get (and it seems strangely familiar): “On the other hand, the underlying topology of a non-discrete uniform or metric space can be discrete; an example is the metric space X := {1/n : n = 1,2,3,…} (with metric inherited from the real line and given by d(x,y) = |x − y|).” ( )
    We need a limit point, or more specifically a cluster point. 🙂

  16. Torbjörn Larsson

    “We need a limit point, or more specifically a cluster point.”
    Duh! We need a limit point, but here it is a cluster point.

  17. Romulo

    Sorry about being late to this thread. Just a comment about indexing: one does not have to index over a countable set. Actually, the “main” purpose of indexing is not served if one indexes over the countable Q.


Leave a Reply