Mathwords logoMathwords

Projection Matrix — Definition, Formula & Examples

A projection matrix is a square matrix PP that, when multiplied by a vector, gives the orthogonal projection of that vector onto a subspace. Applying PP twice has the same effect as applying it once, meaning P2=PP^2 = P.

A matrix PP is a projection matrix if P2=PP^2 = P (idempotent). It is an orthogonal projection matrix if, additionally, P=PTP = P^T (symmetric). Given a matrix AA whose columns span the target subspace, the orthogonal projection matrix onto the column space of AA is P=A(ATA)1ATP = A(A^T A)^{-1}A^T.

Key Formula

P=A(ATA)1ATP = A(A^T A)^{-1}A^T
Where:
  • PP = The orthogonal projection matrix onto the column space of A
  • AA = Matrix whose columns form a basis for the target subspace
  • ATA^T = Transpose of A
  • (ATA)1(A^T A)^{-1} = Inverse of the Gram matrix, which exists when A has linearly independent columns

How It Works

To project a vector b\mathbf{b} onto the column space of a matrix AA, you compute PbP\mathbf{b} where P=A(ATA)1ATP = A(A^T A)^{-1}A^T. The result b^=Pb\hat{\mathbf{b}} = P\mathbf{b} is the closest point in the column space to b\mathbf{b}. The residual bb^\mathbf{b} - \hat{\mathbf{b}} is orthogonal to every column of AA. This is the geometric heart of least squares regression: when Ax=bA\mathbf{x} = \mathbf{b} has no exact solution, the projection gives the best approximation.

Worked Example

Problem: Find the projection matrix that projects vectors in R² onto the line spanned by a = [1, 2]ᵀ.
Compute AᵀA: Here A is just the column vector a. Compute the dot product.
ATA=[12][12]=5A^T A = \begin{bmatrix}1 & 2\end{bmatrix}\begin{bmatrix}1\\2\end{bmatrix} = 5
Compute (AᵀA)⁻¹: Since AᵀA is a scalar, its inverse is simply 1/5.
(ATA)1=15(A^T A)^{-1} = \frac{1}{5}
Compute P = A(AᵀA)⁻¹Aᵀ: Multiply the column vector by 1/5 by the row vector.
P=15[12][12]=15[1224]P = \frac{1}{5}\begin{bmatrix}1\\2\end{bmatrix}\begin{bmatrix}1 & 2\end{bmatrix} = \frac{1}{5}\begin{bmatrix}1 & 2\\2 & 4\end{bmatrix}
Answer: The projection matrix is P=15[1224]P = \frac{1}{5}\begin{bmatrix}1 & 2\\2 & 4\end{bmatrix}. You can verify: P2=PP^2 = P and PT=PP^T = P.

Why It Matters

Projection matrices are the foundation of least squares solutions. In statistics and data science, every ordinary least squares regression computes a projection of observed data onto the column space of the design matrix. Understanding projections also clarifies concepts like residuals and the hat matrix in regression diagnostics.

Common Mistakes

Mistake: Forgetting to check that the columns of A are linearly independent before computing (AᵀA)⁻¹.
Correction: The formula P = A(AᵀA)⁻¹Aᵀ requires AᵀA to be invertible, which happens only when A has linearly independent columns. If columns are dependent, remove redundant columns first or use the pseudoinverse.