Hello! Welcome to your next lesson on linear algebra.
In our last lesson, we learned the Gram-Schmidt process, an algorithm that uses projection onto a single vector as a key building block. As we concluded, today we'll generalize that idea significantly. This lesson directly addresses your goal of building a foundation for deep learning and quantum mechanics, as projections are fundamental to both fields—from data compression and model fitting to the measurement process in quantum systems.
Our learning outcome is to compute the orthogonal projection of a vector onto a subspace. We'll move from projecting onto a simple line to projecting onto higher-dimensional subspaces like planes. This concept answers a crucial question: What is the "best approximation" of a vector within a given subspace?
1. The Geometry of Projection
Imagine you're in a 3D room and you shine a flashlight directly down onto the floor. The shadow cast by an object is its projection onto the 2D subspace of the floor. The key idea is that the "projection" is the point on the floor closest to the object.
Mathematically, the orthogonal projection of a vector onto a subspace is the vector in that is closest to . This "closest vector" has a unique and critical property: the vector representing the "error" or "difference," , is orthogonal to the entire subspace .
2. From a Line to a Subspace: Building the General Formula
Let's start by formalizing the projection onto a line using matrix notation, and then we'll expand from there. Professor Gilbert Strang provides a fantastic walkthrough of this entire logical progression, from a 1D line to a general n-D subspace.
15. Projections onto Subspaces
This lecture by Professor Strang from MIT OpenCourseWare will be our guide. We'll watch it in two parts. First, he'll recap projection onto a line, introducing the idea of a projection matrix. Then, he'll generalize this to any subspace.
First, watch from 00:09 to 14:55. This part covers projection onto a 1D subspace (a line) and introduces the projection matrix for this case. Pay attention to how he uses the orthogonality condition a^T * e = 0 to derive the formula. Then, watch from 18:39 to 41:43. This is the core of our lesson. He extends the same logic to a subspace spanned by multiple vectors, which form the columns of a matrix A. The key takeaway is the derivation of the 'normal equations' A^T A x_hat = A^T B and the final formula for the projection matrix.
Let's break down and solidify the crucial formulas from that lecture.
The Core Logic
-
Define the Subspace: Any subspace can be defined as the column space of a matrix , where the columns of form a basis for . Let this basis be .
-
Define the Projection: The projection vector must be in the subspace . This means it can be written as a linear combination of the basis vectors:
where is the vector of unknown coefficients. Our goal is to find .
-
Apply the Orthogonality Condition: The error vector, , must be orthogonal to every vector in . It's sufficient to make it orthogonal to all the basis vectors of .
As Professor Strang showed, this entire system of equations can be written in one elegant matrix equation:
-
Solve for the Coefficients: Rearranging this gives us the famous normal equations:
This is a standard system of linear equations for . If the columns of are linearly independent (which they are for a basis), the matrix is square and invertible. We can solve for :
-
Compute the Projection: Now that we have the coefficients , we can find the projection vector :
This gives us both a method and a formula. The matrix is the projection matrix that projects any vector onto the column space of .
3. A Step-by-Step Recipe and Example
The LibreTexts resource provides a clear, step-by-step recipe for this process. This formalizes the method for computation.
This reading from LibreTexts provides a concise, recipe-style guide to computing orthogonal projections, along with a worked example.
Read the sections titled "Recipe: Compute an Orthogonal Decomposition" and "Corollary 1". The recipe gives you a clear algorithm. Focus on Example 11, which shows a concrete calculation for projection onto a plane in R^3.
Let's summarize the recipe for projecting onto a subspace :
- Find a basis for .
- Create the matrix whose columns are the basis vectors.
- Compute the matrix and the vector .
- Solve the system of equations to find the coefficient vector .
- The projection is .
Test your understanding!
Let be the plane in spanned by the vectors and . Compute the orthogonal projection of the vector onto .
Show answer
-
Form the matrix A:
-
Compute and :
-
Solve for in :
We need to solve .
The inverse of is .
So, . -
Compute the projection :
The orthogonal projection of onto the plane is .
4. The Special Case: Projecting onto an Orthogonal Basis
The general formula can be computationally intensive because of the matrix inversion. However, if our basis for the subspace is orthogonal, the process simplifies dramatically. This is why we spent time on the Gram-Schmidt process in the last lesson!
If the columns of (let's call it for an orthogonal basis) are orthogonal, the matrix becomes a simple diagonal matrix. This means the projection onto the subspace is just the sum of the individual projections onto each orthogonal basis vector.

If is an orthogonal basis for , the projection of onto is:
This formula should look familiar! It's exactly the sum of projection components we used in the Gram-Schmidt process.
If the basis is orthonormal (orthogonal and unit length), it's even simpler. In this case, , so the projection matrix becomes .
Conclusion
Today we have developed a complete framework for projecting a vector onto any subspace. This is a concept of immense practical and theoretical importance.
Key Takeaways:
- The orthogonal projection of a vector onto a subspace is the vector in that is closest to .
- The defining property is that the error vector, , is orthogonal to the subspace .
- For a general subspace with basis matrix , the projection is calculated via the normal equations: solve for , and then find .
- If you have an orthogonal basis for the subspace, the projection simplifies to the sum of the individual projections onto each basis vector, avoiding a complex matrix inversion.
Preview of the Next Lesson:
We now have all the tools we need to solve one of the most common problems in science and engineering: finding the "best fit" solution to an overdetermined system of linear equations. In the next lesson, we will decompose a vector into components parallel and orthogonal to a subspace, which directly leads to the method of least squares, a cornerstone of machine learning, data analysis, and experimental physics.