6.28 min read
Length and Distance
The length (or norm) of a vector is the square root of its dot product with itself: . This matches the familiar Pythagorean formula for distance from the origin.
Scaling a vector scales its length proportionally: . A vector with length 1 is called a unit vector. Given any nonzero vector , dividing by its length gives a unit vector in the same direction: . This is called normalization.
The distance between two vectors and is the length of their difference: . Think of and as points, and the vector as the arrow from to .
Formal View
Definition 6.3 — Length (Norm)
For , its length is . The squared length is . If , we call a unit vector, sometimes written .
Definition 6.4 — Distance
The distance between is
Why This Matters
Norms and distances give geometry its measurement capabilities — they let us say what "close" and "far" mean.
- K-nearest neighbors classifiers assign a class to a test point based on the Euclidean distances to training examples
- Image compression measures reconstruction error by the squared distance
- GPS and sensor fusion use norm minimization to find the most likely position given noisy measurements
- The Frobenius norm of a matrix — the length of all entries as one long vector — measures how far a matrix is from zero
Quiz
Question 1
What is for ?
Question 2
If , what is ?
Common Mistakes
- Computing as — the triangle inequality says , with equality only when they point in the same direction.
- Forgetting to take the square root — is the squared length, not the length.
- Normalizing the zero vector — division by is undefined.