TL;DR
A vector is a list of numbers, so it has no obvious size. A norm is a rule that turns a vector into one non-negative number, its length. The most common norm, the Euclidean or norm, is the straight-line length of the arrow the vector describes: square each entry, add them up, and take the square root.
Norms also give you distance. The distance between two vectors is the norm of their difference.
Where you'll see it: in the weight penalty of a regularised model, in clipping exploding gradients by their total size, and in normalising embeddings so that they all have length 1.
Intuition
Length for a list of numbers
Take the vector and draw it as an arrow from the origin. The arrow goes 3 units right and 4 units up. Its length is the hypotenuse of a right triangle with those two legs, so Pythagoras gives .
The same idea works in any number of dimensions. A vector with a hundred entries is an arrow in a hundred-dimensional space, and its length is still the square root of the sum of the squared entries. We cannot draw that space, but the arithmetic is identical.
Why we need a rule, not just a formula
A list of numbers can be measured in several sensible ways. Walking along a city grid, you pay the sum of the absolute values of the moves, not the straight-line distance. Machine learning uses both. So the right question is not "what is the length" but "which notion of size are we using", and a norm is the name for any notion that behaves like a length.
Three properties make a function a norm:
- Non-negative and zero only at zero. A length is never negative, and only the zero vector has length zero.
- Scaling. Doubling a vector doubles its length: .
- Triangle inequality. Going from to and then to is never shorter than going directly: .
The Euclidean norm satisfies all three. So does the sum of absolute values. Any function with these three properties is a norm, and the rest of the theory only uses them.
- length of (x, 1)
- length of (x, 2)
- length of (x, 0)
The math
Definition
For a vector in , the Euclidean norm (also called the norm) is
Here is the entry of in position . The sum adds the squared entries, and the square root undoes the squaring so the result is in the same units as the entries. The double bars mean "norm of", and a plain in bold is a vector.
Triangle inequality, with numbers
Let and .
- and , so the right side of the inequality is .
- , and .
- , as the inequality promised.
The gap of about 0.34 is the cost of not walking in a perfectly straight line.
Other norms, for comparison
The same family of definitions gives other norms. The norm adds absolute values, . For it gives , compared with for the Euclidean norm. Both are norms because they pass the three tests above.
Connection to the dot product
Dotting a vector with itself gives its squared length, as covered in the dot product:
This is why the Euclidean norm is so convenient. Lengths and angles are both built from the dot product, and the square root is only needed when you want the length itself rather than its square.
flowchart LR V[Vector v] --> S[Square each entry] S --> A[Add the squares] A --> R[Square root] R --> N[Length of v] N --> D[Distance between two vectors via their difference]
Worked examples
Let .
- Square each entry: , , .
- Add the squares: .
- Take the square root: .
The sign of each entry disappears when it is squared, so and have the same length. Opposite vectors point in opposite directions but have the same size.
A point in a plane is a vector. The distance between and is the length of the difference .
- Subtract entry by entry: .
- Take the norm: .
So the two points are 5 units apart. This is the usual Pythagorean distance, written as a norm.
Take , which has length 5 from before. Divide every entry by the length:
Check: , so the new vector has length 1. It points in the same direction as and only its size has been removed. This is what "normalising" an embedding means in practice.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Comparing directions only (for example, text embeddings) | Length changes the score even when the direction is the same | Normalise first, or use cosine similarity |
| Sparse data where most entries are zero | Euclidean norm treats a small change in many entries the same as a big change in one | Consider the norm, which encourages zeros |
| Very large or very small entries | Squaring can overflow or lose precision in floating point | Scale the vector by its largest entry before squaring |
| Robustness to a single outlier entry | One huge entry dominates the sum of squares | Use or a clipped norm |
The usual failure in practice is mixing scales. If one feature is measured in metres and another in millimetres, the norm is dominated by the millimetre feature, and the distance no longer means what you intended. Standardise the features before you measure distance.
History
The idea of length comes from Pythagoras and the geometry of right triangles, long before anyone wrote it as a formula over lists of numbers. Writing a length as the square root of a sum of squared coordinates became standard once analytic geometry used coordinates. The abstract axioms of a norm were formalised by Stefan Banach and others in the 1920s and 1930s, when mathematicians started studying spaces of functions as well as spaces of arrows. The Euclidean norm is the case that matches everyday measurement, and it stayed the default because it is smooth, it fits with the dot product, and its square has a simple expansion.
Check yourself
QuestionWhat is the Euclidean norm of ?Show answer
Square the entries: . Take the square root: . The length is 7.
QuestionWhy is the norm of a vector never negative, and when is it zero?Show answer
Each squared entry is zero or positive, so their sum is non-negative, and so is its square root. The sum is zero only when every entry is zero, so the norm is zero only for the zero vector. Any other vector has a strictly positive length.
QuestionCompute the distance between and .Show answer
The distance is the norm of the difference . Then . The distance is 13.
QuestionYou scale a vector by . How does its norm change?Show answer
The scaling property says . The sign of is removed by the absolute value, so the norm becomes . The vector points the opposite way but is three times as long.
QuestionA data scientist normalises every embedding to length 1 before comparing them. Why does this make comparisons about direction rather than size?Show answer
If every vector has length 1, then the only thing left to differ between two vectors is their direction. Length can no longer make one embedding look more similar to another, so dot products of normalised vectors become measures of the angle between them alone.