Angles and Orthogonality
Analytic Geometry
From an inner product we can extract the angle between two non-zero vectors via costheta = frac{langle mathbf{u}, mathbf{v}rangle}{\|mathbf{u}\| cdot \|mathbf{v}\|}. Cauchy–Schwarz guarantees this ratio lies in [-1, 1], so theta in [0, pi] is well-defined. When theta = 0 the vectors are parallel and
defines the angle between vectors.
From an inner product we can extract the angle between two non-zero vectors via . Cauchy–Schwarz guarantees this ratio lies in , so is well-defined. When the vectors are parallel and pointing the same way; when they are anti-parallel; when they are orthogonal.
Two vectors are orthogonal, written , exactly when . Orthogonality is the vector analog of 'independent' or 'unrelated' — orthogonal directions contribute cleanly separate information. Geometrically, two orthogonal vectors meet at a right angle, but algebraically orthogonality extends to any inner-product space, including spaces of functions.
The Pythagorean theorem generalizes to any inner-product space: if , then . This is not a coincidence — the Pythagorean theorem *is* what you get when you expand the squared norm and use orthogonality to kill the cross term. Every 'variance decomposition' in statistics is Pythagoras in disguise.
A matrix is orthogonal if , i.e., its columns form an orthonormal set (unit length, pairwise perpendicular). Orthogonal matrices preserve inner products: . Consequently they preserve lengths and angles — they are exactly the rigid motions of space: rotations and reflections. Orthogonal transformations are the best-behaved linear maps, numerically stable and information-preserving.
Worked example — 45° angle: For and : , , . So , giving (or ). Geometrically bisects the first quadrant.
Worked example — orthogonality: and : . Orthogonal, 90° apart. In general, for any , the vector is perpendicular — a handy 2D trick.
Angles are everywhere in ML. Cosine similarity is the go-to retrieval metric because it ignores vector magnitude. Attention scores in transformers compute — a scaled dot product, essentially an unnormalized cosine. Orthogonal initialization of weights in RNNs prevents gradient explosion by keeping signal magnitudes stable. The angle concept, once abstract, is the backbone of modern representation learning.
Exercises
Put your understanding to the test. Score + streak + speed all count.
Confirm you've got it
3 quick questions. Get 2 right to mark this lesson complete.