Skip to content
VidiMaster it, module by module
Module 4/Projections & Least Squares

Orthogonal Projections & the Orthogonal Complement

Every vector x∈Rn\mathbf{x}\in\mathbb{R}^n splits uniquely as x=x∥+x⊥\mathbf{x}=\mathbf{x}_{\parallel}+\mathbf{x}_{\perp}: a part x∥=proj⁡Vx\mathbf{x}_{\parallel}=\operatorname{proj}_V\mathbf{x} lying in a subspace VV and a part x⊥\mathbf{x}_{\perp} orthogonal to it. This lesson builds that decomposition from an orthonormal basis, turns it into the symmetric projection matrix P=QQT=A(ATA)−1ATP=QQ^{T}=A(A^{T}A)^{-1}A^{T}, measures the distance from x\mathbf{x} to VV as ∥x−proj⁡Vx∥\|\mathbf{x}-\operatorname{proj}_V\mathbf{x}\|, and relates the orthogonal complement V⊥V^{\perp} to VV through dim⁡V+dim⁡V⊥=n\dim V+\dim V^{\perp}=n and im⁡(A)⊥=ker⁡(AT)\operatorname{im}(A)^{\perp}=\ker(A^{T}).

Before you start — give these a try

Attempting first primes your brain for the lesson — even if you miss. Nothing is graded or saved; it's just a warm-up.

Let V⊆R3V\subseteq\mathbb{R}^3 be the plane spanned by the orthogonal vectors v1=(1,−2,1)\mathbf{v}_1=(1,-2,1) and v2=(1,1,1)\mathbf{v}_2=(1,1,1). Compute proj⁡Vx\operatorname{proj}_V\mathbf{x} for x=(2,1,3)\mathbf{x}=(2,1,3).

With the same plane V=span⁡{(1,−2,1),(1,1,1)}V=\operatorname{span}\{(1,-2,1),(1,1,1)\} and x=(2,1,3)\mathbf{x}=(2,1,3), find the distance from x\mathbf{x} to VV, i.e. ∥x−proj⁡Vx∥\|\mathbf{x}-\operatorname{proj}_V\mathbf{x}\|. Give the answer to 3 decimals.

What you’ll be able to do

  • State Definition 8.8 of the orthogonal complement V⊥={x∈Rn:x⋅v=0 for all v∈V}V^{\perp}=\{\mathbf{x}\in\mathbb{R}^n:\mathbf{x}\cdot\mathbf{v}=0\text{ for all }\mathbf{v}\in V\}, and use Lemma 8.3 to test membership by checking orthogonality against a basis of VV.
  • Use Theorem 8.6 to split any x∈Rn\mathbf{x}\in\mathbb{R}^n uniquely as x=x∥+x⊥\mathbf{x}=\mathbf{x}_{\parallel}+\mathbf{x}_{\perp} with x∥=proj⁡Vx∈V\mathbf{x}_{\parallel}=\operatorname{proj}_V\mathbf{x}\in V and x⊥∈V⊥\mathbf{x}_{\perp}\in V^{\perp}, and explain why the projection is unique.
  • Compute proj⁡Vx\operatorname{proj}_V\mathbf{x} from an orthonormal or orthogonal basis (Remark 8.5), and assemble the symmetric projection matrix P=QQT=A(ATA)−1ATP=QQ^{T}=A(A^{T}A)^{-1}A^{T} (Theorem 8.8).
  • Apply Theorem 8.7, ∥proj⁡Vx∥≤∥x∥\|\operatorname{proj}_V\mathbf{x}\|\le\|\mathbf{x}\|, and compute the distance from a vector to a subspace as ∥x−proj⁡Vx∥\|\mathbf{x}-\operatorname{proj}_V\mathbf{x}\|.
  • Use the structure of V⊥V^{\perp} -- dim⁡V+dim⁡V⊥=n\dim V+\dim V^{\perp}=n and (V⊥)⊥=V(V^{\perp})^{\perp}=V (Theorem 8.9) -- together with im⁡(A)⊥=ker⁡(AT)\operatorname{im}(A)^{\perp}=\ker(A^{T}) (Theorem 8.10) and ker⁡A={0}⇒ATA\ker A=\{\mathbf{0}\}\Rightarrow A^{T}A invertible (Corollary 8.1).

In your course

· MATH2015 · Linear Algebra & Probability
§8.3 Orthogonal projections
  • Definition 8.8Orthogonal to a subspace; orthogonal complement
    x\mathbf{x} is orthogonal to VV if x⋅v=0\mathbf{x}\cdot\mathbf{v}=0 for all v∈V\mathbf{v}\in V; then V⊥={x∈Rn:x⋅v=0 for all v∈V}V^{\perp}=\{\mathbf{x}\in\mathbb{R}^n:\mathbf{x}\cdot\mathbf{v}=0\ \text{for all }\mathbf{v}\in V\} is the orthogonal complement.
  • Lemma 8.2The orthogonal complement is a subspace
    V⊥V^{\perp} is itself a vector subspace of Rn\mathbb{R}^n.
  • Lemma 8.3Orthogonality tested on a basis
    Given a basis v1,…,vk\mathbf{v}_1,\dots,\mathbf{v}_k of VV, x∈V⊥\mathbf{x}\in V^{\perp} iff x⋅vi=0\mathbf{x}\cdot\mathbf{v}_i=0 for i=1,…,ki=1,\dots,k.
  • Theorem 8.6Orthogonal projection (existence and uniqueness)
    Every x\mathbf{x} is uniquely x=x∥+x⊥\mathbf{x}=\mathbf{x}_{\parallel}+\mathbf{x}_{\perp} with x∥=proj⁡Vx∈V\mathbf{x}_{\parallel}=\operatorname{proj}_V\mathbf{x}\in V and x⊥∈V⊥\mathbf{x}_{\perp}\in V^{\perp}; the map PVP_V is linear.
  • Remark 8.5Projection via an orthonormal/orthogonal basis
    proj⁡Vx=∑i(x⋅ui)ui\operatorname{proj}_V\mathbf{x}=\sum_i(\mathbf{x}\cdot\mathbf{u}_i)\mathbf{u}_i for an orthonormal basis, or ∑ix⋅vi∥vi∥2vi\sum_i\frac{\mathbf{x}\cdot\mathbf{v}_i}{\|\mathbf{v}_i\|^{2}}\mathbf{v}_i for an orthogonal basis.
  • Theorem 8.7Norm inequality for the projection
    ∥proj⁡Vx∥≤∥x∥\|\operatorname{proj}_V\mathbf{x}\|\le\|\mathbf{x}\|, with equality iff x∈V\mathbf{x}\in V.
  • Theorem 8.8Matrix of an orthogonal projection
    For an orthonormal basis Q=[u1 ⋯ uk]Q=[\mathbf{u}_1\,\cdots\,\mathbf{u}_k], P=QQTP=QQ^{T} is the symmetric projection matrix; for general independent columns AA it is P=A(ATA)−1ATP=A(A^{T}A)^{-1}A^{T}.
  • Theorem 8.9Properties of the orthogonal complement
    V∩V⊥={0}V\cap V^{\perp}=\{\mathbf{0}\}, dim⁡V+dim⁡V⊥=n\dim V+\dim V^{\perp}=n, and (V⊥)⊥=V(V^{\perp})^{\perp}=V.
  • Theorem 8.10Orthogonal complement of an image
    For any matrix AA, im⁡(A)⊥=ker⁡(AT)\operatorname{im}(A)^{\perp}=\ker(A^{T}).
  • Theorem 8.11Projection onto a column space (general basis)
    If the columns of AA are linearly independent, the projection onto im⁡(A)\operatorname{im}(A) is A(ATA)−1ATxA(A^{T}A)^{-1}A^{T}\mathbf{x}, obtained from the normal equations ATA c=ATxA^{T}A\,\mathbf{c}=A^{T}\mathbf{x}.
  • Corollary 8.1ATAA^{T}A is invertible for independent columns
    If ker⁡A={0}\ker A=\{\mathbf{0}\} (the columns of AA are linearly independent), then ATAA^{T}A is invertible.
  • Example 8.6Projection onto a plane in R3\mathbb{R}^3
    For V=span⁡{(1,−2,1),(1,1,1)}V=\operatorname{span}\{(1,-2,1),(1,1,1)\} and x=(1,0,0)\mathbf{x}=(1,0,0), proj⁡Vx=(12,0,12)\operatorname{proj}_V\mathbf{x}=(\tfrac12,0,\tfrac12) and P=[1/201/20101/201/2]P=\begin{bmatrix}1/2&0&1/2\\0&1&0\\1/2&0&1/2\end{bmatrix}.
The course's Theorem 8.8 states the projection matrix as P=QQTP=QQ^{T} for an orthonormal basis QQ; the equivalent general form P=A(ATA)−1ATP=A(A^{T}A)^{-1}A^{T} (for any linearly independent columns AA, with ATAA^{T}A invertible by Corollary 8.1) reduces to QQTQQ^{T} when the columns are orthonormal, and is developed around Theorem 8.11. Theorem 8.11 and Corollary 8.1 fall just past the end of the supplied §8.3 excerpt; their statements here follow the course's standard development. All projections, projection matrices, and distances were recomputed with numpy; OCR'd numerals in the source were not trusted.
1

The orthogonal complement $V^{\perp}$

A vector x∈Rn\mathbf{x}\in\mathbb{R}^n is orthogonal to a subspace VV when it is perpendicular to every vector of VV, i.e. x⋅v=0\mathbf{x}\cdot\mathbf{v}=0 for all v∈V\mathbf{v}\in V (Definition 8.8). Collecting all such vectors gives the orthogonal complement V⊥={x∈Rn:x⋅v=0 for all v∈V},V^{\perp}=\{\mathbf{x}\in\mathbb{R}^n:\mathbf{x}\cdot\mathbf{v}=0\text{ for all }\mathbf{v}\in V\}, which is itself a subspace (Lemma 8.2). Checking orthogonality against infinitely many v∈V\mathbf{v}\in V sounds hopeless, but Lemma 8.3 rescues us: x∈V⊥\mathbf{x}\in V^{\perp} iff x⋅vi=0\mathbf{x}\cdot\mathbf{v}_i=0 for each vector vi\mathbf{v}_i of a basis of VV, because any v=c1v1+⋯+ckvk\mathbf{v}=c_1\mathbf{v}_1+\cdots+c_k\mathbf{v}_k then gives x⋅v=∑ici(x⋅vi)=0\mathbf{x}\cdot\mathbf{v}=\sum_i c_i(\mathbf{x}\cdot\mathbf{v}_i)=0 by linearity. So a membership test in V⊥V^{\perp} is just finitely many dot products.

2

The orthogonal projection: a unique splitting

Theorem 8.6 is the heart of the section: for any subspace V⊆RnV\subseteq\mathbb{R}^n, every x\mathbf{x} decomposes uniquely as x=x∥+x⊥,x∥∈V,  x⊥∈V⊥.\mathbf{x}=\mathbf{x}_{\parallel}+\mathbf{x}_{\perp},\qquad \mathbf{x}_{\parallel}\in V,\ \ \mathbf{x}_{\perp}\in V^{\perp}. The in-subspace part x∥\mathbf{x}_{\parallel} is the orthogonal projection proj⁡Vx\operatorname{proj}_V\mathbf{x}, and the leftover x⊥=x−proj⁡Vx\mathbf{x}_{\perp}=\mathbf{x}-\operatorname{proj}_V\mathbf{x} is the residual. To compute it, take a basis of VV and demand that x⊥\mathbf{x}_{\perp} be orthogonal to each basis vector; this pins the coefficients down exactly. With an orthonormal basis u1,…,uk\mathbf{u}_1,\dots,\mathbf{u}_k the answer is clean (Remark 8.5): proj⁡Vx=(x⋅u1)u1+⋯+(x⋅uk)uk,\operatorname{proj}_V\mathbf{x}=(\mathbf{x}\cdot\mathbf{u}_1)\mathbf{u}_1+\cdots+(\mathbf{x}\cdot\mathbf{u}_k)\mathbf{u}_k, and for a merely orthogonal basis v1,…,vk\mathbf{v}_1,\dots,\mathbf{v}_k each term is divided by ∥vi∥2\|\mathbf{v}_i\|^{2}: proj⁡Vx=∑ix⋅vi∥vi∥2vi\operatorname{proj}_V\mathbf{x}=\sum_i\frac{\mathbf{x}\cdot\mathbf{v}_i}{\|\mathbf{v}_i\|^{2}}\mathbf{v}_i. The map x↦proj⁡Vx\mathbf{x}\mapsto\operatorname{proj}_V\mathbf{x} is linear.

3

The projection matrix $P$

Because PVP_V is linear, it is multiplication by a matrix. Writing each term of the orthonormal formula as (x⋅ui)ui=uiuiTx(\mathbf{x}\cdot\mathbf{u}_i)\mathbf{u}_i=\mathbf{u}_i\mathbf{u}_i^{T}\mathbf{x} and summing gives Theorem 8.8: with Q=[ u1  ⋯  uk ]Q=[\,\mathbf{u}_1\;\cdots\;\mathbf{u}_k\,] (orthonormal columns), proj⁡Vx=Px,P=QQT.\operatorname{proj}_V\mathbf{x}=P\mathbf{x},\qquad P=QQ^{T}. The matrix PP is symmetric (PT=PP^{T}=P) and idempotent (P2=PP^{2}=P) -- projecting twice does nothing new, since the first projection already lands in VV. If your basis is linearly independent but not orthonormal, assemble it as the columns of AA and use the general formula P=A(ATA)−1AT,P=A(A^{T}A)^{-1}A^{T}, which is well defined because ker⁡A={0}\ker A=\{\mathbf{0}\} makes ATAA^{T}A invertible (Corollary 8.1). When the columns happen to be orthonormal, ATA=IA^{T}A=I and this collapses back to QQTQQ^{T}. In practice one solves the normal equations ATA c=ATxA^{T}A\,\mathbf{c}=A^{T}\mathbf{x} for the coordinates c\mathbf{c} and sets proj⁡Vx=Ac\operatorname{proj}_V\mathbf{x}=A\mathbf{c}.

4

Closest point, distance, and $\operatorname{im}/\ker$

The projection is the closest point of VV to x\mathbf{x}: since x−proj⁡Vx\mathbf{x}-\operatorname{proj}_V\mathbf{x} is orthogonal to VV, Pythagoras gives ∥x∥2=∥proj⁡Vx∥2+∥x⊥∥2\|\mathbf{x}\|^{2}=\|\operatorname{proj}_V\mathbf{x}\|^{2}+\|\mathbf{x}_{\perp}\|^{2}, so ∥proj⁡Vx∥≤∥x∥\|\operatorname{proj}_V\mathbf{x}\|\le\|\mathbf{x}\| with equality iff x∈V\mathbf{x}\in V (Theorem 8.7), and the distance from x\mathbf{x} to VV is ∥x−proj⁡Vx∥\|\mathbf{x}-\operatorname{proj}_V\mathbf{x}\|. Structurally, VV and V⊥V^{\perp} are complementary partners (Theorem 8.9): V∩V⊥={0}V\cap V^{\perp}=\{\mathbf{0}\}, dim⁡V+dim⁡V⊥=n\dim V+\dim V^{\perp}=n, and (V⊥)⊥=V(V^{\perp})^{\perp}=V -- all immediate once you note V=im⁡(PV)V=\operatorname{im}(P_V), V⊥=ker⁡(PV)V^{\perp}=\ker(P_V) and apply rank--nullity. Finally, orthogonal complements connect to linear maps through Theorem 8.10: im⁡(A)⊥=ker⁡(AT),\operatorname{im}(A)^{\perp}=\ker(A^{T}), since being perpendicular to every column of AA is exactly the condition ATx=0A^{T}\mathbf{x}=\mathbf{0}. This is the backbone of least squares: the residual of the best approximation lies in ker⁡(AT)\ker(A^{T}).

Theorem 8.6 — Orthogonal projection

Let VV be a subspace of Rn\mathbb{R}^n. Every x∈Rn\mathbf{x}\in\mathbb{R}^n can be written uniquely as x=x∥+x⊥\mathbf{x}=\mathbf{x}_{\parallel}+\mathbf{x}_{\perp} with x∥∈V\mathbf{x}_{\parallel}\in V and x⊥∈V⊥\mathbf{x}_{\perp}\in V^{\perp}. The component x∥∈V\mathbf{x}_{\parallel}\in V is the orthogonal projection of x\mathbf{x} onto VV, written proj⁡Vx\operatorname{proj}_V\mathbf{x}, and the map PV(x)=proj⁡VxP_V(\mathbf{x})=\operatorname{proj}_V\mathbf{x} is linear.

Intuition. Drop a perpendicular from the tip of x\mathbf{x} onto VV: the foot of that perpendicular is proj⁡Vx\operatorname{proj}_V\mathbf{x}, and what is left over, x⊥=x−proj⁡Vx\mathbf{x}_{\perp}=\mathbf{x}-\operatorname{proj}_V\mathbf{x}, points straight out of VV. Forcing x⊥\mathbf{x}_{\perp} to be orthogonal to every basis vector of VV fixes the coefficients of x∥\mathbf{x}_{\parallel} exactly, which is why the split is unique.
Theorem 8.8 — Matrix of an orthogonal projection

Let u1,…,uk\mathbf{u}_1,\dots,\mathbf{u}_k be an orthonormal basis of VV and Q=[ u1  ⋯  uk ]Q=[\,\mathbf{u}_1\;\cdots\;\mathbf{u}_k\,]. Then proj⁡Vx=Px\operatorname{proj}_V\mathbf{x}=P\mathbf{x} for the symmetric n×nn\times n matrix P=QQTP=QQ^{T}. For any basis assembled as the columns of a matrix AA (linearly independent, not necessarily orthonormal), the same projection matrix is P=A(ATA)−1ATP=A(A^{T}A)^{-1}A^{T}; when the columns are orthonormal ATA=IA^{T}A=I and this reduces to QQTQQ^{T}.

Intuition. Each term (x⋅ui)ui=uiuiTx(\mathbf{x}\cdot\mathbf{u}_i)\mathbf{u}_i=\mathbf{u}_i\mathbf{u}_i^{T}\mathbf{x} in the projection formula is a matrix times x\mathbf{x}; summing them gives QQTxQQ^{T}\mathbf{x}. The matrix PP is symmetric (PT=PP^{T}=P) and idempotent (P2=PP^{2}=P): projecting a second time changes nothing, because the first projection already lives in VV.
Theorem 8.9 — Properties of the orthogonal complement

For a subspace V⊆RnV\subseteq\mathbb{R}^n: (1) V⊥V^{\perp} is a subspace; (2) V∩V⊥={0}V\cap V^{\perp}=\{\mathbf{0}\}; (3) dim⁡V+dim⁡V⊥=n\dim V+\dim V^{\perp}=n; (4) (V⊥)⊥=V(V^{\perp})^{\perp}=V.

Intuition. Writing V=im⁡(PV)V=\operatorname{im}(P_V) and V⊥=ker⁡(PV)V^{\perp}=\ker(P_V) turns these into facts about one linear map: rank--nullity gives the dimension count, and the only vector orthogonal to itself is 0\mathbf{0}. Part (4) says taking the complement twice returns you home -- VV and V⊥V^{\perp} are perfect orthogonal partners that together fill Rn\mathbb{R}^n.
Theorem 8.10 — Orthogonal complement of an image

For any matrix AA, im⁡(A)⊥=ker⁡(AT)\operatorname{im}(A)^{\perp}=\ker(A^{T}). Equivalently, a vector is orthogonal to the column space of AA exactly when it is annihilated by ATA^{T}.

Intuition. A vector x\mathbf{x} is orthogonal to every column of AA precisely when viTx=0\mathbf{v}_i^{T}\mathbf{x}=0 for all ii, i.e. ATx=0A^{T}\mathbf{x}=\mathbf{0}. So the geometric condition 'perpendicular to the column space' is the algebraic condition 'in the kernel of the transpose,' tying the orthogonal complement to a familiar kernel.

Worked examples

Example 1

Let V=span⁡{(3,4)}V=\operatorname{span}\{(3,4)\} be a line in R2\mathbb{R}^2. For x=(5,0)\mathbf{x}=(5,0), find proj⁡Vx\operatorname{proj}_V\mathbf{x}, the residual x−proj⁡Vx\mathbf{x}-\operatorname{proj}_V\mathbf{x}, and the distance from x\mathbf{x} to VV.

  1. 1

    For a line V=span⁡{v}V=\operatorname{span}\{\mathbf{v}\}, Remark 8.5 gives proj⁡Vx=x⋅v∥v∥2 v\operatorname{proj}_V\mathbf{x}=\dfrac{\mathbf{x}\cdot\mathbf{v}}{\|\mathbf{v}\|^{2}}\,\mathbf{v}.

  2. 2

    Compute the pieces: x⋅v=5⋅3+0⋅4=15\mathbf{x}\cdot\mathbf{v}=5\cdot3+0\cdot4=15 and ∥v∥2=32+42=25\|\mathbf{v}\|^{2}=3^{2}+4^{2}=25.

  3. 3

    So proj⁡Vx=1525(3,4)=35(3,4)=(1.8, 2.4)\operatorname{proj}_V\mathbf{x}=\dfrac{15}{25}(3,4)=\dfrac{3}{5}(3,4)=(1.8,\,2.4).

  4. 4

    Residual: x⊥=x−proj⁡Vx=(5−1.8, 0−2.4)=(3.2, −2.4)\mathbf{x}_{\perp}=\mathbf{x}-\operatorname{proj}_V\mathbf{x}=(5-1.8,\,0-2.4)=(3.2,\,-2.4). Check it is orthogonal to v\mathbf{v}: (3.2)(3)+(−2.4)(4)=9.6−9.6=0(3.2)(3)+(-2.4)(4)=9.6-9.6=0.

  5. 5

    Distance to VV: ∥x⊥∥=3.22+2.42=10.24+5.76=16=4\|\mathbf{x}_{\perp}\|=\sqrt{3.2^{2}+2.4^{2}}=\sqrt{10.24+5.76}=\sqrt{16}=4.

Answer. proj⁡Vx=(1.8, 2.4)\operatorname{proj}_V\mathbf{x}=(1.8,\,2.4), residual (3.2, −2.4)(3.2,\,-2.4), and the distance from x\mathbf{x} to the line is 44.
Example 2

(Example 8.6) Let V⊆R3V\subseteq\mathbb{R}^3 be the plane spanned by the orthogonal vectors v1=(1,−2,1)\mathbf{v}_1=(1,-2,1) and v2=(1,1,1)\mathbf{v}_2=(1,1,1). Project x=(1,0,0)\mathbf{x}=(1,0,0) onto VV, and write down the projection matrix PP.

Example 3

Build the projection matrix onto the line V=span⁡{(1,2)}V=\operatorname{span}\{(1,2)\} in R2\mathbb{R}^2 using P=A(ATA)−1ATP=A(A^{T}A)^{-1}A^{T}, verify P2=PP^{2}=P and PT=PP^{T}=P, and use it to project x=(3,1)\mathbf{x}=(3,1).