Metric Spaces

A formal Introduction

Jacob Briones
6 min readOct 13, 2020

Introduction

How do we define distance? In the cartesian plane, we know that the distance between two points (x₁, y₁) and (x₂, y₂) is given by the distance formula:

This geometric definition is usually how we think of distance. But in many real world situations, we can’t think of our data points in a way that would make sense geometrically.

For example, let’s say that we have a sequence of stock prices for two different companies. Lets say that f(t) is a function representing the price of a stock at time t. days and g(t) represents the price of or some other stock at time t. What is the distance between the function f and g? To answer this, we can’t use the distance formula. We need a more general definition of distance.

We can abstract the idea of distance so that we can measure distances between objects which don’t have a nice geometric interpretation. In this article, we’ll see how this can be accomplished.

Defining Distance

Suppose X is any set. Any. We define a metric on X as a distance function d which satisfies the following axioms:

  1. d(x, x)=0 for all x in X
  2. d(x, y)=d(y, x) for all x, y in X
  3. d(x, y) ≥ 0 for all x, y in X
  4. d(x, y) d(x, z) + d(z, y) for all x, y, z in X.

The first axiom means that every element of x is a distance 0 from itself. The second axiom means that the distance from x to y is the same as the distance from y to x. Now since negative distance doesn’t make sense, the third axiom guarantees that no two points have negative distance from each other. The last, and most important axiom is known as the triangle inequality. The triangle rule is one of the most important inequalities in mathematics, despite it’s simplicity. It can be visualized below. It essentially states that the sum of two sides of a triangle is greater than the one of it’s sides.

The Triangle Inequality

Examples

In this section, we’ll take a look at a few interesting metrics to help develop some intuition. To try and solidify your understanding, you should check that each of these satisfies the axioms for a metric space.

The discrete metric

For any set X, the discrete metric is defined as follows:

The discrete metric clearly satisfies all of the 4 axioms, and is pretty boring. But it is the simplest example of a metric.

Absolute Value

In , the set of all real numbers, the function

defines a metric. This should be obvious.

The taxicab metric

Let (x₁, y₁) and (x₂, y₂) be two points in the plane ². The taxicab metric is defined

If we imagine the two points as the starting position and destination of a taxi, then the metric defines the total distance which the taxicab will travel.

Taxicab metric

A metric for continuous functions

Let C[0, 1] be the space of continuous functions with domain [0,1]. There are several metrics which could be placed on this space. An example which most people who have taken calculus have seen is the following:

This defines the total area between two functions f and g

The area between the two curves represents d(x, x²)

In general, if f and g are two functions in C[a, b], then we define

for all p ≥ 1.

Another metric for continuous functions

Let C[a, b] be the space of continuous functions with domain [a, b]. We define the metric

to be the maximum distance between f and g in the interval [a, b].

Metric Spaces

Now that we have an idea about what a metric is, we can define metric spaces. A metric space is a pair (X, d) where X is a set, and d is a metric defined on points in the set X. We have just seen several examples of metric spaces above. So now, we will look at some important properties regarding metric spaces

Open Balls

Let (X, d) be a metric space, and let x be any element of X. For some fixed r > 0, define the open ball of radius r centered at x by the set

Open ball of radius r centered at x₀

Also commonly written as B(x ; r).

Convergence in metric spaces

In mathematics, convergence is a very important concept. Almost every math course I took in college talked about convergence in one way or another. We’ll see what convergence looks like in a metric space.

Let (X, d) be a metric space. A sequence (x₀, x₁, x₂, … ) converges to a limit x in X if, for all ϵ >0, there exists a natural number N such that d(xₙ, x) <ϵ for all n ≥ N.

Visualizing convergence: After the Nth point, the points in the sequence stay within a distance ϵ of the limit.

Equivalently, a sequence (x₀, x₁, x₂, … ) converges to a limit x in X if, for all ϵ>0, there exists a natural number n such that x is in the open ball B(xₙ; ϵ) for all m≥ n.

Lets take a look at an example. Define the following recursive sequence in the set of rationals (ℚ, d) with the absolute value metric.

A sequence in ℚ

The first few terms of the sequence are 1, 1.5 ,1.4166.414215,1.41421,… It looks like the sequence is converging to √2. But it is a known fact that √2 is not a rational number. So it does not converge in . However, it does converge in (ℝ, d). Sequences that don’t converge, but get arbitrarily close to each other, such as this one, are called Cauchy Sequences.

The above example actually tells us something important about (ℚ, d). It tells us that under the absolute value metric, is not a complete metric space. A complete metric space is a metric space (X, d) in which every Cauchy sequence converges to a limit which is contained in X. Any sequence which converges to an irrational number is not a convergent sequence in (ℚ, d), and hence, it is not complete.

Conclusion

We took a look at the very basic concepts of metric spaces, and convergence. Two very important concepts in mathematical analysis. There are so many examples of metric spaces available on the internet that you can find if you want more. I will be posting more content soon! Also, feel free to contact me. Hope you enjoyed. Stay frosty, my friends.

--

--

Jacob Briones

Specializing in explainable AI, mathematics, and physical sciences through the use of visualization, computer science, and creative writing.