Euclidean distance and L2 norm are closely related, but they are not exactly the same idea.
An L2 norm measures the length of one vector. Euclidean distance measures the distance between two vectors. In practice, Euclidean distance is the L2 norm of the difference between two vectors.
Short Answer
The difference is:
- L2 norm: how long one vector is
- Euclidean distance: how far apart two vectors are
If you subtract one vector from another, then take the L2 norm of that difference, you get the Euclidean distance.
What Is an L2 Norm?
The L2 norm is the length or magnitude of a vector.
For a vector A = [3, 4], the L2 norm is:
sqrt(3^2 + 4^2) = sqrt(9 + 16) = sqrt(25) = 5
So the vector [3, 4] has length 5.
This measures how far the vector is from the origin, which is the zero point [0, 0].
What Is Euclidean Distance?
Euclidean distance is the straight-line distance between two vectors.
For two vectors:
A = [2, 3]
B = [5, 7]
First subtract them:
B - A = [5 - 2, 7 - 3] = [3, 4]
Then take the L2 norm of the difference:
sqrt(3^2 + 4^2) = 5
The Euclidean distance between A and B is 5.
The Relationship
The relationship can be written like this:
Euclidean distance between A and B = L2 norm of (A - B)
Or:
distance(A, B) = ||A - B||2
That means Euclidean distance uses the L2 norm, but applies it to the difference between two vectors.
Why People Confuse Them
People confuse Euclidean distance and L2 norm because the formulas look almost the same.
L2 norm of one vector:
||A||2 = sqrt(A1^2 + A2^2 + ... + An^2)
Euclidean distance between two vectors:
distance(A, B) = sqrt((A1 - B1)^2 + (A2 - B2)^2 + ... + (An - Bn)^2)
The only difference is that Euclidean distance first subtracts two vectors. L2 norm measures the length of whichever vector you give it.
Example: One Vector vs Two Vectors
Use one vector:
A = [3, 4]
The L2 norm is:
sqrt(3^2 + 4^2) = 5
Now use two vectors:
A = [2, 3]
B = [5, 7]
The difference is:
B - A = [3, 4]
The L2 norm of that difference is:
sqrt(3^2 + 4^2) = 5
So the same length calculation appears in both examples, but the meaning is different.
In Vector Search
In vector search, Euclidean distance is used to compare a query vector with stored vectors.
The database is usually asking:
How far is this stored vector from the query vector?
That is a Euclidean distance question.
The L2 norm can still matter, especially when thinking about vector magnitude, normalization, or how embedding models represent information. But search ranking usually compares two vectors, so the distance between them is the practical value.
Why the Origin Matters
The L2 norm measures distance from the origin.
For vector A, the L2 norm is the distance from [0, 0, ...] to A.
Euclidean distance does not have to involve the origin. It measures the distance from one vector to another vector.
That is the simplest way to remember the difference:
- L2 norm: vector to origin
- Euclidean distance: vector to vector
What About L2 Distance?
In many vector database discussions, L2 distance means Euclidean distance.
That can be slightly confusing because the word “L2” comes from the L2 norm. But when people say “L2 distance” in search, they usually mean the distance between two vectors calculated with the L2 norm.
So:
- L2 norm is the general length operation
- L2 distance is usually Euclidean distance between two vectors
- Euclidean distance is the L2 norm of the vector difference
Squared L2 Distance
Some systems return squared L2 distance.
Squared L2 distance is Euclidean distance without the final square root:
sum((Ai - Bi)^2)
This is often used because it is efficient and preserves nearest-neighbor ordering. The values are on a squared scale, but the closest vector stays closest.
How This Relates to Cosine Similarity
Cosine similarity compares vector direction. Euclidean distance compares coordinate distance.
L2 norm is involved in cosine similarity too, because cosine similarity divides by vector lengths. That is one reason normalization changes how vector comparisons behave.
If vectors are normalized to the same length, cosine-based comparisons and Euclidean-style comparisons can become more closely related. If vectors are not normalized, magnitude can affect Euclidean distance more directly.
Common Mistakes
Common mistakes include:
- saying L2 norm when you mean distance between two vectors
- saying Euclidean distance when you mean the length of one vector
- forgetting that L2 norm measures from the origin
- treating squared L2 values as ordinary Euclidean distance values
- switching between cosine and Euclidean metrics without testing relevance
Summary
L2 norm measures the length of one vector. Euclidean distance measures the distance between two vectors.
The connection is simple: Euclidean distance between two vectors is the L2 norm of their difference.
In vector search, “L2 distance” usually means Euclidean distance between a query vector and a stored vector. Lower distance means the vectors are closer under that metric.