This article is meant to be an intuitive introduction to metric spaces. We aim to motivate the concept of a metric space and some fundamental theorems about them, and have as much fun as we can along the way.
To begin, let me ask you a question: What is the distance between sine and cosine? I can hear you thinking, “What does that mean?” Which is a good question! What does it mean? When I hear this question, I think of taking their difference but of course, at different values their difference is different! However, if you wanted to give one number as the answer what might you say?

Keep this question in mind as we begin our discussion of metric spaces. I think it’s a great one! P.S. There is more than one possible answer!
The key takeaways of this article are, hopefully, (1) you’ll have an intuition for the axioms of a metric space so that way you no longer need to memorize them since you’ll simply understand them, (2) you’ll have a few examples of usefull and common metric spaces, (3) you’ll understand what open sets and closed sets are along with some understanding of how to work with them.
Table of Contents
- Motivation – What is distance?
- Open Sets
- Closed Sets
- Intersections and Unions of Open and Closed Sets
- Final Remarks
Motivation – What is distance?
Here’s the deal: a metric space is a set with `added structure’.1 In our case, the added structure is the notion of distance between points. So, given a set, we can calculate the distance between and and denote it
More precisely and more mathematically, a metric space is a pair where is a set with a function that we can think of as taking in pairs of elements from and outputting a real number that equals the distance between But, in order for to be considered a distance function, it must satisfy certain axioms or rules.
Which begs the question: What properties should satisfy to be a bona fide distance function? Let’s try to make a list of properties that we think are crucial to include as axioms! However, I recommend you try this first on your own! You don’t need to get the ‘correct’ answer; you just need to engage your brain with the material! Plus, it might be fun! You’ll be inventing new mathematics! As motivation, think about the properties that distance in and satisfy in everyday life.
Some properties of distance
(1) Well, right off the bat, the distance between distinct points should be positive, i.e., it should be that for all distinct points
(2) The distance between and itself should be zero. Moreover, the distance between and equals zero if and only if they are the same point:
(3) Next, how should the distance from and compare to the distance from to We’d like them to be equal: for all
(4) There is one more property that we’d like our distance function to satisfy. It’s perhaps the least intuitive axiom, at first at least. We want to capture what is called the triangle inequality. Here’s the idea: imagine starting a journey at point and ending at a point We know, intuitively, that it’s a shorter distance to go directly from to In particular, stopping at any other point along the way will only increase the distance we travel to reach point

This is captured in the previous image and by the following expression:
Using the standard letters we will use throughout the article: and
As it turns out, mathematicians think that these four points are the most crucial aspects of a distance function. We require nothing more out of
Altogether, we have argued for the following definition of a metric space.
Definition 1 (Metric Space): Let be a set and be a map. We call a metric space if satisfies the following axioms,
- (Non-Negative) for all
- (Zero iff Same Point)
- (Symmetric) for all and
- (Triangle Inequality) for all
We call the map a metric if conditions (1.)-(4.) are satisfied.
Of course, with any new definition, we should see a few examples. Cool!
Example The Euclidean Metric: (Click in the Discovery)
Let’s begin with the real line Intuitively, you might suggest that the distance between, say, and should be equal to so that . Or, that the distance between and should be equal to so that Indeed, this is the intuition for the metric where the E stands for Euclidean. We can see that (1), (2), and (3) in Definition 1 are satisfied immediately; however, (4) is trickier. But if you’ve taken real analysis, then you’ll know that for all If not, see here.
We can continue to the plane The metric we choose here is the one you are likely familiar with. It’s based on the Pythagorean theorem, which is funny when you think about it. We call the statement the Pythagorean theorem because it’s a theorem. We needed to establish it with proof, but now we are taking it as an axiom! How cool! Anyway, I digress…
Going back to defining the metric, let and be two points in the plane. Note that we are using angled brackets to denote a vector so that we don’t confuse a vector in and an open interval in Then, we define the metric by,
We can see again that (1), (2), and (3) are satisfied, and, as will be the case most of the time, it’s more challenging to see if this notion of distance satisfies the triangle inequality. I challenge you to show that it does. However, for our purposes, we will be satisfied to say that this is a geometric fact.

The two metrics are called the Euclidean metrics on and We can further generalize using the Pythagorean theorem as motivation to With and we define the following metric,
Example The Manhattan Metric: (Click in the Discovery)
Consider the plane There are other metrics we can define on the plane besides the Euclidean metric. For instance, imagine if we could only move left/right and up/down. That is, we cannot move diagonally. It’s as if we are forced to move along city streets in a city grid. Then, the distance between two points would be calculated using the following metric. For and we have

This is indeed a metric. We can see again that (1), (2), and (3) are satisfied in Definition 1, and the fact that the triangle inequality is satisfied follows from the standard triangle inequality for absolute values
We can also generalize this metric to More precisely, let and we define the following metric,
Example The Infinity Metric: (Click in the Discovery)
This is the last metric we will put on
First, consider the plane In this case, given two points and we first determine how separated and are along the -axis, that is, we calculate Then, we determine how separated along the -axis and are, that is, we calculate Then, we simply take the maximum of the two computations to be the distance,
We can see yet again that (1), (2), and (3) are satisfied. However, again, it’s a little more challenging to see if this notion of distance satisfies the triangle inequality. Here’s the idea: Let and Then,
Likewise, Consequently, This is our desired result
We can further generalize to Let and we define the following metric,
The previous three metric spaces are all on the same set, However, the utility of metric spaces is that we can also consider other sets that may be less intuitive. In this next example, we will give one possible answer to the question we asked at the beginning.
Example : (Click in the Discovery)
Recall the question: What is the distance between sine and cosine? Well, it’s time to answer! For most practical purposes, we will consider the distance between functions on a closed, bounded interval. In this case, the distance between sine and cosine over the closed unit interval Thus, we are now asking: What is the distance between the sine function and the cosine function over the interval ? We will change the period of sine and cosine and consider and
You might have come up with something like the following: Maybe we should fix some special and look at the difference However, how would we choose the particular value? However, this is not a great choice since if we happened to chose then so that their distance is zero, which contradicts point (2).
Ok, new plan… maybe we choose the value that maximizes the difference between them. That is, we say that the distance between and equals (see the footnote for a reminder on what the supremum is)2 Indeed, this is one way we can choose to define the distance between sine and cosine. In fact, we can use this to define the distance between any two continuous functions on the closed unit interval!
Let’s see how.
The pair is a metric space where, is the set of continuous functions and is the metric given by
Let’s show that this is indeed a metric. I leave it to you to prove that satisfies (1), (2). and (3); we will show that 𝑑 satisfies the triangle inequality below. But try it on your own first!
Proof: Let be continuous functions. We aim to show that First, note that is a continuous function on which is a closed and bounded interval. Thus, by the extreme value theorem, there is some so that attains its maximum (or supremum). More preicely, for all Thus,
by the triangle inequality on absolute values. However, and are also continuous on a closed and bounded interval. It follows by the extreme value theorem that and for Consequently, Hence,
Thus concluding the proof.
Now we can give an answer to our starting question: The distance between sine and cosine on equals 3
There is one last metric that we want to mention. Before we do, you might ask, “Given any set can we upgrade it to a metric space?” The answer is affirmative and is given by the so-called trivial metric, which exists for all sets.
Example (The Trivial Metric): (Click in the Discovery)
Let be any set. We define the following metric,
Again, satisfies all the axioms of a metric space. Although proving the triangle inequality case by case is tedious.
Open Sets
Recall that open intervals in are of the form for and that closed intervals in are of the form for What differentiates these two sets from one another? This is a loaded question with no obvious correct answer. It turns out that the key feature that we want to hone in on is the fact that any point has another smaller open interval centered at that is contained in That is, for any there exists some such that For instance, consider the open unit interval and the point We see that However, in a non-open interval, such as or the endpoint doesn’t have this property. This is because is not contained in for any
Thus, we call an open interval because no matter what we can always find a small enough such that
We take this property and raise it to general metric spaces. However, let’s first define an open ball and a closed ball. These are the generalizations of the two intervals: and But we will replace with because we will think of it as a radius.
Definition 2 (Open and Closed Balls): Let be a metric space and let and We define an open ball in to be the set
Next, we define the closed ball to be the set,
In both cases, we call the center of the ball and the radius.
Remark 1: In an open ball has the form and a closed ball has the form
Remark 2: Note that simply contains all the points that are within a distance from Similarly, contains all the points that are at most a distance of from
Now that we have this out of the way, we define an open set.
Definition 3 (Open Set): Let be a metric space. We call a subset an open set in if, for all there exists some radius such that
That is, every point in can be surrounded by a small open ball contained in
Challenge: Show that open balls are open sets.
Proof: (Click in the Discovery)
Scratch Work: Consider the metric space in blue below. The green disk is the open ball Our goal is to show that is an open set in This means that for all we must find some radius so that

How might we go about this? Well, to show we need to show that implies That is, implies that To the rescue, the triangle inequality gives us But since we want we let Note that since the t
Take a moment to work out the geometry here.
Proof: Let We claim that Indeed, let and observe that
Thus,
Important Remark: Note that and are both open sets in any metric space The reason why is open is that for any and we have As for being open, note that the statement: for all there exists some such that is true. This is because there are no to prove it wrong! Thus, it is vacuously true. Vacuously, in this case, means there are no to disprove the statement. Take a moment to appreciate this strangeness!
A challenge left for you is to show that and are open sets in
What is in the metric space
First, note that is the ball centered at the origin of the plane with radius equal to This will be the case for the next few examples.
With the Euclidean metric, we are interested in finding all the points that are within a distance of of the origin. Give this a go!
Solution: (Click in the Discovery)
As you might have guessed, it’s a circle since is given by the Pythagorean theorem.

What is in the metric space
Solution: (Click in the Discovery)
Recall that is given by the equation,
Which for us with gives, the equation, using the standard variables,

How strange, an open ball is a square!
What is in the metric space
Solution: (Click in the Discovery)
Since is given by,
We are looking for all the points whose coordinate values, are less than 1 in absolute value.

How strange, an open ball is a square! (Again!)
What are some open sets in the metric space
Now that we have seen some open sets and open balls, let’s ask a trickier question. What are some open sets in the metric space This is trickier because we now want an open set And, is itself a subset We will see why this makes some things seem strange.
First, let me say that we’re abusing notation a little here when we write So, to avoid needless confusion, the set we are considering is the closed unit interval and the metric is the absolute value for all
There are some obvious open sets in such as However, we claim that is also an open set in our metric space, even if it doesn’t look like it. See if you can see why!
For to be an open set, we need to show that every point has an open ball that is centered at and lies completely inside Of course, the trouble point in the interval is So we focus on 0. Consider the open ball By definition,
Well, the only points with are those contained in
But this set is contained in the set That is,
The reason we have square brackets around zero is, first, because and, second, because there are no other points less than zero in our metric space’s set Thus, we see that open sets don’t need to look open at first.
See if you can argue why and are open sets in as well!
Remark: This is a little taste of what are called subspaces and relative openness. However, we will wait to cover this in more detail in another article.
Closed Sets
We have yet to mention what a closed set is, although we did mention what a closed ball is. So, we might think that we will define a closed set using closed balls. However, this is not the case! We define them in terms of their complement.
Definition (Closed Set): Let be a metric space. We call a subset a closed set in if its complement is an open set.
Recall that the complement of a set is everything that is not in the set, i.e.
Remark: Note this shows why is a closed interval. It’s because is open!
Challenge: Show that closed balls are closed sets.
Proof: (Click in the Discovery)
Scratch: We aim to show that is a closed set. We do this by showing that is an open set. Recall, to show that we must show that for every point there is some such that

To show we want to show that implies That is,
Well, using the triangle inequality, we want to have greater than something. This means that we want to look at the distance between and or and this is because we will have something like which has on the correct side of the inequality. In particular, we consider
Which gives and since we want we claim letting works. We leave it to you to write out the formal proof! You’re welcome!
Intersections and Unions of Open and Closed Sets
We have two goals left for this article, and they concern taking the union and intersection of open sets and the union and intersection of closed sets. These might seem like strange things to want to consider; however, when we eventually look at the axioms of a topological space, we will see these results come into play.
Arbitrary Unions/Intersections of Open Sets
The goal is to answer the following questions:
- Is the arbitrary union of open sets an open set?
- Is the arbitrary intersection of open sets an open set?
Take a moment to think about these questions and make a guess!
The answer to 1 is yes and 2 is no. We will demonstrate these both in a few moments; however, let’s ask something weaker than question 2. Is finite intersections of open sets open? As it turns out, yes, yes they are! Let’s see why.
Theorem (Arbitrary Unions and Finite Intersections of Open Sets): Let be a metric space and let be an open set in for all where is an arbitrary index set. Then, the following properties hold:
- The set is an open set.
- If is a finite collection of open sets, then the intersection is open.
Proof: (Click in the Discovery)
Proof of 1. Here’s the idea. To show that is an open set, we must show that every has some such that Indeed, this is the case since implies that for some And, since is an open set, there is some such that
Proof of 2. Let We aim to show that there is some such that Well, implies that for Consequently, there are radii such that for Let’s simply take the smallest radii which we can guarantee is greater than zero since we are taking a minimum of a finite collection of positive numbers Thus, we have for all and consequently,
We have a nice corollary!
Corollary (Another Characterization of Open Sets): Let be a metric space. We call a subset an open set in if and only if can be written as the union of open balls in
Proof: (Click in the Discovery)
Forward: Let be an open set in It follows that for all there is some such that
Thus,
Note that we are unioning over
Backward: Let be a union of open balls in By Theorem 1 and the fact that open balls are open sets,
Now, let’s go back to show that an arbitrary intersection of open sets is not, in general, an open set.
Proposition (Arbitrary Intersections of Open Sets is NOT Open): Consider and the collection of open sets (intervals)
Then, the intersection of all open intervals in is not an open set.
Give it a go and see what you get!
Proof: (Click in the Discovery)
First, note that
Next, we claim that the intersection To see this is the case, note that we definitely have since we have for all We just have to show that no negative numbers are in our intersection.
To see that no negative number is in our intersection, suppose for the hope of a contradiction, that some where It follows (by the Archimedean Property in this article) that there is some large enough so that Consequently, Thus, see that and therefore, our contradiction.

Thus, no negative number is in our intersection proving our claim that the infinte intersection of open sets can be a non-open set,
This wasn’t too bad, right? The good news is that we are basically done since closed sets are defined in terms of open sets, we can use Theorem 1 to answer the same questions regarding closed sets.
Arbitrary Unions/Intersections of Closed Sets
Same as before,
- Is the arbitrary union of closed sets an closed set?
- Is the arbitrary intersection of closed sets an closed set?
As a hint, if you know De Morgan’s Laws (applied to sets) use them!
Ok, the answer here follows from what are known as De Morgan’s Laws.
Theorem (De Morgan’s Laws): Let be a collection of subset of the set Then we have the following,
and
Note that the index set can be finite, countably infinite, uncountably infinite, etc. It’s arbitrary.
Remark: Note that this is a statement about how taking complements interacts with unions and intersections. What’s great is that these laws are statements about sets, so to prove them we don’t need to use anything about openess/closedness.
Proof: (Click in the Discovery)
We will prove the first statement and leave you to prove the other since the proof is similar. That is, we will show the following set relation,
To begin, we show
With this goal in mind, let Now observe
The right-hand only holds if and only if there is some such that which is equivalent to the statement Which implies
Thus, as desired.
Now, note that almost all of our steps were bidirectional, that is, if and only if statements. Thus, with minor modifications, we can just use the same logic to prove the other set inclusion Thus concluding the proof.
With De Morgan’s Laws by our sides, we can now answer our questions!
Theorem (Finite Unions and Arbitrary Intersections of Closed Sets): Let be a metric space and let be a closed set in for all where is an arbitrary index set. Then, we have the following properties hold:
- If is a finite collection of closed sets, then the union is a closed set.
- The arbitrary intersection is closed.
Proof: (Click in the Discovery)
Proof of 1. Let is a finite collection of closed sets. We want to show that
is closed. We do so by demonstrating that is open. See where we will use De Morgan’s Laws?
Since is a finite collection of closed sets, is a finite collection of open sets, and therefore their intersection is open. That is is open. But by De Morgan’s Laws,
So that is open. Hence is closed, as desired.
Thus, and
Proof of 2. In a similar manner as before, we want to show that
is closed. We do so by showing that is open.
Since are closed, are open. Thus, their union is open: By De Morgan’s Law,
and is open. As desired.
Final Remarks
We have covered a lot of stuff today. I hope that you found it helpful, if not, please leave a comment indicating where I could have done better. Thank you in advance!
There is a lot more we could have covered about metric spaces than we did today. We didn’t even touch sequences or continuity yet! We will cover these in the future! However, in the meantime, there are some great resources out there for you in your mathematical journey. I will list a few of my favorites for you to peruse,
- Introduction to Metric Spaces | Mathematics | MIT OpenCourseWare This is a free MIT course with lecture videos, lecture notes, and problem sets.
- Introduction to Topology: Second Edition (Dover Books on Mathematics): Gamelin, Theodore W., Greene, Robert Everist. This is an Amazon link (with no royalties) for convenience.
- Amazon.com: Principles of Mathematical Analysis (International Series in Pure and Applied Mathematics): Rudin, Walter: Books This is another Amazon link (with no royalties) for convenience.
- Metric Space | Brilliant Math & Science Wiki Less comprehensive than the other sources, but it’s free and covers continuity. I will say that I haven;t looked at this article, but Brilliant usually does a great job.
Be Kind. Be Curious. Be Compassionate. Be Creative.
And Have Fun!
Footnote(s):
- This happens all the time in math, for instance, to form a group, we have a set with an operation on the set that satisfies certain axioms. ↩︎
- The supremum of a set of real numbers equals the least upper bound of that set. For example, the set has Similarly, This is because is an upper bound for and there is nothing smaller that is an upper bound. One way of thinking of the supremum is to think of it as quantifying what the maximum of the set wants to be. For instance, clearly the maximum element in is And, for the open interval the number really wants to be the upper bound, but since it cannot be the maximum. However, it can be the supremum! In fact, the supremum equals the maximum if it belongs to the set in question. For more detail, see this article here. Or, just change with everywhere and it all works out. ↩︎
- To see why, we employ some calculus. Consider To find its maximum (or minimum), we take its derivative and set it to zero:
Which is solved by Now, plugging this into we get ↩︎

Leave a comment