Two vectors span a plane in , and a target vector lies off the plane. Which point of the plane is closest to ? Projecting onto each spanning vector separately and adding the results looks natural, but when the spanning vectors are not perpendicular it generally gives the wrong point. This lesson finds the closest point by making the residual perpendicular to the whole plane, packages the answer as a projection matrix, and shows that the answer depends only on the subspace, not on the basis used to describe it. Throughout, a tuple such as stands for a column vector, and all vectors are real with the ordinary dot product.
Key terms
Orthogonal projection onto a subspace
Definition Let be a subspace of and let be a vector in . The orthogonal projection of onto is the unique vector with
It exists and is unique because , so is the part of the orthogonal decomposition . The vector is the residual. If span , the residual condition is for every . The projection onto the zero subspace is . When is an orthogonal basis of , made of nonzero and mutually perpendicular vectors, the separate line projections add,
but for a basis that is not orthogonal this sum is in general not the projection.
In plain words Split into a piece inside the subspace and a piece perpendicular to all of it. The inside piece is the projection.
Example Let be the plane spanned by and , which is the plane , and let . Adding the two line projections gives . This point lies in , but its residual has dot product with , so it is not perpendicular to the plane. The shortcut fails because . The true projection, computed in the next card, is , whose residual is perpendicular to both and .
Normal equations
Definition Let be a real matrix with linearly independent columns , so that has dimension , and let be in . Write the projection as with in . The residual conditions for stack into , that is
These are the normal equations, where normal means perpendicular and refers to the residual. The matrix is invertible. Indeed, if , then , so , and independence of the columns forces . So the coordinate vector is unique, and the projection is the vector of .
In plain words There is one equation per column, and each says that the residual is perpendicular to that column. Solving them gives the coordinates of the projection, and multiplying by gives the projection itself.
Example Let have columns and , and let . Then
The equations and give , so
The residual passes both tests, since and .
Projection matrix
Definition For a real matrix with linearly independent columns, the projection matrix onto is the matrix
and for every in . The inverse is taken of the square matrix , never of itself, which is not even square when . If the columns are orthonormal, then and the formula becomes . To project a single vector it is usually simpler to solve the normal equations than to form .
In plain words The matrix does the whole job at once. It takes any target in and returns its projection onto the subspace.
Example For the same ,
and multiplying out gives
Then , as before. For the new target the same matrix gives , with residual , which is the normal direction of the plane.
Idempotence
Definition A square matrix is idempotent if . Every projection matrix is idempotent and symmetric. With ,
and , because is symmetric and so is its inverse. Conversely, every real square matrix with and is the orthogonal projection onto its own column space. Idempotence alone is not enough. An idempotent matrix that is not symmetric projects along a slanted direction, and some of its residuals are not perpendicular to .
In plain words Projecting a second time changes nothing, because a vector already in the subspace is its own projection. Symmetry is what makes the projection perpendicular rather than slanted.
Example With from the previous card and , the projection satisfies , and the residual satisfies . By contrast, the matrix
has and column space the -axis, but it sends to and leaves the residual , which is not perpendicular to the -axis. The closest point of the -axis to is , not .
Closest vector in a subspace
Definition Let be a subspace of , let be in , and let with residual . For every in ,
Hence , with equality only for . So is the unique vector of closest to , and the distance from to is . The identity is the Pythagorean theorem. Write . Since lies in and lies in , the cross term in the expansion is zero.
In plain words Moving away from inside the subspace adds an error perpendicular to the residual, so every other candidate is farther from .
Example For and the plane , the squared distance is , so the distance is . The shortcut point has and , so its squared distance to is . A direct computation agrees, since has squared length .
Basis independence of a projection
Definition The projection depends only on the subspace and the dot product, not on the basis chosen for . If and are real matrices with linearly independent columns and , then
The reason is uniqueness. Both formulas return a vector of whose residual lies in , and there is only one such vector. The coordinates , by contrast, generally change with the basis. If the spanning list is dependent, then is singular and the formula cannot be used, yet the projection still exists and is unique, while its coordinates in that list are not. One remedy is to remove redundant columns first.
In plain words Different bases describe the same plane with different coordinates, but the closest point of the plane does not depend on how the plane is described.
Example Replace by , so that has columns and and the same column space as . For ,
with solution . The coordinates changed from , but is the same . With the dependent list , , , the coefficient vectors and both produce this same .
Check yourself
- Project onto the plane spanned by and , and find the distance from to the plane.
Show the answer
The spanning vectors are perpendicular, since , so the line projections add. The coefficients are and , which gives . The residual has zero dot product with both and , and the distance is its length .
- Let have columns and , and let . Solve the normal equations, then find the projection of onto , the residual and the distance.
Show the answer
Here
The equations and give and . So and . The residual is perpendicular to both columns, since and , and the distance is . Adding the separate line projections would give , at squared distance from instead of .
- Both matrices below satisfy , and both have the line spanned by as column space. Which one is the orthogonal projection onto that line?
Show the answer
Idempotence cannot decide, since both matrices have it. The matrix is symmetric and equals for , so it is the orthogonal projection. The matrix is not symmetric, and it fails the residual test. It sends to , leaving the residual , whose dot product with is . The matrix sends to , leaving , which is perpendicular to the line. That point is at distance from , closer than the distance to the point chosen by .