Skip to content
BIASED

Inner products, norms and orthogonality

Block 1 of 8~3 min

The dot product: length and angle

The topic Matrices and linear systems ended with systems that have no solution. Take three equations in two unknowns:

x1=1,x2=2,x1+x2=6.x_1 = 1, \qquad x_2 = 2, \qquad x_1 + x_2 = 6 .

The first two force x1+x2=3x_1 + x_2 = 3, not 66. In matrix form Ax=bAx = b has no exact solution, but some xx come closer than others. To say "closer" we need lengths, and lengths come from one operation.

The dot product of x,y∈Rnx, y \in \mathbb R^n multiplies matching coordinates and adds them up:

⟨x,y⟩=x⊤y=∑i=1nxiyi.\langle x, y \rangle = x^\top y = \sum_{i=1}^n x_i y_i .

It gives the length ∥x∥=⟨x,x⟩\lVert x \rVert = \sqrt{\langle x, x \rangle} and the distance ∥x−y∥\lVert x - y \rVert. In the plane it also gives the angle, by the law of cosines:

⟨x,y⟩=∥x∥ ∥y∥cos⁡θ.\langle x, y \rangle = \lVert x \rVert\, \lVert y \rVert \cos\theta .

For u=(3,4)u = (3, 4) and v=(4,3)v = (4, 3): u⊤v=24u^\top v = 24, both lengths are 55, so cos⁡θ=0.96\cos\theta = 0.96 and θ≈16.3∘\theta \approx 16.3^\circ. In R768\mathbb R^{768} there is no protractor, so we turn this around and define the angle by the formula.

Two vectors are orthogonal, x⊥yx \perp y, when ⟨x,y⟩=0\langle x, y \rangle = 0. Then Pythagoras holds in any dimension: ∥x+y∥2=∥x∥2+∥y∥2\lVert x + y \rVert^2 = \lVert x \rVert^2 + \lVert y \rVert^2.

The dot product is one example of an inner product: a rule that is symmetric, linear in each argument and gives ⟨x,x⟩>0\langle x, x \rangle > 0 for every x≠0x \ne 0. Another is ⟨x,y⟩M=x⊤My\langle x, y \rangle_M = x^\top M y with M=diag⁡(m1,…,mn)M = \operatorname{diag}(m_1, \dots, m_n) and all mi>0m_i > 0. It weighs features differently, which is what rescaling features does to a model's geometry. Below, ⟨x,y⟩\langle x, y \rangle means the plain dot product.

Answers are saved on the server and tied to this browser until you sign in.