Linear Algebra · Undergraduate

Orthogonal Projections and Orthogonal Bases

Quick answer

An orthogonal set of nonzero vectors is automatically independent, and relative to an orthogonal basis the coordinates of any vector are ratios of dot products, with no row reduction. The same ratios give the orthogonal projection of a vector y onto a subspace W: the sum of its projections onto the orthogonal basis vectors. The error y − ŷ is orthogonal to W, and the Pythagorean theorem then shows that ŷ is the point of W closest to y, which is the idea behind least squares.

What you'll learn

  • Recognize orthogonal and orthonormal sets
  • Find coordinates relative to an orthogonal basis with dot products
  • Project a vector onto a line and onto a subspace
  • Find the distance from a vector to a subspace

Orthogonal sets

A set of vectors is orthogonal when every pair has dot product 00. The standard basis of ℝⁿ is one example; so is

u1=(3,1,1)u2=(−1,2,1)u3=(−12,−2,72)\mathbf{u}_1 = (3, 1, 1) \qquad \mathbf{u}_2 = (-1, 2, 1) \qquad \mathbf{u}_3 = \left(-\tfrac{1}{2}, -2, \tfrac{7}{2}\right)

since u1⋅u2=−3+2+1=0\mathbf{u}_1 \cdot \mathbf{u}_2 = -3 + 2 + 1 = 0, and the other two pairs also give 00.

An orthogonal set of nonzero vectors is automatically linearly independent. If c1u1+⋯+cpup=0c_1\mathbf{u}_1 + \cdots + c_p\mathbf{u}_p = \mathbf{0}, taking the dot product of both sides with uj\mathbf{u}_j kills every term but one, leaving cj uj⋅uj=0c_j\,\mathbf{u}_j \cdot \mathbf{u}_j = 0, so cj=0c_j = 0.

The same move finds coordinates. If y=c1u1+⋯+cpup\mathbf{y} = c_1\mathbf{u}_1 + \cdots + c_p\mathbf{u}_p, dotting with uj\mathbf{u}_j isolates cjc_j:

cj=y⋅ujuj⋅ujc_j = \frac{\mathbf{y} \cdot \mathbf{u}_j}{\mathbf{u}_j \cdot \mathbf{u}_j}

Projecting onto a line

The dot product lesson found the shadow of one vector on another. For a line LL spanned by u\mathbf{u},

y^=projL y=y⋅uu⋅u u\hat{\mathbf{y}} = \text{proj}_L\,\mathbf{y} = \frac{\mathbf{y} \cdot \mathbf{u}}{\mathbf{u} \cdot \mathbf{u}}\,\mathbf{u}

and the leftover y−y^\mathbf{y} - \hat{\mathbf{y}} is orthogonal to u\mathbf{u}. For y=(7,6)\mathbf{y} = (7, 6) and u=(4,2)\mathbf{u} = (4, 2) the ratio is 28+1216+4=2\tfrac{28 + 12}{16 + 4} = 2, so y^=(8,4)\hat{\mathbf{y}} = (8, 4), and the leftover (−1,2)(-1, 2) has dot product −4+4=0-4 + 4 = 0 with u\mathbf{u}. The distance from y\mathbf{y} to the line is ∥(−1,2)∥=5\|(-1, 2)\| = \sqrt{5}.

Projecting y = (7, 6) onto the line through (4, 2) A dashed line through the origin in the direction (4, 2). An arrow reaches y = (7, 6), and a second arrow along the line reaches its projection (8, 4). A dashed segment from (7, 6) to (8, 4) meets the line at a right angle. y 24681012246xy ŷ = (8, 4)
  • line spanned by (4, 2)
Projecting y = (7, 6) onto the line through (4, 2)

Why the projection is the closest point

For a subspace WW with an orthogonal basis u1,…,up\mathbf{u}_1, \ldots, \mathbf{u}_p, the projection adds up the projections onto each basis vector:

y^=y⋅u1u1⋅u1 u1+⋯+y⋅upup⋅up up\hat{\mathbf{y}} = \frac{\mathbf{y} \cdot \mathbf{u}_1}{\mathbf{u}_1 \cdot \mathbf{u}_1}\,\mathbf{u}_1 + \cdots + \frac{\mathbf{y} \cdot \mathbf{u}_p}{\mathbf{u}_p \cdot \mathbf{u}_p}\,\mathbf{u}_p

Dotting y−y^\mathbf{y} - \hat{\mathbf{y}} with any uj\mathbf{u}_j gives y⋅uj−cj uj⋅uj=0\mathbf{y} \cdot \mathbf{u}_j - c_j\,\mathbf{u}_j \cdot \mathbf{u}_j = 0, so the error is orthogonal to every basis vector and therefore to all of WW. Now take any other point w\mathbf{w} in WW. The vector y−w\mathbf{y} - \mathbf{w} splits as (y−y^)+(y^−w)(\mathbf{y} - \hat{\mathbf{y}}) + (\hat{\mathbf{y}} - \mathbf{w}), the first piece orthogonal to WW and the second inside it, so by the Pythagorean theorem

∥y−w∥2=∥y−y^∥2+∥y^−w∥2≥∥y−y^∥2\|\mathbf{y} - \mathbf{w}\|^2 = \|\mathbf{y} - \hat{\mathbf{y}}\|^2 + \|\hat{\mathbf{y}} - \mathbf{w}\|^2 \ge \|\mathbf{y} - \hat{\mathbf{y}}\|^2

Because the error y−y^\mathbf{y} - \hat{\mathbf{y}} is perpendicular to WW, every other point of WW is farther from y\mathbf{y}: the projection is the best approximation to y\mathbf{y} from inside WW.

Worked examples

Common mistakes

Practice problems

  1. Are (1,1,0)(1, 1, 0), (1,−1,0)(1, -1, 0) and (0,0,2)(0, 0, 2) an orthogonal set?

    Answer

    Yes

    Full solution

    The three dot products are 1−1+0=01 - 1 + 0 = 0, 0+0+0=00 + 0 + 0 = 0 and 0+0+0=00 + 0 + 0 = 0.

  2. Find the coordinates of (3,1,4)(3, 1, 4) relative to the basis in exercise 1.

    Answer

    22, 11 and 22

    Full solution

    3+12=2\tfrac{3 + 1}{2} = 2, 3−12=1\tfrac{3 - 1}{2} = 1 and 84=2\tfrac{8}{4} = 2. Check: 2(1,1,0)+(1,−1,0)+2(0,0,2)=(3,1,4)2(1, 1, 0) + (1, -1, 0) + 2(0, 0, 2) = (3, 1, 4).

  3. Find the coordinates of (5,5)(5, 5) relative to the orthogonal basis (1,2)(1, 2), (−2,1)(-2, 1).

    Answer

    33 and −1-1

    Full solution

    5+105=3\tfrac{5 + 10}{5} = 3 and −10+55=−1\tfrac{-10 + 5}{5} = -1.

  4. Project (4,2)(4, 2) onto the line spanned by (1,1)(1, 1).

    Answer

    (3,3)(3, 3)

    Full solution

    4+21+1=3\tfrac{4 + 2}{1 + 1} = 3, so the projection is 3(1,1)3(1, 1).

  5. Find the distance from (4,2)(4, 2) to that line.

    Answer

    2\sqrt{2}

    Full solution

    The error is (4,2)−(3,3)=(1,−1)(4, 2) - (3, 3) = (1, -1), of length 2\sqrt{2}.

  6. Project (1,1,1)(1, 1, 1) onto the xyxy-plane, using the basis e1\mathbf{e}_1, e2\mathbf{e}_2.

    Answer

    (1,1,0)(1, 1, 0)

    Full solution

    The two coefficients are 11 and 11. The error (0,0,1)(0, 0, 1) points straight out of the plane.

  7. Scale (1,2,2)(1, 2, 2) to a unit vector.

    Answer

    (13,23,23)\left(\tfrac{1}{3}, \tfrac{2}{3}, \tfrac{2}{3}\right)

    Full solution

    Its length is 1+4+4=3\sqrt{1 + 4 + 4} = 3.

  8. Project (2,3)(2, 3) onto the line spanned by (1,0)(1, 0).

    Answer

    (2,0)(2, 0)

    Full solution

    Projecting onto the xx-axis keeps the first coordinate and zeroes the second.

  9. If y\mathbf{y} is already in WW, what is its projection onto WW?

    Answer

    y\mathbf{y} itself

    Full solution

    The closest point of WW to a point already in WW is that point, at distance 00. The coordinate formula reproduces y\mathbf{y} exactly.

  10. A student projects (0,1)(0, 1) onto ℝ² using the basis (1,0)(1, 0), (1,1)(1, 1) and the sum-of-projections formula, and gets (0.5,0.5)(0.5, 0.5). What went wrong?

    Hint

    Is the basis orthogonal?

    Answer

    The basis is not orthogonal, so the formula does not apply. The projection is (0,1)(0, 1).

    Full solution

    (1,0)⋅(1,1)=1≠0(1, 0) \cdot (1, 1) = 1 \ne 0. With a non-orthogonal basis the pieces overlap and the sum misses the target. Replacing (1,1)(1, 1) by (0,1)(0, 1), which makes the basis orthogonal, gives (0,0)+(0,1)=(0,1)(0, 0) + (0, 1) = (0, 1).

Frequently asked questions

What is an orthogonal set?

A set of vectors in which every pair has dot product 0. If the vectors are also unit vectors, the set is orthonormal.

Why are orthogonal bases convenient?

The coordinates of y are c_j = (y · u_j)/(u_j · u_j), one dot product each, with no system of equations to solve.

How do you project a vector onto a subspace?

Take an orthogonal basis u₁, …, u_p of the subspace and add the projections of y onto each: ŷ = Σ (y · u_j)/(u_j · u_j) u_j.

Why is the projection the closest point?

The error y − ŷ is orthogonal to the subspace. For any other point w in it, the Pythagorean theorem gives ‖y − w‖² = ‖y − ŷ‖² + ‖ŷ − w‖², which is larger.

Does the projection formula work with any basis?

No. Adding the projections onto each basis vector gives the projection onto the subspace only when the basis is orthogonal.

What to learn next