Euler Hall — free maths guides

Project a vector onto a column space

Set up and solve the normal equations AT A x = AT b and form p = A x. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.

The same idea, with more than one direction

A line was one direction. Now the target is a column space — several directions at once, usually not perpendicular to each other.

The projection ofbb is still the closest point, and the residual is still perpendicular to everything in the space. "Perpendicular to every column" is one matrix equation:

AT(b−Ax^)=0⟹ATA x^=ATb.A^{\mathrm{T}}(b-A\hat{x})=0\qquad\Longrightarrow\qquad A^{\mathrm{T}}A\,\hat{x}=A^{\mathrm{T}}b.

These are the normal equations. Solve them forx^\hat{x}, then setp=Ax^p=A\hat{x}.

Never invertAA. It is usually a rectangle with no inverse. The matrix that gets inverted isATAA^{\mathrm{T}}A, which is square.

WhyATAA^{\mathrm{T}}A is the matrix that works

The residuale=b−Ax^e=b-A\hat{x} must be perpendicular to every column ofAA. That isdd separate conditions, one per column, and they pack into a single equation:ATe=0A^{\mathrm{T}}e=\mathbf{0}.

Substitutingee:

AT(b−Ax^)=0 ⇒ ATb−ATAx^=0.A^{\mathrm{T}}(b-A\hat{x})=\mathbf{0}\ \Rightarrow\ A^{\mathrm{T}}b-A^{\mathrm{T}}A\hat{x}=\mathbf{0}.

Rearrange and you have the normal equations.

Two facts make this usable.ATAA^{\mathrm{T}}A is square n×nn\times n) and symmetric, so it is a system you can actually solve. And whenAA has independent columns,ATAA^{\mathrm{T}}A is invertible — its nullspace is the same asAA's, andAA's nullspace is trivial by assumption. Without independence,ATAA^{\mathrm{T}}A is singular and there is no single closest-point formula of this shape.

WhyATAA^{\mathrm{T}}A and notAATAA^{\mathrm{T}}?AATAA^{\mathrm{T}} ism×mm\times m and its rank isnn, so it is singular wheneverAA has fewer columns than rows — which is the usual case. The order is forced.

One full projection, two directions

Problem. Projectb=[311]b=\begin{bmatrix}3\\1\\1\end{bmatrix} onto the column space ofA=[111001]A=\begin{bmatrix}1&1\\1&0\\0&1\end{bmatrix}.

Solution, set up.

ATA=[2112],ATb=[44].A^{\mathrm{T}}A=\begin{bmatrix}2&1\\1&2\end{bmatrix},\qquad A^{\mathrm{T}}b=\begin{bmatrix}4\\4\end{bmatrix}.

Solve. Subtracting the two equations givesx^1−x^2=0\hat{x}_1-\hat{x}_2=0, sox^1=x^2\hat{x}_1=\hat{x}_2; then3x^1=43\hat{x}_1=4 and both coordinates are43\frac43.

Buildpp.

p=Ax^=43[110]+43[101]=[8/34/34/3].p=A\hat{x}=\tfrac43\begin{bmatrix}1\\1\\0\end{bmatrix}+\tfrac43\begin{bmatrix}1\\0\\1\end{bmatrix}=\begin{bmatrix}8/3\\4/3\\4/3\end{bmatrix}.

Check.e=b−p=[1/3−1/3−1/3]e=b-p=\begin{bmatrix}1/3\\-1/3\\-1/3\end{bmatrix}, andATe=[1/3−1/31/3−1/3]=[00]A^{\mathrm{T}}e=\begin{bmatrix}1/3-1/3\\1/3-1/3\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix} ✓ — perpendicular to both columns at once, which is what "closest point in the plane" means.

Why thisbb and not a nicer one. This column space is the planex2+x3=x1x_2+x_3=x_1, andb=(3,1,1)b=(3,1,1) has1+1=2≠31+1=2\neq3, sobb is genuinely off the plane and the projection is notbb itself. Choosingb=(2,1,1)b=(2,1,1) would have madep=bp=b and taught nothing.

By the end you can
  • Set up and solve the normal equations A^T A x = A^T b and form p = A x
  • Verify the projection by testing that the residual is orthogonal to every column
  • Recognise the orthonormal case where A^T A = I and no inverse is needed
Two questions

(a) ForAA of shape3×23\times2 with independent columns, what is the shape ofATAA^{\mathrm{T}}A and ofPP?

(b) Why isATAA^{\mathrm{T}}A invertible exactly whenAA has independent columns?

Answers

(a)ATAA^{\mathrm{T}}A is2×22\times2;P=A(ATA)−1ATP=A(A^{\mathrm{T}}A)^{-1}A^{\mathrm{T}} is3×33\times3 with rank22.

(b) IfATAx^=0A^{\mathrm{T}}A\hat{x}=\mathbf{0}, then multiplying byx^T\hat{x}^{\mathrm{T}} gives∥Ax^∥2=0\|A\hat{x}\|^2=0, soAx^=0A\hat{x}=\mathbf{0}. With independent columns that forcesx^=0\hat{x}=\mathbf{0}, soATAA^{\mathrm{T}}A has trivial nullspace and is invertible. Dependent columns give a nonzerox^\hat{x} withAx^=0A\hat{x}=\mathbf{0}, hence a nonzero nullspace ofATAA^{\mathrm{T}}A.

Work out where to start — free, no accountAnswer six real questions — free, no account