Projection Onto a Subspace: Normal Equations, Invertibility and the Geometry of Averages

A detailed study of projection onto multidimensional subspaces, including coefficient vectors, normal equations, the invertibility of A transpose A, its nullspace proof, projection onto a plane, and the geometric interpretation of averages and least squares.

Projection Onto a Subspace: Normal Equations, Invertibility and the Geometry of Averages

1. From projection onto a line to projection onto a subspace

Previously, we learned how to project a vector b onto a line through a nonzero vector a:

\[ p=\frac{a^Tb}{a^Ta}a. \]

We now extend this idea to a multidimensional subspace.

Suppose a subspace is spanned by independent vectors

\[ a_1,a_2,\ldots,a_n. \]

Put these vectors into the columns of a matrix:

\[ A=\begin{bmatrix}a_1&a_2&\cdots&a_n\end{bmatrix}. \]

The objective is to find the vector inside this subspace that is closest to a given vector b.


2. Why every vector in the subspace has the form Ax

The learner asked why every vector in a subspace can be represented as Ax.

By definition, the column space of A contains all linear combinations of its columns:

\[ v=x_1a_1+x_2a_2+\cdots+x_na_n. \]

Collect the coefficients into a vector:

\[ x=\begin{bmatrix}x_1\\x_2\\\vdots\\x_n\end{bmatrix}. \]

Matrix multiplication produces exactly this linear combination:

\[ Ax=x_1a_1+x_2a_2+\cdots+x_na_n. \]

Therefore

\[ \boxed{C(A)=\{Ax:x\in\mathbb R^n\}}. \]

The matrix A provides the available building directions, while x provides the coefficients used to combine those directions.


3. What is the purpose of x?

Consider the matrix

\[ A=\begin{bmatrix}1&0\\0&1\\0&0\end{bmatrix}. \]

Its columns span the xy-plane.

However, the matrix itself contains only two basis vectors:

\[ a_1=\begin{bmatrix}1\\0\\0\end{bmatrix},\qquad a_2=\begin{bmatrix}0\\1\\0\end{bmatrix}. \]

The coefficient vector x determines which particular vector in the plane is produced.

For example,

\[ A\begin{bmatrix}3\\4\end{bmatrix}=\begin{bmatrix}3\\4\\0\end{bmatrix}. \]

But

\[ A\begin{bmatrix}-2\\7\end{bmatrix}=\begin{bmatrix}-2\\7\\0\end{bmatrix}. \]

Thus changing x can change both the length and direction of Ax without changing the subspace itself.

For the first example,

\[ \left\|\begin{bmatrix}3\\4\\0\end{bmatrix}\right\|=5. \]

Doubling the coefficients gives

\[ A\begin{bmatrix}6\\8\end{bmatrix}=\begin{bmatrix}6\\8\\0\end{bmatrix}, \]

whose length is 10.

The useful mental model is:

  • A specifies the available directions.
  • x specifies how much of each direction to use.
  • Ax is the actual resulting vector.

4. Difference between x and x-hat

An arbitrary x can produce any vector in the column space of A.

Projection is concerned with one particular choice of coefficients, written

\[ \hat{x}. \]

This is the choice that makes the resulting vector as close as possible to b.

Therefore the projection is

\[ \boxed{p=A\hat{x}}. \]

The learner asked whether A times x-hat gives b.

The answer is: only when b already belongs to the column space of A.

Generally,

\[ A\hat{x}=p\neq b. \]

Instead,

\[ \boxed{b=p+e=A\hat{x}+e}, \]

where e is the perpendicular error.

The distinction is:

\[ Ax=b \]

asks for an exact solution, whereas projection asks for the closest achievable approximation when an exact solution is unavailable.


5. The geometric condition for the closest point

The error between b and its projection is

\[ e=b-A\hat{x}. \]

For the projection to be the closest point in the subspace, this error must be perpendicular to the entire column space of A.

Consequently, it must be perpendicular to every basis vector:

\[ a_1^Te=0,\qquad a_2^Te=0,\qquad\ldots,\qquad a_n^Te=0. \]

The rows of A transpose are precisely the transposes of these column vectors.

Therefore all these equations can be combined into one matrix equation:

\[ \boxed{A^Te=0}. \]

Substitute the expression for e:

\[ \boxed{A^T(b-A\hat{x})=0}. \]

This is the central geometric condition behind projection onto a subspace.


6. Why a perpendicular error gives the closest point

Suppose p is the perpendicular projection of b onto a subspace S, and q is any other vector in S.

Then

\[ b-q=(b-p)+(p-q). \]

The vector b-p is perpendicular to S, while p-q lies inside S.

By the Pythagorean theorem,

\[ \|b-q\|^2=\|b-p\|^2+\|p-q\|^2. \]

Since squared lengths cannot be negative,

\[ \|b-q\|^2\geq\|b-p\|^2. \]

Therefore no other point q can be closer to b than p.

Equality occurs only when q=p.

This explains why orthogonality determines the unique closest projected vector.


7. Deriving the normal equations

Start with

\[ A^T(b-A\hat{x})=0. \]

Expand:

\[ A^Tb-A^TA\hat{x}=0. \]

Rearrange:

\[ \boxed{A^TA\hat{x}=A^Tb}. \]

These are called the normal equations.

They are obtained directly from the requirement that the error must be perpendicular to the target subspace.

The logical sequence is:

Closest point leads to perpendicular error, which leads to zero dot products with every column, which produces the normal equations.


8. Connection to the four fundamental subspaces

Previously, we established that

\[ C(A)^\perp=N(A^T). \]

Since the error e is perpendicular to the column space,

\[ e\in N(A^T). \]

Therefore

\[ A^Te=0. \]

This immediately produces

\[ A^T(b-A\hat{x})=0. \]

Thus projection is a practical application of the orthogonal-complement relationship between the column space and left nullspace.

Every vector b in the output space can be decomposed as

\[ \boxed{b=p+e}, \]

where

\[ p\in C(A),\qquad e\in N(A^T). \]


9. Solving the normal equations

Given

\[ A^TA\hat{x}=A^Tb, \]

if A transpose A is invertible, multiply both sides by its inverse:

\[ (A^TA)^{-1}A^TA\hat{x}=(A^TA)^{-1}A^Tb. \]

Because

\[ (A^TA)^{-1}(A^TA)=I, \]

we obtain

\[ \boxed{\hat{x}=(A^TA)^{-1}A^Tb}. \]

This provides the coefficients needed to construct the closest vector.

The projection is

\[ p=A\hat{x}. \]

Substitution gives

\[ \boxed{p=A(A^TA)^{-1}A^Tb}. \]

Therefore the projection matrix is

\[ \boxed{P=A(A^TA)^{-1}A^T}. \]

So

\[ \boxed{p=Pb}. \]

The three quantities have different meanings:

  • x-hat: coefficients of the best linear combination.
  • p: the actual projected vector.
  • P: the matrix that performs the projection.

10. Understanding the dimensions

Suppose A is an m by n matrix.

Then

\[ A^T:\ n\times m. \]

Consequently,

\[ A^TA:\ n\times n. \]

Even when A is rectangular, A transpose A is square.

The coefficient vector x-hat has n components, while p and b have m components.

The projection matrix has dimensions m by m.

In particular,

\[ \underbrace{A}_{m\times n}\underbrace{(A^TA)^{-1}}_{n\times n}\underbrace{A^T}_{n\times m} \]

produces an m by m matrix.


11. What does invertibility mean here?

The learner asked why A transpose A must be invertible and what invertibility means in this context.

Invertibility means that a transformation can be uniquely reversed.

For example,

\[ M=\begin{bmatrix}2&0\\0&3\end{bmatrix} \]

transforms

\[ \begin{bmatrix}3\\4\end{bmatrix} \]

into

\[ \begin{bmatrix}6\\12\end{bmatrix}. \]

Its inverse is

\[ M^{-1}=\begin{bmatrix}1/2&0\\0&1/3\end{bmatrix}. \]

The inverse recovers the original input uniquely.

For the normal equations, invertibility means we can uniquely recover x-hat from A transpose b:

\[ \hat{x}=(A^TA)^{-1}A^Tb. \]

This gives one unique set of coefficients for the projection.


12. Why dependent columns prevent invertibility

Consider

\[ A=\begin{bmatrix}1&2\\2&4\end{bmatrix}. \]

The second column is twice the first.

Therefore

\[ a_2=2a_1. \]

The columns are dependent because the second column contributes no new direction.

A nonzero vector

\[ x=\begin{bmatrix}2\\-1\end{bmatrix} \]

satisfies

\[ Ax=2a_1-a_2=0. \]

Now compute

\[ A^TA=\begin{bmatrix}5&10\\10&20\end{bmatrix}. \]

Its determinant is

\[ 5(20)-10(10)=0. \]

Therefore it is not invertible.

Furthermore,

\[ A^TA\begin{bmatrix}2\\-1\end{bmatrix}=0. \]

The same redundancy appears in A transpose A.

If the columns are dependent, different coefficient vectors can construct the same projected vector.

The orthogonal projection itself remains unique, but its representation using redundant columns is not unique. The ordinary inverse formula cannot be used in this case.


13. Proof that A and A transpose A have the same nullspace

Strang establishes the important identity

\[ \boxed{N(A^TA)=N(A)}. \]

First suppose

\[ Ax=0. \]

Multiplying by A transpose gives

\[ A^TAx=0. \]

Therefore

\[ N(A)\subseteq N(A^TA). \]

Now prove the reverse direction.

Suppose

\[ A^TAx=0. \]

Multiply on the left by x transpose:

\[ x^TA^TAx=0. \]

Using

\[ x^TA^T=(Ax)^T, \]

we obtain

\[ (Ax)^T(Ax)=0. \]

But this is the squared length of Ax:

\[ \|Ax\|^2=0. \]

A real vector has zero length only when it is the zero vector.

Therefore

\[ Ax=0. \]

Hence

\[ N(A^TA)\subseteq N(A). \]

Combining both directions gives

\[ \boxed{N(A^TA)=N(A)}. \]


14. Why independent columns guarantee invertibility

If the columns of A are independent, then

\[ Ax=0 \]

has only the solution

\[ x=0. \]

Therefore

\[ N(A)=\{0\}. \]

Since the nullspaces are equal,

\[ N(A^TA)=\{0\}. \]

A transpose A is square. A square matrix with a zero-only nullspace has a pivot in every column and is invertible.

Consequently,

\[ \boxed{A^TA\text{ is invertible if and only if the columns of }A\text{ are independent}.} \]

Independence ensures that every basis direction contributes something genuinely new and that the coefficients can be recovered uniquely.


15. Why we cannot cancel A and A transpose in the projection formula

The formula

\[ P=A(A^TA)^{-1}A^T \]

might tempt us to write

\[ (A^TA)^{-1}=A^{-1}(A^T)^{-1}. \]

However, this requires A and A transpose to have ordinary inverses.

A is generally rectangular, so these inverses do not exist.

Although A transpose A may be invertible, that does not make A itself invertible.

Only when A is square and invertible does the projection matrix simplify to the identity matrix, because its column space is then the entire surrounding space.


16. Worked example 4.2 A: Projection onto a line

Strang considers

\[ b=\begin{bmatrix}3\\4\\4\end{bmatrix},\qquad a=\begin{bmatrix}2\\2\\1\end{bmatrix}. \]

Use

\[ p=\frac{a^Tb}{a^Ta}a. \]

Calculate

\[ a^Tb=6+8+4=18 \]

and

\[ a^Ta=4+4+1=9. \]

Therefore

\[ \hat{x}=\frac{18}{9}=2. \]

The projection is

\[ \boxed{p=2a=\begin{bmatrix}4\\4\\2\end{bmatrix}}. \]

The error is

\[ e=b-p=\begin{bmatrix}-1\\0\\2\end{bmatrix}. \]

Check perpendicularity:

\[ a^Te=-2+0+2=0. \]

Thus e is perpendicular to the target line.


17. Worked example 4.2 A: Projection onto a plane

Now enlarge the target from a line to a plane spanned by

\[ a=\begin{bmatrix}2\\2\\1\end{bmatrix},\qquad a^*=\begin{bmatrix}1\\0\\0\end{bmatrix}. \]

Form the matrix

\[ A=\begin{bmatrix}2&1\\2&0\\1&0\end{bmatrix}. \]

Then

\[ A^TA=\begin{bmatrix}9&2\\2&1\end{bmatrix}. \]

Its determinant is

\[ 9-4=5. \]

Therefore

\[ (A^TA)^{-1}=\frac15\begin{bmatrix}1&-2\\-2&9\end{bmatrix}. \]

Using the general projection formula gives

\[ P=A(A^TA)^{-1}A^T=\begin{bmatrix}1&0&0\\0&0.8&0.4\\0&0.4&0.2\end{bmatrix}. \]

Multiply by b:

\[ p^*=Pb=\begin{bmatrix}3\\4.8\\2.4\end{bmatrix}. \]

This is the closest vector in the plane.

The error is

\[ e^*=b-p^*=\begin{bmatrix}0\\-0.8\\1.6\end{bmatrix}. \]

Check the dot products:

\[ a^Te^*=0-1.6+1.6=0 \]

and

\[ (a^*)^Te^*=0. \]

Thus e-star is perpendicular to both basis vectors and consequently perpendicular to the entire plane.


18. Why enlarging the subspace improves the approximation

The original line is contained inside the new plane.

The squared distance from b to the line is

\[ \|e\|^2=(-1)^2+0^2+2^2=5. \]

The squared distance from b to the plane is

\[ \|e^*\|^2=0^2+(-0.8)^2+1.6^2=3.2. \]

Therefore

\[ \|e^*\|<\|e\|. \]

The larger subspace provides more possible vectors and therefore allows a closer approximation in this example.

In general, enlarging a target subspace cannot increase the minimum projection error.


19. The nullspace of a projection matrix

The plane projection error satisfies

\[ Pe^*=0. \]

Why?

Because e-star points completely perpendicular to the plane. It contains no component inside the plane.

Consequently,

\[ C(P)=C(A) \]

and

\[ N(P)=C(A)^\perp=N(A^T). \]

The projection matrix retains the part of an input vector inside the target subspace and sends its perpendicular component to zero.

Two further properties are

\[ \boxed{P^2=P} \]

and

\[ \boxed{P^T=P}. \]

The first means that projecting twice is equivalent to projecting once. The second expresses the symmetry of an orthogonal projection matrix.


20. Worked example 4.2 B: An average is a projection

Suppose three pulse measurements are 70, 80 and 120.

Represent them as

\[ b=\begin{bmatrix}70\\80\\120\end{bmatrix}. \]

We want one constant number x that best represents all three measurements, in the sense of minimizing squared errors.

Every constant approximation has the form

\[ p=x\begin{bmatrix}1\\1\\1\end{bmatrix}. \]

Define

\[ a=\begin{bmatrix}1\\1\\1\end{bmatrix}. \]

All possible constant approximations belong to the line through a.

Therefore finding the best constant is equivalent to projecting b onto this line.

Use

\[ \hat{x}=\frac{a^Tb}{a^Ta}. \]

Calculate

\[ a^Tb=70+80+120=270 \]

and

\[ a^Ta=1+1+1=3. \]

Therefore

\[ \boxed{\hat{x}=90}. \]

The projection is

\[ \boxed{p=\begin{bmatrix}90\\90\\90\end{bmatrix}}. \]

The ordinary arithmetic mean has emerged naturally from the projection formula.

The error is

\[ e=b-p=\begin{bmatrix}-20\\-10\\30\end{bmatrix}. \]

Check orthogonality:

\[ a^Te=-20-10+30=0. \]

This explains geometrically why deviations from the arithmetic mean sum to zero.

The average is the coefficient of the orthogonal projection onto the line of vectors whose entries are all equal.


21. Why the average minimizes squared error

Strang also solves the same problem using calculus.

Define the total squared error:

\[ E(x)=(x-70)^2+(x-80)^2+(x-120)^2. \]

Differentiate:

\[ \frac{dE}{dx}=2(x-70)+2(x-80)+2(x-120). \]

Set the derivative equal to zero:

\[ 6x-540=0. \]

Therefore

\[ x=90. \]

The second derivative is positive:

\[ \frac{d^2E}{dx^2}=6>0. \]

Therefore the result is a minimum.

Both calculus and orthogonal projection produce the same answer.

This provides an introduction to least squares: finding the approximation that minimizes the sum of squared errors.


22. Updating the average recursively

Suppose a fourth measurement of 130 arrives.

The original average was

\[ \bar{x}_{old}=90. \]

Instead of averaging all four measurements from scratch, use

\[ \bar{x}_{new}=\bar{x}_{old}+\frac14(130-\bar{x}_{old}). \]

Therefore

\[ \bar{x}_{new}=90+\frac14(40)=100. \]

More generally, when n observations have already been averaged and a new observation arrives,

\[ \boxed{\bar{x}_{n+1}=\bar{x}_n+\frac{1}{n+1}(x_{new}-\bar{x}_n)}. \]

The old average is adjusted toward the new observation by a fraction of its deviation.

This is a simple example of recursive least squares and incremental computation.


23. Practical significance

Projection is not merely a geometric operation involving lines and planes.

It also provides a mathematical method for finding the best available approximation when an exact solution is impossible.

Examples include fitting models to observations, estimating unknown parameters, analyzing measurement errors, calculating averages and performing least-squares regression.

The underlying idea remains the same: choose the achievable vector closest to the desired vector.


24. Complete projection procedure

Given a matrix A with independent columns and a target vector b:

Step 1: Form the normal equations.

\[ A^TA\hat{x}=A^Tb. \]

Step 2: Find the coefficients.

\[ \hat{x}=(A^TA)^{-1}A^Tb. \]

Step 3: Construct the projection.

\[ p=A\hat{x}. \]

Step 4: Find the error.

\[ e=b-p. \]

Step 5: Verify perpendicularity.

\[ A^Te=0. \]

Alternatively, construct the projection matrix

\[ P=A(A^TA)^{-1}A^T \]

and use

\[ p=Pb,\qquad e=(I-P)b. \]

The distance from b to the column space is

\[ \boxed{\|e\|}. \]


Study progress

This note completes the main teaching material and worked examples of Section 4.2, Projections, in Gilbert Strang's Introduction to Linear Algebra, fifth edition.

The problem set is intentionally deferred until the second reading of the book.

The next section is Section 4.3, Least Squares Approximations.


Note metadata

  • Note type: learning-note
  • Subject: learning-notes
  • Source: Introduction to Linear Algebra, 5th Edition — Section 4.2 Projections

Related notes