Unit 6, lesson 29

Orthonormal Coordinates and Line Projection

How the projection coefficient gives the projection of a vector onto a line, why the residual is perpendicular and the projection is the closest point, and how orthonormal bases and orthogonal matrices give coordinates.

  • Video 29
  • Projections and Orthogonal Complements

Start at the point (4,3)(4, 3) and look at the line through the origin in the direction (1,2)(1, 2). Which point of the line is nearest? If you slide a candidate point along the line, the segment back to (4,3)(4, 3) is shortest where it meets the line at a right angle. This lesson turns that picture into a formula, proves that no other point of the line comes closer, and shows that the same measurement along unit directions gives coordinates in an orthonormal basis. A tuple such as (4,3)(4, 3) stands for a column vector, and the inner product is the dot product of Rn\mathbb{R}^n unless another one is named.

Key terms

Orthogonal list

Definition A list v1,…,vk\mathbf{v}_1, \dots, \mathbf{v}_k of vectors in a real inner product space is orthogonal if ⟨vi,vj⟩=0\langle \mathbf{v}_i, \mathbf{v}_j \rangle = 0 whenever i≠ji \ne j. It is orthonormal if, in addition, every vector has norm 11, that is

⟨vi,vj⟩={1,i=j,0,i≠j.\langle \mathbf{v}_i, \mathbf{v}_j \rangle = \begin{cases} 1, & i = j, \\ 0, & i \ne j. \end{cases}

An orthogonal list may contain the zero vector, while an orthonormal list cannot. An orthogonal list of nonzero vectors is linearly independent. Indeed, if c1v1+⋯+ckvk=0c_1\mathbf{v}_1 + \cdots + c_k\mathbf{v}_k = \mathbf{0}, taking the inner product of both sides with vj\mathbf{v}_j leaves cj∥vj∥2=0c_j \lVert \mathbf{v}_j \rVert^2 = 0, so cj=0c_j = 0 for each jj. Dividing each vector of such a list by its norm gives an orthonormal list with the same span.

In plain words In an orthogonal list every pair of vectors has inner product zero, and every pair of nonzero vectors meets at a right angle. Orthonormal adds that each vector has length one, so the list behaves like a set of standard axes.

Example In R3\mathbb{R}^3 the vectors v1=(1,1,0)\mathbf{v}_1 = (1, 1, 0), v2=(1,−1,1)\mathbf{v}_2 = (1, -1, 1) and v3=(−1,1,2)\mathbf{v}_3 = (-1, 1, 2) form an orthogonal list, since

v1⋅v2=1−1+0=0,v1⋅v3=−1+1+0=0,v2⋅v3=−1−1+2=0.\begin{aligned} \mathbf{v}_1 \cdot \mathbf{v}_2 &= 1 - 1 + 0 = 0, \\[0.4em] \mathbf{v}_1 \cdot \mathbf{v}_3 &= -1 + 1 + 0 = 0, \\[0.4em] \mathbf{v}_2 \cdot \mathbf{v}_3 &= -1 - 1 + 2 = 0. \end{aligned}

Their norms are 2\sqrt{2}, 3\sqrt{3} and 6\sqrt{6}, so v1/2\mathbf{v}_1/\sqrt{2}, v2/3\mathbf{v}_2/\sqrt{3} and v3/6\mathbf{v}_3/\sqrt{6} form an orthonormal list. The list (1,0),(0,0)(1, 0), (0, 0) is orthogonal, but it is neither orthonormal nor independent.

Orthonormal basis

Definition An orthonormal basis of a finite-dimensional real inner product space VV is an orthonormal list that is a basis of VV. Since orthonormal lists are independent, every orthonormal list of dim⁡V\dim V vectors in VV is an orthonormal basis. If B=(q1,…,qn)\mathcal{B} = (\mathbf{q}_1, \dots, \mathbf{q}_n) is an orthonormal basis of VV, then every v\mathbf{v} in VV satisfies

v=⟨q1,v⟩q1+⋯+⟨qn,v⟩qn,\begin{aligned} \mathbf{v} &= \langle \mathbf{q}_1, \mathbf{v} \rangle \mathbf{q}_1 + \cdots \\[0.4em] &\quad + \langle \mathbf{q}_n, \mathbf{v} \rangle \mathbf{q}_n, \end{aligned}

so its coordinates are [v]B=(⟨q1,v⟩,…,⟨qn,v⟩)[\mathbf{v}]_{\mathcal{B}} = (\langle \mathbf{q}_1, \mathbf{v} \rangle, \dots, \langle \mathbf{q}_n, \mathbf{v} \rangle). To see this, write v=a1q1+⋯+anqn\mathbf{v} = a_1\mathbf{q}_1 + \cdots + a_n\mathbf{q}_n and take the inner product with qj\mathbf{q}_j. Every term but one vanishes, and ⟨qj,qj⟩=1\langle \mathbf{q}_j, \mathbf{q}_j \rangle = 1, which leaves ⟨qj,v⟩=aj\langle \mathbf{q}_j, \mathbf{v} \rangle = a_j.

In plain words In an orthonormal basis each coordinate is a single measurement along one basis vector. No system of equations has to be solved.

Example The vectors q1=12(1,1)\mathbf{q}_1 = \frac{1}{\sqrt{2}}(1, 1) and q2=12(1,−1)\mathbf{q}_2 = \frac{1}{\sqrt{2}}(1, -1) have length 11 and dot product 00, so they form an orthonormal basis B\mathcal{B} of R2\mathbb{R}^2. For b=(5,−1)\mathbf{b} = (5, -1),

q1⋅b=5−12=22,q2⋅b=5+12=32,\begin{aligned} \mathbf{q}_1 \cdot \mathbf{b} &= \frac{5 - 1}{\sqrt{2}} = 2\sqrt{2}, \\[0.4em] \mathbf{q}_2 \cdot \mathbf{b} &= \frac{5 + 1}{\sqrt{2}} = 3\sqrt{2}, \end{aligned}

so [b]B=(22,32)[\mathbf{b}]_{\mathcal{B}} = (2\sqrt{2}, 3\sqrt{2}). Rebuilding gives 22 q1+32 q2=(2,2)+(3,−3)=(5,−1)2\sqrt{2}\,\mathbf{q}_1 + 3\sqrt{2}\,\mathbf{q}_2 = (2, 2) + (3, -3) = (5, -1). The shortcut needs orthonormality. In the basis (1,0),(1,1)(1, 0), (1, 1), which is not orthogonal, the vector (3,2)(3, 2) equals 1⋅(1,0)+2⋅(1,1)1 \cdot (1, 0) + 2 \cdot (1, 1), so its coordinates are (1,2)(1, 2), while its dot products with the basis vectors are 33 and 55.

Projection onto a line

Definition Let u\mathbf{u} be a nonzero vector in Rn\mathbb{R}^n and L=span⁡{u}L = \operatorname{span}\{\mathbf{u}\}, the line through the origin in the direction of u\mathbf{u}. The orthogonal projection of a vector b\mathbf{b} in Rn\mathbb{R}^n onto LL is

proj⁡Lb=u⋅bu⋅u u.\operatorname{proj}_L \mathbf{b} = \frac{\mathbf{u} \cdot \mathbf{b}}{\mathbf{u} \cdot \mathbf{u}}\,\mathbf{u}.

The scalar α=(u⋅b)/(u⋅u)\alpha = (\mathbf{u} \cdot \mathbf{b})/(\mathbf{u} \cdot \mathbf{u}) is the projection coefficient. It is the only scalar for which b−αu\mathbf{b} - \alpha\mathbf{u} is orthogonal to u\mathbf{u}, because the equation

u⋅(b−αu)=u⋅b−α (u⋅u)=0\begin{aligned} &\mathbf{u} \cdot (\mathbf{b} - \alpha\mathbf{u}) \\[0.4em] &\quad = \mathbf{u} \cdot \mathbf{b} - \alpha\,(\mathbf{u} \cdot \mathbf{u}) = 0 \end{aligned}

has exactly one solution, since u⋅u>0\mathbf{u} \cdot \mathbf{u} > 0 for u≠0\mathbf{u} \ne \mathbf{0}. For a unit vector q\mathbf{q} the denominator is 11, so the coefficient is q⋅b\mathbf{q} \cdot \mathbf{b} and the projection is (q⋅b) q(\mathbf{q} \cdot \mathbf{b})\,\mathbf{q}. Replacing u\mathbf{u} by cuc\mathbf{u} with c≠0c \ne 0 divides the coefficient by cc and leaves the projected vector unchanged, so the projection depends only on the line. In any real inner product space the same formula holds with ⟨u,b⟩/⟨u,u⟩\langle \mathbf{u}, \mathbf{b} \rangle / \langle \mathbf{u}, \mathbf{u} \rangle as the coefficient. If u=0\mathbf{u} = \mathbf{0}, its span is {0}\{\mathbf{0}\} rather than a line, and the projection onto that subspace is 0\mathbf{0}, with no division involved.

In plain words Drop a perpendicular from b\mathbf{b} to the line, and the foot of the perpendicular is the projection. The coefficient is the signed number of copies of u\mathbf{u} that reach that foot. It can be any real number, not only a whole number, and it depends on the chosen u\mathbf{u}, while the foot does not. The denominator is the squared length of u\mathbf{u}, not its length.

Example For u=(1,2)\mathbf{u} = (1, 2) and b=(4,3)\mathbf{b} = (4, 3), the dot products are u⋅b=10\mathbf{u} \cdot \mathbf{b} = 10 and u⋅u=5\mathbf{u} \cdot \mathbf{u} = 5, so α=2\alpha = 2 and proj⁡Lb=(2,4)\operatorname{proj}_L \mathbf{b} = (2, 4). With −u=(−1,−2)-\mathbf{u} = (-1, -2) as the generator, the coefficient is −10/5=−2-10/5 = -2, and −2⋅(−1,−2)-2 \cdot (-1, -2) is again (2,4)(2, 4). With the unit vector q=15(1,2)\mathbf{q} = \frac{1}{\sqrt{5}}(1, 2) the coefficient is q⋅b=105=25\mathbf{q} \cdot \mathbf{b} = \frac{10}{\sqrt{5}} = 2\sqrt{5}, and 25 q=(2,4)2\sqrt{5}\,\mathbf{q} = (2, 4) once more.

Residual vector

Definition Let u≠0\mathbf{u} \ne \mathbf{0}, L=span⁡{u}L = \operatorname{span}\{\mathbf{u}\} and p=proj⁡Lb\mathbf{p} = \operatorname{proj}_L \mathbf{b}. The residual vector is r=b−p\mathbf{r} = \mathbf{b} - \mathbf{p}. It is orthogonal to u\mathbf{u}, hence to every vector of LL, and

b=p+r\mathbf{b} = \mathbf{p} + \mathbf{r}

writes b\mathbf{b} as a vector on LL plus a vector orthogonal to LL. This split is unique. If b=βu+s\mathbf{b} = \beta\mathbf{u} + \mathbf{s} with s\mathbf{s} orthogonal to u\mathbf{u}, then b−βu\mathbf{b} - \beta\mathbf{u} is orthogonal to u\mathbf{u}, so β\beta is the projection coefficient. For orthogonal vectors x\mathbf{x} and y\mathbf{y} the Pythagorean identity ∥x+y∥2=∥x∥2+∥y∥2\lVert \mathbf{x} + \mathbf{y} \rVert^2 = \lVert \mathbf{x} \rVert^2 + \lVert \mathbf{y} \rVert^2 holds, so

∥b∥2=∥p∥2+∥r∥2.\lVert \mathbf{b} \rVert^2 = \lVert \mathbf{p} \rVert^2 + \lVert \mathbf{r} \rVert^2.

In plain words The residual is what remains of b\mathbf{b} after removing its part along the line. When b\mathbf{b} is off the line, the residual points straight from the line to b\mathbf{b}. Its length is the distance from b\mathbf{b} to the line, as the next card proves.

Example Continuing with u=(1,2)\mathbf{u} = (1, 2) and b=(4,3)\mathbf{b} = (4, 3), the residual is r=(4,3)−(2,4)=(2,−1)\mathbf{r} = (4, 3) - (2, 4) = (2, -1). It passes the test u⋅r=2−2=0\mathbf{u} \cdot \mathbf{r} = 2 - 2 = 0. The squared lengths are ∥p∥2=20\lVert \mathbf{p} \rVert^2 = 20, ∥r∥2=5\lVert \mathbf{r} \rVert^2 = 5 and ∥b∥2=25=20+5\lVert \mathbf{b} \rVert^2 = 25 = 20 + 5. Projecting the pieces again shows their roles, since p\mathbf{p} projects to itself and r\mathbf{r} projects to 0\mathbf{0}.

Closest-point property

Definition Let u≠0\mathbf{u} \ne \mathbf{0} in Rn\mathbb{R}^n, L=span⁡{u}L = \operatorname{span}\{\mathbf{u}\}, b\mathbf{b} in Rn\mathbb{R}^n and p=proj⁡Lb\mathbf{p} = \operatorname{proj}_L \mathbf{b}. For every y\mathbf{y} in LL,

∥b−y∥2=∥b−p∥2+∥p−y∥2.\begin{aligned} \lVert \mathbf{b} - \mathbf{y} \rVert^2 &= \lVert \mathbf{b} - \mathbf{p} \rVert^2 \\[0.4em] &\quad + \lVert \mathbf{p} - \mathbf{y} \rVert^2. \end{aligned}

Hence ∥b−y∥≥∥b−p∥\lVert \mathbf{b} - \mathbf{y} \rVert \ge \lVert \mathbf{b} - \mathbf{p} \rVert, with equality only for y=p\mathbf{y} = \mathbf{p}. So p\mathbf{p} is the unique point of LL closest to b\mathbf{b}, and the distance from b\mathbf{b} to LL is the length ∥r∥\lVert \mathbf{r} \rVert of the residual. To prove the identity, write b−y=r+(p−y)\mathbf{b} - \mathbf{y} = \mathbf{r} + (\mathbf{p} - \mathbf{y}). Both p\mathbf{p} and y\mathbf{y} lie on LL, so p−y\mathbf{p} - \mathbf{y} lies on LL and is orthogonal to r\mathbf{r}. The Pythagorean identity gives the equation, and its last term is 00 only when y=p\mathbf{y} = \mathbf{p}.

In plain words Moving away from the foot of the perpendicular adds a second error orthogonal to the first. Squared lengths of orthogonal errors add, so every move along the line away from the foot makes the distance larger.

Example For u=(1,2)\mathbf{u} = (1, 2) and b=(4,3)\mathbf{b} = (4, 3), a point of the line is y=tu\mathbf{y} = t\mathbf{u}, and p−y=(2−t)u\mathbf{p} - \mathbf{y} = (2 - t)\mathbf{u}. The identity becomes

∥b−tu∥2=5+5(2−t)2,\lVert \mathbf{b} - t\mathbf{u} \rVert^2 = 5 + 5(2 - t)^2,

which is smallest, equal to 55, exactly at t=2t = 2. At t=0t = 0 it gives 2525, the squared distance from b\mathbf{b} to the origin. At t=3t = 3 the point (3,6)(3, 6) gives b−y=(1,−3)\mathbf{b} - \mathbf{y} = (1, -3), with squared length 10=5+510 = 5 + 5.

Orthogonal matrix

Definition A real n×nn \times n matrix QQ is orthogonal if its columns q1,…,qn\mathbf{q}_1, \dots, \mathbf{q}_n form an orthonormal basis of Rn\mathbb{R}^n. Since the (i,j)(i, j) entry of Q⊤QQ^{\top}Q is qi⋅qj\mathbf{q}_i \cdot \mathbf{q}_j, this is the same as

Q⊤Q=I.Q^{\top}Q = I.

Because QQ is square, it follows that QQ is invertible with Q−1=Q⊤Q^{-1} = Q^{\top}, so QQ⊤=IQQ^{\top} = I as well. For the orthonormal basis B\mathcal{B} formed by its columns, coordinates are read off and rebuilt by

[b]B=Q⊤b,b=Q [b]B.[\mathbf{b}]_{\mathcal{B}} = Q^{\top}\mathbf{b}, \qquad \mathbf{b} = Q\,[\mathbf{b}]_{\mathcal{B}}.

Multiplication by QQ keeps dot products and lengths, since (Qx)⋅(Qy)=x⊤Q⊤Qy=x⋅y(Q\mathbf{x}) \cdot (Q\mathbf{y}) = \mathbf{x}^{\top}Q^{\top}Q\mathbf{y} = \mathbf{x} \cdot \mathbf{y}. Despite the name, the columns must be orthonormal, and orthogonal columns alone are not enough. An m×nm \times n matrix with orthonormal columns and m>nm > n still satisfies Q⊤Q=InQ^{\top}Q = I_n. But it is not square, so Q⊤Q^{\top} undoes it only from the left, and QQ⊤≠ImQQ^{\top} \ne I_m. Such a matrix is not called an orthogonal matrix.

In plain words An orthogonal matrix lists a new set of perpendicular unit axes as its columns. Its transpose converts standard coordinates into coordinates along those axes, and undoing the matrix costs only a transpose.

Example The matrix

Q=15[3−443]Q = \frac{1}{5}\begin{bmatrix} 3 & -4 \\ 4 & 3 \end{bmatrix}

has columns (35,45)(\frac{3}{5}, \frac{4}{5}) and (−45,35)(-\frac{4}{5}, \frac{3}{5}), each of length 11, with dot product −1225+1225=0-\frac{12}{25} + \frac{12}{25} = 0, so Q⊤Q=IQ^{\top}Q = I. For b=(5,5)\mathbf{b} = (5, 5) the coordinates are Q⊤b=(7,−1)Q^{\top}\mathbf{b} = (7, -1), and indeed 7(35,45)−(−45,35)=(5,5)7(\frac{3}{5}, \frac{4}{5}) - (-\frac{4}{5}, \frac{3}{5}) = (5, 5). By contrast, the matrix MM with columns (1,1)(1, 1) and (1,−1)(1, -1) has orthogonal columns, but M⊤M=2IM^{\top}M = 2I, so it is not an orthogonal matrix. Dividing it by 2\sqrt{2} makes it one.

Check yourself

  1. Project b=(1,5)\mathbf{b} = (1, 5) onto the line spanned by u=(1,1)\mathbf{u} = (1, 1). Give the projection coefficient, the projection, the residual and the distance from b\mathbf{b} to the line.
Show the answer

The dot products are u⋅b=6\mathbf{u} \cdot \mathbf{b} = 6 and u⋅u=2\mathbf{u} \cdot \mathbf{u} = 2, so the coefficient is 33 and the projection is (3,3)(3, 3). The residual is (1,5)−(3,3)=(−2,2)(1, 5) - (3, 3) = (-2, 2), and it is perpendicular to the line, since u⋅(−2,2)=0\mathbf{u} \cdot (-2, 2) = 0. The distance is ∥(−2,2)∥=8=22\lVert (-2, 2) \rVert = \sqrt{8} = 2\sqrt{2}.

  1. The vectors q1=12(1,1,0)\mathbf{q}_1 = \frac{1}{\sqrt{2}}(1, 1, 0), q2=13(1,−1,1)\mathbf{q}_2 = \frac{1}{\sqrt{3}}(1, -1, 1) and q3=16(−1,1,2)\mathbf{q}_3 = \frac{1}{\sqrt{6}}(-1, 1, 2) form an orthonormal basis B\mathcal{B} of R3\mathbb{R}^3. Find [b]B[\mathbf{b}]_{\mathcal{B}} for b=(2,0,1)\mathbf{b} = (2, 0, 1) and check it by rebuilding b\mathbf{b}.
Show the answer

Each coordinate is a dot product with a basis vector,

q1⋅b=22=2,q2⋅b=33=3,q3⋅b=06=0,\begin{aligned} \mathbf{q}_1 \cdot \mathbf{b} &= \frac{2}{\sqrt{2}} = \sqrt{2}, \\[0.4em] \mathbf{q}_2 \cdot \mathbf{b} &= \frac{3}{\sqrt{3}} = \sqrt{3}, \\[0.4em] \mathbf{q}_3 \cdot \mathbf{b} &= \frac{0}{\sqrt{6}} = 0, \end{aligned}

so [b]B=(2,3,0)[\mathbf{b}]_{\mathcal{B}} = (\sqrt{2}, \sqrt{3}, 0). Rebuilding, 2 q1=(1,1,0)\sqrt{2}\,\mathbf{q}_1 = (1, 1, 0) and 3 q2=(1,−1,1)\sqrt{3}\,\mathbf{q}_2 = (1, -1, 1) add to (2,0,1)(2, 0, 1). The third coordinate is 00 because b\mathbf{b} is orthogonal to q3\mathbf{q}_3. The same numbers come from Q⊤bQ^{\top}\mathbf{b}, where QQ is the orthogonal matrix with columns q1,q2,q3\mathbf{q}_1, \mathbf{q}_2, \mathbf{q}_3.

  1. A classmate projects b=(7,1)\mathbf{b} = (7, 1) onto the line spanned by u=(3,4)\mathbf{u} = (3, 4) and uses the coefficient (u⋅b)/∥u∥(\mathbf{u} \cdot \mathbf{b})/\lVert \mathbf{u} \rVert. Find the correct projection and residual, and explain what goes wrong in the classmate’s version.
Show the answer

The dot products are u⋅b=21+4=25\mathbf{u} \cdot \mathbf{b} = 21 + 4 = 25 and u⋅u=25\mathbf{u} \cdot \mathbf{u} = 25, so the coefficient is 11 and the projection is (3,4)(3, 4). The residual (7,1)−(3,4)=(4,−3)(7, 1) - (3, 4) = (4, -3) satisfies u⋅(4,−3)=12−12=0\mathbf{u} \cdot (4, -3) = 12 - 12 = 0, and the distance to the line is 55.

The classmate divides by ∥u∥=5\lVert \mathbf{u} \rVert = 5 instead of ∥u∥2=25\lVert \mathbf{u} \rVert^2 = 25, gets the coefficient 55 and the point (15,20)(15, 20). The difference (7,1)−(15,20)=(−8,−19)(7, 1) - (15, 20) = (-8, -19) has dot product −24−76=−100-24 - 76 = -100 with u\mathbf{u}, so it is not perpendicular to the line and (15,20)(15, 20) is not the closest point. The number 55 is the right coefficient for the unit vector 15(3,4)\frac{1}{5}(3, 4), and five copies of that unit vector do give (3,4)(3, 4). Using it with u\mathbf{u} itself makes the answer ∥u∥\lVert \mathbf{u} \rVert times too long.

How this lesson connects