Lecture 15 · Projection on subspace
Derive the projection formula and understand why projection gives the best approximation.
On this page
Projections onto subspaces | Gilbert Strang | MIT 18.06 Linear Algebra
Lecture 15 / Total 35 Lectures |Part 2 · Orthogonality and Determinant
Video of this lecture: Bilibili p15 · Projection on subspace ↗(48:51)| MIT OCW official page ↗
Illustration: MIT OCW 18.06SC official lecture summary (CC BY-NC-SA 4.0) and Bilibili classroom video frames (time stamped), about 10 frames per lecture.
Introduction to this lecture
In the previous lecture, orthogonal maps of four basic subspaces were drawn: the null space is orthogonal to the row space, and the left null space is orthogonal to the column space. That is describing the structure of space. This is the first time I use it to solve problems in this lecture - when When there is no solution, use orthogonality to find the “closest” solvable problem and solve it.
What does a system of equations without a solution look like? The most common situation is when there are more equations than unknowns. For example, three data points are used to determine a straight line with only two parameters. The three equations contradict each other, and no straight line passes through these three points at the same time. Since the exact solution does not exist, let’s take a step back and find the best approximation: put the right-hand vector Change to column space, change to column space The nearest vector , then solve . this It’s the “best possible solution”.
Everything that follows starts from the same condition: pointing from the projection point The error vector is perpendicular to the subspace where the projection is located. “Nearest” is a geometric term. Once translated into “error is orthogonal to the subspace”, it becomes a linear equation that can be solved directly. Along this clue, this lecture first projects the vector onto a straight line to obtain three one-dimensional formulas; then projects it onto a plane until Dimension space, get the projection matrix ; Finally, three data points are used to fit a straight line and the formula is pushed to the actual data.

MIT OCW Official Lecture Notes Summary Page 1/3 (18.06SC Lecture 15 Summary, CC BY-NC-SA 4.0).
1. Project to a straight line
Set is a non-zero vector, which forms a straight line passing through the origin, which is a one-dimensional subspace in . given vector , which is usually not on this straight line. Question: Which point on the straight line is far from Recently?
mark the nearest point as , it is vertical foot on a straight line, connecting line At right angles to the straight line. The key to the whole lecture is this right angle. It is not an accidental phenomenon when drawing pictures, but the only condition that can write “nearest” as an equation.
on a straight line, therefore A multiple of:
The problem boils down to finding this number . called on a straight line projection (projection), the error vector is
It is perpendicular to the straight line, that is, perpendicular to the . Use the inner product to express “vertical” to get the central equation of this lecture
Expand:
Both quantities are numbers: is the inner product of two vectors, is The inner product with itself is equal to length squared. So is the ratio of two numbers. This derivation has nothing to do with the dimension. Two-dimensional, three-dimensional, Vidu is the same.
The projection itself is
If we use trigonometry to do the same thing, we need to introduce with the angle of , writing length, sine and cosine all the way, the formula is clunky and not easy to generalize. The inner product absorbs the angle information: already contains effect, but the formula itself only performs inner products and multiplications between vectors, and no corners appear.
This result also has a structural implication: it Split into two pieces,
Among them on a straight line, Orthogonal to the straight line. The two pieces do not overlap each other, and together they are exactly the same as the original . If Originally on a straight line, the error is zero and the projection is itself; The further away from the straight line, The longer. What projection needs to do is to completely peel off this “component orthogonal to the straight line”.
Editor’s note: Why the vertical foot is the closest point can be seen clearly using the Pythagorean theorem. Take another point on the line , then , the two terms on the right are perpendicular to each other, so , as long as It must be better than farther. The orthogonality condition therefore does characterize the closest point.

Video 00:04:53|Approximately corresponding to Section 1 “1. Project to a straight line”.
2. Projection matrix
If you change the parenthetical reading of the formula in the first section, new objects will appear. Move scalar factors to the front of vectors:
The two writing methods are numerically identical, but the meaning of the matrix is different. molecule It is row times column, it is a number; numerator It is a column multiplied by a row. Matrix, the number of rows and columns is equal to of dimensions. Denominator is still a number, so the entire fraction is a matrix, which acts on A projection is produced on it. This matrix is called projection matrix (projection matrix), recorded as :
This formula can be tested with two small experiments. put Replace with : The molecule has one more factor , the projection also becomes , the input doubles and the output doubles, which is consistent with “the further you walk in the same direction, the further you drop your foot.” put Replace with : If the straight line does not change, the projection should not change. The occurrence factor of the molecule in the formula , factors also appear in the denominator , offset up and down, the projection is still the original . This shows that the projection only depends on the line itself and has nothing to do with the length of the vector used to describe the line.
There are three properties worth remembering.
Article 1, The rank of . It’s one column by one row, exactly rank 1 matrix (rank-one matrix) standard shape, that column is the basis of the column space. From this of column space (column space) is The straight line formed by Zhang: Take it as you like , All fall on a straight line. This must be consistent with the definition - the column space of the matrix is “the space that can fall after multiplying by any vector”, and the landing point of the projection can only be that line.
Article 2, is symmetric matrix(symmetric matrix):
because of transposition What you get is itself, the denominator is the number, transposing does not change it.
Article 3, . The reasons are all in one screen: Take it anywhere , It has fallen on the straight line; project the point on the straight line again and it will stay where it is. So for any All , that is . “The square equals itself” is the algebraic way of writing “projecting twice equals projecting once”.
Symmetry and Together, these two items are a sign of whether a matrix is a projection matrix. Subsequent high-dimensional projection matrices must undergo these two checks.
There are now three formulas for the one-dimensional case, they are Prototype of dimension formula:
Pay attention to distinguishing between projections (vector) and projection matrix (Matrix): The latter acts on Only then did I get the former. In the formula, the numerator is a column times a row, and the denominator is a number. It looks like a fraction. In fact, the numerator and denominator cannot be “reduced” to a single number.

Video 00:11:44 | Approximately corresponding to Section 2 “2. Projection Matrix”.

Video 00:14:39 | Approximately corresponding to Section 2 “2. Projection Matrix”.
3. Why projection is needed
Projection is not to make the picture look good, but to solve the problem Possibly unanswerable questions.
when When there are more rows than columns, there are more equations than unknowns, there are too many conditions, and they usually contradict each other. It’s clear from the column view: always is a linear combination of the columns, so regardless of How to get it? all fall in column space inside; while Generally not in this space. request , which is equivalent to requiring a certain vector in the column space to be exactly equal to the vector outside the column space. , this can’t be done.
If you cannot meet the precise requirements, modify the requirements: Zhong Zhao Li nearest vector , then solve
This equation must have a solution because It is originally constructed from vectors in column space. solved Not the solution to the original equation - which has no solution at all - but the “best possible solution”. Adding a hat to the head is just to distinguish it from the exact solution that does not exist. And The way to find it is to put Project to column space on. In other words, is “use This form can really be put together and separated from the The most recent” vector.
So the value of projection is that it replaces an unsolvable problem with a problem that has a solution and is as close to the original problem as possible. This idea will be developed in the next lecture into least squares (least squares): The so-called “best” in data fitting is defined by this projection.
The order of reasoning here is worth remembering: first admit that the original equation is unsolvable, then ask “which solvable problem is closest to it”, and finally use the projection formula. There are problems to be solved first, then there are tools. To put it another way, fall on The part other than It cannot be eliminated; what the projection does is to identify this part separately, put it aside, and leave the rest to Go for an exact match. One-dimensional rectilinear projection is just the simplest training ground. The real use case is column space.
4. Projection to the plane: general subspace
Now move up to three dimensions: given a plane passing through the origin and a vector outside the plane , ask for projection on plane .
To do the calculation, you must first describe the plane. The most natural description is to give a set of basis: take two linearly independent vectors in the plane and . They do not have to be orthogonal, as long as they are linearly independent, all their linear combinations will cover this plane. Arrange these two vectors into a matrix by columns
The plane is column space . This step translates the geometric problem into a matrix problem: projection to the plane is projection to , and generalize from two columns to Columns don’t require any new ideas.
Projection point in the plane, so it is the combination of two columns:
Instead of Write it down all the way, why not memorize it : Coefficients are packed into vectors , basis vectors are packed into matrices , the combination is written as a matrix multiplication. In this way, whether the plane consists of two columns or The columns are spread, and the shapes of the formulas are exactly the same. This is also the introduction of the matrix. intention.
What needs to be done is still to find the combination coefficient . if happens to be already in column space, the projection is itself, the error is zero; but in general the error
Not zero. As in one dimension, the key fact is is the closest point, so perpendicular to the entire plane. Perpendicular to a plane means perpendicular to every vector in the plane, specifically perpendicular to the two basis vectors:
There are two unknowns, and there are exactly two conditions. The number of equations is equal to the number of unknowns. This is a natural extension of the one-dimensional equation.
Stack the two equations and write them into a matrix. The two lines of are exactly with , so the two equations merge into one:
Use it to check the one-dimensional degradation case: if only one column , the above formula is , which is exactly the central equation of the first section. It can be seen that there is only one equation for “projection to subspace”, and the only difference between one-dimensional and high-dimensional is There are several columns.
This equation can also be mapped to four basic subspaces. What is said fall on in the zero space, that is, of left null space(left nullspace). We already know from the previous lecture that left null space and column space are mutually exclusive orthogonal complement(orthogonal complement):
So” Belongs to the left null space “AND” “Perpendicular to the column space” is the same sentence. The equation that took half a page to write out is exactly the right angle in geometry. The orthogonal relationship between the four subspaces ensures that it will not be calculated incorrectly.
Untie the brackets and get the core equation of the projection problem
is matrix, is square array; on the plane , so there are two equations and two unknowns. In one-dimensional case It’s just a number, so you can just divide it; now it’s a matrix, you can’t divide it, you have to invert it. As long as the two columns are linearly independent (this is the condition for them to serve as the basis of the plane), It is reversible and the inverse matrix exists; this also explains why it appears in high-dimensional formulas , while only the denominator appears in the one-dimensional formula.

MIT OCW Official Lecture Notes Summary Page 2/3 (18.06SC Lecture 15 Summary, CC BY-NC-SA 4.0).

Video 00:31:45 | Approximately corresponding to Section 4 “4. Projection to the plane: general subspace”.
5. Three formulas for general situations
According to the three lines of one dimension, write Three dimensions:
The second article just puts Substitute : It is originally the “column combination coefficient”. After calculating the coefficient, the projection is naturally determined by Get it by multiplying it. Article 3 The previous string of matrices is packed into one matrix, which is the projection matrix . Contrast one-dimensional , the structure is exactly the same, except that the number Replaced with matrix , division is replaced by inversion.
It’s worth checking the dimensions of each part. is , is , so is The square matrix of can be inverted; is vector, so Also , exactly combination coefficient. is , return to the original dimensional space, the projection point must be like this. finally put from Delivery dimension, it is matrix. one dimensional time arbitrary, , these dimensions degenerate into the relationship between numbers, scalars and a single matrix, which seems to be the formulas in the first section.
This formula can easily lead to an impulse: Since there is an “inverse product” formula, why not just use split into ? Then the product becomes
The projection matrix becomes the identity matrix, which is obviously wrong. What’s wrong? Wrong It’s not a square matrix, it has no inverse at all. The premise of our entire question is exactly More rows than columns, tall and thin, with only a few columns but many rows. It is indeed a square matrix, and it is indeed reversible, but This whole cannot be dismantled. If it is dismantled, it will use something that does not exist. . So the formula has to stay like this.
But this “wrong” happens to be true in one situation: if is a square matrix and reversible, its column space is the entire , no need to do anything when projecting to the whole space. It should have been the identity matrix . At this time exists, the above offset is legal, Exactly the right answer. our This is not the case, so it cannot be offset.
High-dimensional projection matrices also satisfy those two properties. Symmetry:
The last step was used is a symmetric matrix, and its inverse is also symmetric. It is a series of beautiful offsets:
middle Adjacent to its inverse, multiplied by it is the identity matrix, and the whole string is just the beginning and the end. The geometric interpretation is the same as in one dimension: the first projection sends the vector into column space, and the second projection falls on a point in column space and does not move anymore.

Video 00:38:07 | Approximately corresponding to Section 5 “5. Three formulas for general situations”.

Video 00:39:05 | Approximately corresponding to Section 5 “5. Three formulas for general situations”.
6. Fit a straight line to the data
Finally, apply the formula to specific data. There are three data points: time , time , time . here is the horizontal axis (time), is the ordinate of the data point. The three points are not collinear, so we need to find a straight line in the plane , making it closest to these three points as a whole.
A straight line has only two parameters: intercept with slope . If it passes through three points exactly, it must simultaneously satisfy
Three equations, two unknowns, no solution, that is, no straight line passes through these three points at the same time. It will be different if you change the data: if the third observation value is not Rather , the three points are exactly collinear, and the system of equations has a solution immediately. Exactly These three numbers make the problem unsolvable.
Write the system of equations as , see clearly which part is the matrix, which part is the unknown, and which part is the right end:
The first column is all , corresponding to the constant term ;The second column is The value of , corresponding to the slope . this The matrix is a typical example of a “tall and thin” matrix: three equations, two unknowns. Arrange the three observations vertically, which is the right-hand vector .
Since If there is no solution, change the solution , among which is in column space projection on. The vectors in are all shaped like , When all real numbers are taken, they are spread out into a plane passing through the origin; and Not in this plane. Substitute into the core equation
Specifically, it is
The left side is a coefficient matrix as System of equations, the right side is a two-dimensional vector, solve The best straight line is obtained. The three components of are the straight line in The value at; The three components of are the vertical deviations of the three data points from the straight line. The set of coefficients selected by the projection makes all three deviations as small as possible instead of making one of them zero.
This lecture stops at setting up the equations: all derivation is done using letters, and the solution of specific numerical values is left to the next lecture. But the structure is clear: a The system of unsolvable equations is replaced by A system of solved equations , the bridge between the two is Arrive projection. This substitution method is applicable as long as the number of equations exceeds the number of unknowns.

Video 00:43:58 | Approximately corresponding to Section 6 “6. Fitting a straight line with data”.

MIT OCW Official Lecture Notes Summary Page 3/3 (18.06SC Lecture 15 Summary, CC BY-NC-SA 4.0).
Summary of this lecture
- projection (projection) solves the problem of “finding the point closest to the given vector in the subspace”, and its criterion is the error vector orthogonal to the entire subspace.
- Project to Spreading Straight Lines: Central Equation , the solution is , projected as .
- projection matrix is matrix, rank , the column space is the straight line; it satisfies with .
- put Doubling doubles the projection; When doubled, the projection remains unchanged because factors appear in the numerator and denominator. They cancel each other out and the straight line itself remains unchanged.
- The motivation for needing projection is: When there are more equations than unknowns, there is usually no solution. can only fall in the column space, so the closest one in the column space is used instead of , modified .
- Projected to the general column space: the error is orthogonal to each column, we get , that is ; is Square array.
- with They are two ways of saying the same thing, and the projection equation just writes this orthogonal relationship.
- three Dimension formula: , , ;cannot be disassembled , because Not a phalanx. If Reversible square matrix, is the correct answer.
- The dimensional projection matrix also satisfies with , the latter consists of the middle Can be obtained by canceling it with its inverse matrix.
- Fit three points , , straight line given The system of unsolvable equations needs to be solved of .
keywords
| English | Chinese | One sentence explanation |
|---|---|---|
| projection | projection | The point in the subspace closest to the given vector, the error is orthogonal to the subspace |
| projection matrix | projection matrix | Send any vector to a matrix on a subspace , satisfy , |
| error vector | error vector | , perpendicular to the target subspace in the projection problem |
| symmetric matrix | symmetric matrix | satisfy matrix, the projection matrix must be symmetric |
| rank-one matrix | rank 1 matrix | The matrix obtained by multiplying one column by one row appears when projected onto a straight line |
| column space | column space | All linear combinations of each column of the matrix, the target space of the projection |
| left nullspace | left null space | the null space of , orthogonal to the column space |
| orthogonal complement | orthogonal complement | All vectors orthogonal to every vector in a given subspace |
| least squares | least squares | A complete set of methods for dealing with systems of unsolvable equations and finding the best approximation using projection |
| line fitting | straight line fitting | use Approximate a set of data points and derive |
Machine-assisted translation · Read Chinese original
