When you handle arrays of numerical data, you often need to be able to describe them in terms of their magnitude. In this topic, you will define the concept of norm and see how it relates to the concept of metric, measuring distances, and magnitudes.
Norm
At first, let's focus on vectors on the plane and facts you already know.
Given the vector :
You know that you can use the Pythagorean theorem to determine its length:
For any vector, norm is equal to its length and is denoted by double bars. So, for our vector :
There's also a more general definition of the norm as a function that maps a vector of real (or complex) numbers to one non-negative real number. Here's an illustration of this definition of our vector .
Can any function be a norm? For sure, not! A function is considered a norm if and only if it satisfies the following properties:
Zero only for zero vector: The only vector that has a norm of zero is the zero vector itself. In other words, if the length of a vector is zero, that means it's not pointing anywhere – it's just a point.
Scalar multiplication: If you stretch or shrink a vector by a factor, the norm changes by the same factor. So if you have a vector of length and you double it, the new vector has a length of . Mathematically, you can write it as , where is a scalar and is a vector.
Triangle inequality: This property says that the length of one vector plus the length of another vector is always greater than or equal to the length of the vector that you get when you add the two together. This is just like the rule in geometry that says that in any triangle, the length of one side plus the length of another side is always greater than or equal to the length of the third side. Mathematically, you can write it as , where are two different vectors.
Different norms
The ancient Greeks were able to formally describe the Euclidean norm by observing the relationship between squares constructed on the sides of a right triangle. They arrived at the idea that the length of the line segment between two points corresponds to the Euclidean distance between them.
You've already used this norm in the previous paragraph for the vector on a plane. If you have a vector in a three-dimensional space, it's still quite easy to understand, how to calculate the norm using the Pythagorean theorem. But what happens if you have vectors in four or even ten-dimensional space? Surprisingly enough, you can still use the Pythagorean theorem, but you'll have to add more squares of vector coordinates.
For an -dimensional space, the Euclidean norm of a vector is equal to:
Let's consider an example. Imagine that you have a vector in a six-dimensional space. Its Euclidean norm is equal to:
However, there are times when constraints force us to find new ways to define distances. Picture a city with a rectangular grid, like Manhattan in NYC. Imagine there is a huge skyscraper taking up the entire block on either side. Here, if you tried to find the shortest route between streets using the Euclidean distance, you'd have to go through the skyscraper's walls!
Enter the Manhattan norm: if you measure the distance between two points as the sum of the distances between their coordinates instead, you can find the shortest possible route without running into any walls.
This definition of distance gave way to its own form of geometry – Taxicab geometry.
Formally, the Manhattan norm of a vector is defined as:
Let's consider an example. Imagine that you are at the point and you would like to go to the café at the point . The shortest route, according to the Manhattan norm, is equal to .
There's also another type of norm called p-norm. It is defined as:
As you can see, we get the Euclidean norm if . So, this norm is also referred to as 2-norm. The subscript for it is usually omitted. When you have the Manhattan norm, which we've just discussed.
Mighty metrics
You can use a given norm to define a metric. A metric is a function that maps two elements of a set (like two vectors, for example) to the distance between them.
For a given norm and two vectors and , you can define a distance function, or metric, as follows:
Let's consider two points on the plane, and , with their corresponding point vectors and :
You can determine the distance between the two vectors by subtracting one vector from the other and computing the norm of the resulting vector:
So, the Euclidean distance between vectors and is computed using the formula
On the other hand, the Manhattan norm between them is
A metric must satisfy the following properties:
Identity of indiscernibles: The distance between two points is zero if and only if the points are the same. In other words, if two objects are exactly the same, their distance apart is zero. Formally, it can be written as
Symmetry: The distance between point and point is the same as the distance between point and point . This property reflects the idea that the distance between two points doesn't depend on the order in which you consider them. Formally, it can be written as
Triangle inequality: If you have three points and , the distance between and is always less than or equal to the sum of the distances between and , and between and . This property captures the idea that the shortest path between two points is a straight line, or at least not longer than any detour you might take. Formally, you can write it as
Conclusion
In this topic, you have learned that:
A norm is a function that maps a vector to a non-negative real number
A norm must satisfy three properties: zero only for zero vector, scalar multiplication, and triangle inequality.
When you measure distances using the Pythagorean theorem, you are talking about the Euclidean norm.
When you measure the distance between two points as the sum of the distances between their coordinates, you are talking about the Manhattan norm.
You can use different types of norms to define metrics.
All metrics have to satisfy three properties: identity of indiscernibles, symmetry and triangle inequality.