Metric Spaces

Metric Space Manhattan by J Labrador

Even in everyday life, the question “What’s the distance between Point A and Point B?” is ambiguous. The standard definition of distance is the length of a straight line segment with one end at A and the other at B. But, if you ask me how far it is from LAX to Downtown LA, I’m probably not going to tell you the actual distance that a measuring tape would show if it had one end in MacArthur Park and the other nailed to the tarmac. More likely I would tell you the number of miles taken by the fastest route.

In Manhattan, distance is usually measured in how many blocks you have to walk north/south plus how many blocks you have to walk east/west instead of the standard distance. If you take the subway, you may measure distance in the number of stops between the two places and, if you’re going crosstown, you may even have to go south then east then double back north, counting each stop along the way.

One of the wonderful things about math is that it takes concepts we bump into every day without even noticing, finds underlying similarities, and then builds a general theory that applies more universally. What common attributes do all these measures of distance have?

  1. The distance from any point to itself is 0. If you’re measuring distance in a way that lets someone be 10 feet away from themselves, you’re doing it wrong. Similarly if the distance between Point A and Point B is 0, A and B must be the same exact location.

  2. The distance from Point A to Point B is the same as the distance from Point B to Point A. This one is a little irritating in the real world because there are sometimes one way shortcuts, but we’ll put our heads in the sand like ostriches and ignore that in the name of mathematical elegance.

  3. For any three points A, B, and C, the distance between A and C can’t possibly be more than the distance from A to B plus the distance from B to C. In other words, making an extra stop can’t make your trip any shorter.

One important thing to say about Property 3, often called the triangle inequality, is that it is possible that the distance from A to C is equal to the distance between A and B plus the distance between B and C. For instance, if I drive from Los Angeles to San Diego and there’s a gas station right off the highway between the two cities, the distance from Los Angeles to San Diego (distance of the drive along the highway, that is) is basically the distance between Los Angeles and the gas station plus the distance between the gas station and San Diego. On the other hand, if I wander from Los Angeles east into Riverside county for a hike and then down to San Diego, I have substantially increased the distance of my trip relative to the actual length of the fastest route between the two cities.

In math we use the word metric to describe a measure of distance that satisfies all three properties above. Aside from the standard distance based on the length of the straight line between two points, what other metrics are there?

A common one is the taxicab metric or Manhattan metric that we’ve already seen. In this metric, the distance between A and B is the shortest length it takes to get from A to B if you only go north/south and east/west (i.e. no diagonals). The names “taxicab” and “Manhattan” refer to the fact I alluded to earlier that, if you take a cab in Manhattan, you can only go north/south and east/west so it’s a pretty useful metric when you’re there. If you’re as cheap as I am, the subway metric I mentioned earlier is more practical. If we think about distance in 3-dimensional space, then we allow ourselves only to go north/south, east/west, and up/down (in altitude). You need to take the north/south, east/west, up/down coordinate system with a grain of salt because it doesn’t make a whole lot of sense in outer space, but take my word for it that you can make it mathematically formal without too much difficulty if you understand coordinate systems.

Metric Spaces 7 across 5 up taxicab metric
In the taxicab metric, the distance between A and B is 12.

On a 2-dimensional plane, the uniform metric is the larger number of the east/west distance and the north/south distance. In the diagram below you can see one of the oddities of changing metrics. In the uniform metric, B is closer to A than C is. However, in both the standard metric and the taxicab metric, C is closer to A than B is. In 3-dimensional space, the uniform metric is, as you may expect by now, the biggest number of the east/west, north/south, and up/down distances.

Metric Spaces 7 across and 8 across uniform metric
In the uniform metric, the distance between A and B is 7 while the distance between A and C is 8.

One of the reasons I bothered to mention 3-dimensional space at all is to draw attention to the fact that nowhere in the definition of a metric does it matter that we define distances on a plane. You may know from air travel that when you fly around the earth, you take what looks like a roundabout route on a map, but is actually a segment of great circle, that is a circle around the surface of the Earth whose center is also the center of the Earth. It turns out that, assuming you don’t have a really good shovel, the shortest distance you can travel to move between 2 points on the Earth’s surface is along a segment of a great circle (incidentally, there’s only one great circle between any two points on the Earth’s surface). As a result the most useful metric to determine distance on the Earth’s surface is the geodesic metric where the distance between two points is the shortest distance you can travel to get between them on the Earth’s surface, that is travelling along a great circle.

When we talk about distance, we think about some metric space of all locations between which we measure distances. For instance, if we talk about the taxicab metric in the gridded portion in Manhattan, our metric space is “all street corners on the grid” equipped with the metric that measures the distance between two street corners on the grid as the number of east/west blocks between them plus the number of north/south blocks between them. The word location is a little deceptive, because in the abstract these “locations” can be any type of object. In the box below we’ll see an example where the locations are planets, an example where the locations are towns, an example where the locations are people, and even an example where the locations are words.

We’ve seen some more mathematically useful metric spaces, a 2-dimensional plane, a 3-dimensional space, and the surface of the Earth equipped with different metrics such as the standard, uniform, and geodesic metrics respectively. Here are some other metric spaces…

  • Stupid example: We say that the distance between two planets is 1 if they’re not the same planet and 0 if they are the same planet. Then our metric space is the set of all planets in the universe paired with the “are they the same planet?” metric. It’s dumb, but it satisfies all the metric properties. As a side note, the same metric works for any set; for instance we can take the set of people and say their distance is 1 if they’re not the same person and 0 if they are the same person. In general this is called the discrete metric.

  • Computer science example: We say the distance between two words of the same length is the number of letter positions they differ in. So the distance between “plain” and “plant” is 2 (they differ in the bolded slots 4 and 5) while the distance between “serve” and “erase” is 4 (they differ in the bolded slots 1, 2, 3, and 4). In this example the metric space is the set of all 5-letter words paired with the Hamming metric that I just described.

  • Cheap example: Suppose we live in a state where there’s one road connecting any 2 neighboring towns and each of these roads has at least one toll booth on it. Then we can measure the distance between two cities as the least amount of money we need to pay to pay in tolls to get from one to the other. It sounds weird to measure distance in money, but as long as the tollbooths charge the same amount in both directions, it satisfies the three properties of a metric. Then our metric space is the set of all the cities in the state paired with the “holy hell, why is driving in this state so damn expensive?” metric.

Jordy Greenblatt is a PhD student in pure math at UCLA doing research in harmonic analysis. His intellectual interests include physics and history but he likes to spend his free time juggling and playing harmonica. He co-writes the humor blog Put It All on Red and contributes to Trop and McSweeney's Internet Tendency.

comments powered by Disqus

Get the best

Get monthly email updates with the best from The Concepts Project. No spam, ever.

Contact us

Get in touch, we'd love to hear from you:

Greatest Hits

Thinking At The Margin: what to do when you drop your piggy bank in the middle of the forest.

Strategy and Backward Induction: how to win a week of lunches from your unsuspecting colleagues.

What is Multiple Imputation?: when statisticians turn into detectives.

On Shuttle Drivers, Chocolate and NP Completeness: a deliciously difficult problem in computer science.

Rest and Digest vs Fight or Flight: how your body (and medications) help with fighting tigers.

Sites we like

William Shaw, writing about Politics, Theatre, Sci-fi… Mainly Sci-fi.

Better Explained, for maths explanations that click.

Science Non Fiction, a graduate student perspective on science in the news and in our lives.

Clearer Thinking, learn to think more clearly and make better decisions., working to improve the quality of research communications.

Jess Whittlestone, a blog about decision making and behavioural science.