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

Transcript

in this lecture we are going to define the  notion of a metric space. In real analysis,   a metric space is kind of like the broadest,  most inclusive type of domain that we work on   because it doesn't take much to have a metric  space, as you will see over the course of this   lesson. So what does it take to have a metric  space? You need a set M of elements. It could   be real numbers, it could be complex numbers,  but it could also be like markers in the room, as we will actually use in an example. So  you need a set M, and you need a function   D which measures distance between elements.  So that's why I'm saying here that D is a   real-valued function of two inputs because  you plug in the two inputs, and you get out   the real-valued notion of distance. Okay, so you  have a metric space if you have these two things:   a set and a distance, so that the distance  satisfies four very natural properties. The first one is positivity.

It's very strange to tell distance with negative  numbers, right? So the distance from me to the   camera is not -3 meters, it's like about 3 meters.  So D of X comma Y is greater than or equal to   zero for all X and Y in the metric space. I'll  leave off writing that distance could be zero,   but when is it zero? If and only if you're  measuring the distance from an element to   itself. We call that non-degeneracy. So  that means that D of X comma Y is zero

if and only if X and Y are the same. We call that  non-degeneracy because this word indicates that D   distinguishes between distinct objects. So if  it kind of like couldn't tell the difference   between two different objects X and Y,  kind of collapses them onto each other,   and said their distance was zero, that would be  a degenerate function. So here we're saying that   it separates different elements, you  can tell the difference between them.

The next one is symmetry, right? So the  distance from the green marker to the   orange marker is the same as the distance  from the orange marker to the green marker.   Straightforward, right? So it's  a natural property. Symmetry. And then the last property is that detours  make your journey longer. So if I want to go   from the green marker to the orange marker,  it would be a detour if I went and visited

a different marker along the way. I'm trying  to say the triangle inequality. I'll give you   a more mathematical illustration of it in just  a second. So the triangle inequality is that   the distance from X to Y is less than or equal to  going through a different element Z. So it's less   than or equal to the distance from X to Z plus  the distance from Z to Y. If I imagine that X,   Y, and Z are points in R^2, so imagine the board  here is just Euclidean two-dimensional space,

say here's X and here's Y. This straight  line in Euclidean space is an illustration   of their distance, so the length of this  line is the distance from X to Y. If I   go through any other point—supposed to be a  straight line segment, so is this one—okay,   you get the idea. It's the triangle inequality  because the distance from X to Y in Euclidean   space—that's the length of this line segment—is  less than or equal to the length of this segment plus that one. So that's the triangle  inequality. Okay, it looks like a triangle. Alright, this is an illustration of one of  these properties in two-dimensional space,   but what I would like to do now is look at a  totally different metric space which you may have   never worked in before. I said it's not too hard  to have a metric space, the requirements are not   that difficult to satisfy. So here's an example.  Let M be the set of markers in the room. That's

actually these five markers. And let D be what's  called the discrete metric. So this is a metric   that I will refer to when we work in metric spaces  pretty often. So if you're following my lessons,   please keep this in mind. This is our first  introduction to it. The discrete metric is   defined as D of any X and Y from the set M is zero  if they are the same element, otherwise it's one.   So it's either zero or one. D of orange marker,  comma orange marker is zero. D of orange marker,

comma green marker is one. The distance between  these elements is still one, it's still one,   it's still one, it's always one. So this is our  notion of distance between distinct elements. Let's verify that this is a metric space. Well,  to be a metric space, you have to have a set of   elements, we have that, so M is ready to  go. We need to check that the function D   here satisfies the four required properties.  I think the first three I can do out loud, you may want to write them down, but we can probably  go through those out loud, and then I will write   down a quick sketch—or actually, I'll probably  do the full proof for the triangle inequality. Okay, the first property we need to check is  positivity. This function only has two possible   outputs, zero and one, neither is negative, so by  construction we have positivity for this function.   Also by construction we have non-degeneracy, so  if two elements are the same, their distance is

zero. On the other hand, if their distance  is zero, they must be the same. Don't forget   non-degeneracy is an if and only if statement, but  again, this function is basically set up to match   non-degeneracy. Same thing with symmetry, so D  of X comma Y is going to be the same as D of Y   comma X. If they're the same, both of those values  will be zero. If they're different, both of those   values will be one. Okay, so the first three are  pretty much automatic, we can do them out loud.

Almost always, when the triangle inequality is  one of the properties of a function like this one,   it's worth taking a little bit more time to  treat it carefully. So let me pause in case   you are still thinking about this metric, and  go ahead and write down the triangle inequality.   Think about the kinds of values that you would  encounter on the left and right-hand sides of   the triangle inequality, and then I will come  back and actually write out a little proof. Alright, if you write down the triangle  inequality, this is what you should have. I'll   go ahead and start the formal proof. So I'll say  we want to show that for any X, Y, and Z in the   metric space or in the set M, because we don't yet  know it's a metric space, the distance from X to   Y is less than or equal to the distance from X to  Z plus the distance from Z to Y. If I was writing   this on paper, I might put this centered on its  own line, but I don't have too much space to

work with here. For this particular metric, let's  consider the values that are possible on both the   left and right-hand sides of this inequality. On  the left-hand side, either zero or one, that comes   straight from the definition. On the right-hand  side, we could be looking at 0+0, we could be   looking at 0+1, or similarly 1+0, or we could  be looking at 1+1. Okay, so 0, 1, 0, 1, or 2. I typically prefer direct proofs, and I think if  I were actually writing this up and not hoping to

do the fastest proof possible because I'm running  out of board space, I would probably write this   up directly, but I'm going to do a proof by  contradiction because it might be the fastest   route. Suppose the—maybe I should say what the  values are for the reader, and then I'll go into   the contradiction. So notice the left-hand side—so  abbreviation left-hand side—is either zero or one,   while the right-hand side is either zero,  one, or two. The only way that the triangle

inequality could fail is if the left-hand side  is strictly bigger than the right-hand side.   So if the left-hand side is zero, we're done.  If it's one and the right-hand side is zero,   that's the only way the triangle inequality  could fail here for the sake of contradiction.   So for the sake of contradiction, suppose Dxy  is one, but dxz plus dzy is zero. You probably   see what's going on now. Now, if the right-hand  side is zero, we must have added 0+0. That's the

only way we could get 0 out of this sum.  But that means x equals z and z equals y,   which means x equals y by transitivity. But  then that means the left-hand side is zero. This latter implies x equals z and  z equals y, but then x equals y.   This would produce—the left-hand side is  zero. So let me say this implies—alright,

so this implies the distance between x and y is in  fact zero, because they really should be the same   element. But then that contradicts this statement  here. So this is my symbol for contradiction,   and I just kind of quickly wrapped up this  proof. You could write this maybe avoiding the   contradiction language. I just kind of did this  right on the spot. You also could write it without contradiction, just kind of show that the triangle  inequality must be satisfied directly. But I think   this is a nice little argument to recognize  for this particular metric that the triangle   inequality can only fail in one particular  situation which literally cannot happen. Alright, I'll give you a minute to finish  writing this down or if you'd like to   tackle it a little bit differently,  you can do so. When I come back,

we will talk a bit about what geometry  might look like in this metric space. The exercise I would like for us to complete now  is to describe circles in this discrete metric   space. So first, what is a circle? If we just  think back to the classic circle that you would draw on paper in the XY plane, a circle is a set  of points which are the same distance from a fixed   center point. So we can characterize circles in  terms of a distance from like an anchor point, the

center point. Okay, so what would a distance look  like in this discrete metric space? Well, we only   really have two distances, zero and one, which  are realized between objects in this setting.   So here's my metric space. It's these markers  together with the discrete metric. I need a center   point. Let's make it this pink marker, P. Okay,  can you think for a moment what is the unit circle   centered around P? So if I want to draw the unit  circle around P, what would that look like? Are

you ready? It would be all of the other markers.  So every other marker in this discrete metric   space is distance one from P. So these markers  form the unit circle around P. These markers—I   just switched out pink for orange—these markers  form the unit circle around this orange marker. Okay, what about the circle around the orange  marker of radius two? What does that look like?   That is the empty set. No markers at all are  distance two from this orange marker. So there

is nothing in the circle. The circle consists  of no elements from this discrete metric space.   Same thing for the circle of radius two. If  I wanted like the solid disc of radius one,   so all of the markers in the metric space whose  distance from this central orange marker is less   than or equal to one, what would that look like?  It would be all of them, right? So all of the   markers in the metric space have a distance less  than or equal to one for this orange marker. Okay, so I just wanted to kind of lift that up for you  as an illustration of how geometry can change when   you move from one metric space to another. So our  notion of circles in Euclidean space, it's like   we have circle radius one, circle radius two,  solid disc of radius one in the plane does not   contain all of the plane, but when we look at this  particular metric space, it looks very different. Okay, let's also look at another example, and  then we will wrap up with an important result.

For another example of a metric space you may  not have seen before, let M be the XY plane.   So in other words, elements in M are points  X comma Y. And let our notion of distance be   what we call the taxi cab metric or the Manhattan  distance between two points. So it's defined this   way. What we will do now is just a quick check  that we understand how to read this function.   We will verify that it has the four properties  of a metric so that we can call this a metric space. Then I just want to take a quick moment  to sketch a circle in this new metric space. Okay, so how does this work? Suppose  I take the point -3,1 down here in the   third quadrant—that would be like  U1 comma U2 in my definition—and I   want to measure its taxi cab distance to the  point 2,3 right here—that's the point V1 V2.

What is the taxi cab distance between these two  points? So if I do the distance between -3,1 and   2,3, that's going to be the absolute value of  the difference in their x coordinates -3 minus   2. Take the absolute value of that, add to that  the absolute value of the difference in their y   coordinates. So -1 minus 3. Alright, so we get  5 + 4 is 9. Alright, so the distance—we want to   call it a distance, we still have to verify the  four properties—but let me use that already. The

distance between these two points with the taxi  cab metric is 9. That is not the same as the   length of the straight line connecting them. That  would be the Euclidean distance, that's not what   we're looking at here. Instead, what we're saying  is that the distance between these two points is   the horizontal distance that's being measured by  this absolute value of one x coordinate minus the other. That horizontal distance plus the vertical  distance, so that's being measured as the distance   between their y components. This is called taxi  cab distance because if you think about it,   imagine this was a city grid like Manhattan and  you had kind of north-south running streets,   east-west running streets, and maybe these  blocks here are like apartment buildings and   hospitals and schools and things like that. If  you were a taxi driver navigating the city and

you wanted to figure out some idea of how far  this point is from this one, it doesn't really   make sense to imagine going from one to the other  in a straight line because that's not how you can   get there. So you can't cut through buildings,  you have to go along city streets. So this   taxi cab distance is measuring how many blocks  the taxi would drive down in order to get from   one point to the other. So 5 here is like  5 blocks to the east plus 4 blocks to the

north. That's a more natural way to think about  a trajectory in the city compared with how, say,   a bird might fly from one roof to another. Okay,  so that's why it's called the taxi cab distance. Take a moment and if you don't do anything else,  just say the names of the four properties out   loud and kind of assess which ones are immediate,  which ones do you think I'm going to write down.   I will come back and we will talk through them  and we'll do a little bit more with this metric.

The four properties that we need to check are  positivity, non-degeneracy, symmetry, and the   triangle inequality. Let's think about each one  visually first, and then we will write probably   every single one down just to have a complete  argument. Positivity seems very immediate, right?   So no way that if I'm telling you how many blocks  I'm going to drive to get from one location in the   city to another, there's no way I'm going to say  -4 blocks, and that's going to agree with the way this function is defined. Non-degeneracy, if I  want to go from one intersection back to itself,   like what's the distance between one point in  the city and itself is zero. On the other hand,   if I say that the distance from another point to  this one is zero, is it clear that I'm looking at   comparing the same point to itself? Is this metric  non-degenerate is what I'm trying to say? Yes,

that's also going to be true. Sorry, it's kind of  an awkward if and only if thing to phrase in this   context. Symmetry: is the distance from here to  here the same as the distance from here to here?   That is actually true for this function, but if  you think about it, it's not necessarily true in   a real city because you might have something like  a one-way street, right? So in the place where I live, if I want to drive from the north side of  town to the south side, I actually have kind of   a different trajectory based on traffic and sort  of unusual traffic patterns through the center of   town. But for this function and this idealized  city, symmetry will hold. Triangle inequality:   you know, if I want to get from this point to  this one, the most direct thing I can do is   travel only east and north the right amount  of blocks. If I take any kind of detour,

like I go south or I go west, I'm going to add  on to the length of my journey. That would be   the triangle inequality for the city. Let's work  through all of those statements now algebraically. Positivity doesn't quite feel like it's worth  writing down, but let me say something. Since   the absolute value of A minus B is  greater than or equal to zero for   all real numbers A and B, in particular pairs  of x coordinates and pairs of y coordinates, the distance between the point U1 U2 and the  point V1 V2 is made up of the sum of those   two. So it's greater than or equal to zero,  and I'm just going to write by construction.

So that means it follows right out of the  definition with very little analysis necessary. Non-degeneracy, which I did not  describe very well a minute ago,   is an if and only if statement. Let's see if we  can write it more clearly than I said it out loud.   Notice the distance from any point—I'm going  to describe it as this vector U—back to itself is the absolute value of U1 minus U1 plus U2 minus  U2, the absolute value of that—sorry, that should   be a minus—which is zero, zero plus zero, which  is zero. That's one direction of non-degeneracy. For the other direction, conversely,

suppose that the distance from U  to V was zero. How could we get   zero from adding together two absolute value  expressions? Both would have to be zero. Oh,   this marker is worse. Let's see. A little bit  better. Then the absolute value of U1 minus V1   equals zero, and also the absolute value of  U2 minus V2 is zero, which implies that U1 U2,   that point, equals V1 V2. Okay, what I really want  to highlight here by writing out non-degeneracy is

that it's if and only if, and you need to address  both directions. Okay, let me step aside just   so I can erase this. Then we will continue  with symmetry and the triangle inequality. Alright, for symmetry, we can write that  the distance from V to U is the absolute   value of V1 minus U1 plus the absolute  value of V2 minus U2, but we have symmetry   inside the absolute values. So that's the same  thing as the absolute value of U1 minus V1 plus

the absolute value of U2 minus V2, which is the  definition of the distance from U to V. Okay,   so symmetry is going to check out. And I think  I can squeeze the triangle inequality on here. Let's compare U to V but take a detour  through W, so that will have coordinates W1 W 2. So the distance from U to V is equal  to this. I'm going to run out of room,   so instead of rewriting this again, which  is in the definition of the function,

let me go ahead and bring in the coordinates of  W. You'll see what I mean. So I'm going to say   it's U1 minus V1, but let me bring in—before  I write minus V1, let me write minus W1 plus   W1 so that I haven't changed anything,  and then take off V1. And then likewise,   we'll write U2 minus the y component of  this other point. So minus W2 plus W2,   so it's like adding a fancy version of the  number zero, and then minus V2 like that.

The absolute value function, which is actually  the Euclidean metric on the real number line,   this has a triangle inequality in its own right.  So I can break each of these up and say that this   is less than or equal to the absolute value of U1  minus W1 plus the absolute value of W1 minus V1,   plus here it's going to be the same  idea, absolute value of U2 minus W2

plus the absolute value of W2 minus V2, which  I should have written here. My apologies,   probably you saw that when I wrote it. There  we go. And if you wanted to, you could bring   in another line where you kind of reorder these  terms so that this is next to that and this is   next to that. But what we have here is the  distance from U to W. I'm really struggling   with markers right now, I apologize. But these  two together are the distance from U to W,

and these two together are the distance from W  to V. Okay, that wraps up the four criteria that   we need to check to verify that the taxi cab  metric is indeed a proper metric. So R2 with   this notion of distance is a metric space. Take a  moment, finish this, and then I just want to talk   through some visual implications here before  we move on to a little result with a proof. Alright, let's make a few visual observations  about this metric space. The first thing I want

to point out is something you may have realized  when I was talking about why this is called the   taxi cab metric, and that is that there is not  a unique path from two different points in the   city unless they are on the same street. So as  long as I have to make at least one turn, I might   have multiple ways to get from, say, this point to  this one. So what we could do is drive five blocks   to the east and drive four blocks north, or we  could drive four blocks north, five blocks east, or we could kind of mix and match some  east, some north, that sort of thing, as   long as we are always moving in the right sense of  direction. That's different than R2 equipped with   the Euclidean metric. If I had these two points  in Euclidean space, there is only one shortest   path between them. So we have more variety here  on what you might think of as the shortest path. Another geometric discussion worth having  is what circles would look like in this

metric space. Let's draw the circle  of radius two centered at the origin.   So we'll just make this a circle around the origin  in R2 of radius two. Okay, so how could we do   that? First, let's stick with this idea that we're  working with a city. I could go two blocks east,   I could go one block east, one block north, two  blocks north, one block west, one block north,   west, you know, southwest, south, southeast.  Okay, in a city, those are all of the points

in the metric space which would be distance two  from the origin. But that's not actually really   what we have here. We have R2, so I would like  to be able to actually travel fractional amounts,   if you will, or really any amount. So could I  go like 1.5, 0.5? Okay, or 0.5, 1.5? Basically,   take away the story behind this metric, which  we were looking at a city grid. We're not really   looking at a city grid. What we have here is the  plane. U1, U2, V1, V2, they don't have to be whole

numbers. That's really what I was trying to say.  So we can go any amount up to two blocks east,   pair with that some amount north, and fill in this  whole straight line segment here. Likewise here,   here, and here to conclude that the circle  of radius two centered at the origin takes   a diamond shape. Okay, so we saw that  circles looked a little different in a   discrete metric space. Here with this taxi  cab metric, our circles look like diamonds.

Alright, that's the end of our  examples. I want to wrap up,   though, with an important result  connecting norms to metrics. In this last part of the lecture, I want to  show you that if you are working in a normed   vector space V, there's a function that you  write down which is automatically a metric.   So we will call that D for metric, and we'll say  that this metric is the norm of V minus W. So this is a metric defined in terms of the norm that we  are getting from the normed vector space. We are   going to prove that this metric has the four  properties. Here I haven't specified what the   norm and the vector space are, which means that  if you are working in any kind of normed vector   space and you work with the metric, you know  it's a metric. You don't need to prove the four   properties because we're going to prove them  in the most general sense. Before I do that,

let me just make a couple quick remarks. When  we looked at these kinds of computations on   Euclidean space, so our norm was like Euclidean  magnitude of vectors, and our notion of distance,   like the distance formula, we could actually  characterize in this way. That was an analogous   result to this one. Similarly, when we talked  about norms, we had a result that said that if   you are working in a real inner product space,  from that inner product you can define a norm. That's also an analogous result. So inner products  induce norms, norms induce metrics. We are going   to do the second part of that statement  now and prove that this norm induces this   metric. It's just a question of checking the  four properties. All you need to be a metric   space is the set and the metric. The set here  is the set of vectors in V, so we get the set   from the fact that we're working in this vector  space V. The four properties we need to verify—

As we go through each of these properties,  pay attention to how they come so quickly   because we know we are working with a  valid norm. So when I say valid norm,   I mean that this norm has all the properties  of a norm that we already covered. For example, notice the distance  between any vectors V and W,   which is just to kind of restate it, defined  as the norm of V minus W, is greater than or   equal to zero because we already know that  the norm is never negative. So let me write, because the norm function has positivity. That was  also the first property that we named for norms.

Okay, let's look at non-degeneracy. I think we  can do this as one kind of if-and-only-if chain.   I don't think I need to make two arguments to  cover the two directions of the if-and-only-if   statement. So I used notice here, let me switch  to observe. Observe the distance between V and   W equals zero if and only if—so this is like the  first link in my if-and-only-if chain—if and only   if—well, this equals zero. Just going to kind of  restate how this metric is defined. But norms are

non-degenerate, so if the norm of something is  zero, then what you took the norm of had to be   the origin in the vector space. So let me say that  this is true if and only if this quantity in here   is, and I'll write zero vector here to distinguish  it from scalar zero. So this is like the zero   in the vector space, this is just distance zero,  they can look different. We're working in a vector   space where we have vector addition, additive  inverses, things like that, so I can just add W

to both sides and that addition works. If and only  if, because it's well-defined addition, so if I   swing W over to the right-hand side, we get equal  W, and that concludes our if-and-only-if chain. Alright, just going to write it off to the side  here. We have, like, this is non-degenerate. Okay,   that's not part of the formal proof,  that's kind of a note to myself. Okay,   so positivity of the metric was inherited  from the positivity of the norm. Similarly,

non-degeneracy of the metric was inherited  from the non-degeneracy of the norm. That's   really what it means to say that the norm  is inducing the metric. But we have two   more properties to check, and I think  I would like a little bit more room,   so let me erase this and come back and do  symmetry and also the triangle inequality. Alright, the reason why I wanted to  give myself more room for symmetry, which might feel like it's going to be a fast  computation, is because the third property of   norms is not symmetry, it's multiplicativity.  So what I want to do is the full computation   to show that symmetry holds for this proposed  metric, because each step really relies on the   fact that we are working in a normed vector  space. So I don't want to rush through this. We have that—let me just start here—the distance  from W to V. I want to show that's the same thing

as the distance from V to W to establish  symmetry. By definition, this is the norm   of the difference W minus V. Yes, I do just want  to flip these, but again, I want to show why I'm able to do that, and it's going  to rely on the fact that vector   addition is nice in the vector space  and the norm has multiplicativity. Okay, what I'm going to do is take this expression  and rewrite it with a negative 1 kind of factored

out front. That's the scalar multiplication in  the vector space. So let me write -1 * W + V,   and that's just relying on the fact that scalar  multiplication works well in a vector space. Now   I can use multiplicativity of the norm to bring  this negative one in front and take its absolute   value. Okay, so that's multiplicativity  of the norm. And then here, what I'm   left with is -W + V. I'm going to use  commutativity of vector addition in the

vector space to rewrite that as V minus  W. Absolute value of negative 1 is one,   so we get V minus W. But then, of course,  that is the distance from V back to W. Alright, so again, it's tempting  to go straight from here to here,   but I think to make it clear why that's  allowed, you want to do this procedure   in here where you highlight things like scalar  multiplicativity in a vector space works well,   vector addition in the vector space is  commutative, the norm has multiplicativity,

that's where we're really getting the  property. So my ability to bring this negative   one in front right here is following  from the multiplicativity of the norm. Okay, so essentially what we've done is prove  that you can do what feels like you should be   able to do. So you can swap the order  in here because we've proved that that   construction works. Okay, let's resume this  in a moment with the triangle inequality. Alright, the triangle inequality  is actually fast because we're

working with a norm that has the  triangle inequality. So lastly,   notice that the distance from V to W is going to  be here. I'm going to bring in U. So how about V   minus U plus U minus W? The norm has the  triangle inequality. That was the fourth   property that we covered for norms. So this is  less than or equal to V minus U plus U minus W.   But now that is the distance from V to U plus  the distance from U to W. And that wraps it up.

So I hope you enjoyed seeing how the  four properties of a metric followed   from the four properties of the norm.  So positivity followed from positivity,   non-degeneracy from non-degeneracy, symmetry  from multiplicativity, and then here we have   the triangle inequality for the metric follows  from the triangle inequality for the norm.   Summarizing across a few different lectures, we  can say the inner product induces a norm and a norm induces a metric. But don't try to go the  other direction. For example, we take the metric   space that we introduced earlier, which consists  of my markers with the discrete metric. This is a   metric space with the discrete metric, but I'm not  going to be able to induce a norm here. This is   not going to form a normed vector space. I don't  have an origin, I don't have vector addition,   I don't have scalar multiplication—struggling  to say that word. It's not going to be a vector

space. I'm also not going to get an inner product  here. So the implication there matters: inner   product induces norm, norm induces metric. The  other remark I want to make before we wrap this up   is that while I'm saying that on a normed vector  space, this is a valid metric, you don't need to   check the four properties. If you have this, you  know it's a metric. It's not the only metric, so it's not like this is a unique choice to have  a metric. In particular, on a normed vector space,   I could work with the discrete metric. That  would also be a valid choice of a metric.   So we're just saying that this is one particular  metric that works. This is the induced metric. Alright, that wraps up this lesson on  metric spaces. Thank you for your attention.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent