Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Orthogonal Projections






The Closest Point in a Subspace

The orthogonal projection of a vector onto a subspace is the point in the subspace closest to the original vector. The residual — the difference between the vector and its projection — is perpendicular to the subspace. This orthogonal decomposition is the geometric engine behind least squares, the QR decomposition, and every approximation problem in linear algebra.



Projection onto a Vector

The orthogonal projection of b\mathbf{b} onto a nonzero vector a\mathbf{a} is the point on the line through a\mathbf{a} nearest to b\mathbf{b}:

projab=abaaa\text{proj}_{\mathbf{a}}\mathbf{b} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{a} \cdot \mathbf{a}}\,\mathbf{a}


The scalar c^=abaa\hat{c} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{a} \cdot \mathbf{a}} is the component of b\mathbf{b} in the direction of a\mathbf{a}. The projection c^a\hat{c}\,\mathbf{a} lies on the line through a\mathbf{a}, and the residual bc^a\mathbf{b} - \hat{c}\,\mathbf{a} is orthogonal to a\mathbf{a}:

(bc^a)a=bac^(aa)=baba=0(\mathbf{b} - \hat{c}\,\mathbf{a}) \cdot \mathbf{a} = \mathbf{b} \cdot \mathbf{a} - \hat{c}(\mathbf{a} \cdot \mathbf{a}) = \mathbf{b} \cdot \mathbf{a} - \mathbf{b} \cdot \mathbf{a} = 0


Worked Example


Project b=(3,4,0)\mathbf{b} = (3, 4, 0) onto a=(1,1,1)\mathbf{a} = (1, 1, 1):

c^=3+4+01+1+1=73,projab=73(1,1,1)=(73,73,73)\hat{c} = \frac{3 + 4 + 0}{1 + 1 + 1} = \frac{7}{3}, \quad \text{proj}_{\mathbf{a}}\mathbf{b} = \frac{7}{3}(1, 1, 1) = \left(\frac{7}{3}, \frac{7}{3}, \frac{7}{3}\right)


Residual: bprojab=(23,53,73)\mathbf{b} - \text{proj}_{\mathbf{a}}\mathbf{b} = (\frac{2}{3}, \frac{5}{3}, -\frac{7}{3}). Check: (23)(1)+(53)(1)+(73)(1)=0(\frac{2}{3})(1) + (\frac{5}{3})(1) + (-\frac{7}{3})(1) = 0.
cu·v/‖v‖²·v1×3v1v2v3=proj1×3c·v1c·v2?
The coefficient applied to the direction

The scalar built from the two dot products is being multiplied onto the direction vector, turning a ratio into an actual vector on that line. The projection is always a multiple of the vector being projected onto, never of the one being projected — an asymmetry the formula hides and the picture does not. Follow the whole computation on the vector projection visualizer.

Projecting onto a subspace rather than a single vector is this same step repeated once per basis direction, provided the basis is orthogonal.

Projection Notation

Notation

Projection Notation

A subscript that names the target, the hat's second job in this subject, and the letter P moonlighting for the third time.
The dot and its bars — dot product notation; WW^{\perp}inner product notation; the hat's first job — norm notation.
projab\text{proj}_{\mathbf{a}}\mathbf{b} · projWb\text{proj}_{W}\mathbf{b}
The projection of b onto a; onto W
The subscript names the target — onto what — and the argument is the vector being projected. Onto a vector in Projection onto a Vector above; onto a whole subspace as the sections below build up.
CasesThe subscript's species matters: proja\text{proj}_{\mathbf{a}} lands on a line, projW\text{proj}_{W} on a subspace of any dimension — same word-operator, widening target.
Also writtenPWbP_W\mathbf{b} — the matrix form, once The Projection Matrix below is built; b^\hat{\mathbf{b}} — the hat shorthand of the next entry.
Do not confuseA component index. proja\text{proj}_{\mathbf{a}} is not the “a\mathbf{a}-th” anything — the subscript is a destination, joining the basis-labels of coordinate notation in the family of subscripts that name rather than count.
b^\hat{\mathbf{b}} · x^\hat{\mathbf{x}}
b hat — the projection; x hat — the least-squares solution
The hat's second job in linear algebra: best approximation of. b^\hat{\mathbf{b}} is the closest point to b\mathbf{b} inside WW — the decomposition b=b^+z\mathbf{b} = \hat{\mathbf{b}} + \mathbf{z} of The Orthogonal Decomposition below — and x^\hat{\mathbf{x}} the closest-fit solution in least squares.
CasesTwo hats now live in this subject: the unit-vector hat promises norm one; this one promises nearness. Bold-letter context usually decides — u^\hat{\mathbf{u}} tends to be unit, b^\hat{\mathbf{b}}, x^\hat{\mathbf{x}} tend to be estimates.
Also writtenbW\mathbf{b}_{W} or b\mathbf{b}_{\parallel} in some texts — subscript-flavoured alternatives that free the hat for unit vectors.
Do not confuseStatistics arrived here first: the estimator hat p^\hat{p}, β^\hat{\beta} is this hat — least squares is where the two fields share one convention honestly, not a collision at all.
P=A(ATA)1ATP = A(A^{T}A)^{-1}A^{T}, P2=P\quad P^2 = P
The projection matrix; applying it twice changes nothing
The letter PP's third job on this site: change-of-basis matrix, permutation matrix, and now projection — built in The Projection Matrix below. The equation P2=PP^2 = P is idempotence written as notation: project twice, land in the same place.
CasesOrthogonal projections add symmetry: PT=PP^{T} = P. The pair P2=P=PTP^2 = P = P^{T} characterizes orthogonal projection matrices — two equations serving as a definition.
Also writtenPWP_W with the target as subscript, matching projW\text{proj}_{W}; Π\Pi in texts that need PP elsewhere.
Do not confuseInvertibility. P2=PP^2 = P makes PP singular whenever WRnW \neq \mathbb{R}^n — projection discards the WW^{\perp} component, and discarded information is exactly what an inverse cannot recover.

The Orthogonal Decomposition

Every vector bRn\mathbf{b} \in \mathbb{R}^n decomposes uniquely with respect to a subspace WW as

Orthogonal Decomposition
b=b^+z,b^W, zW\mathbf{b} = \hat{\mathbf{b}} + \mathbf{z}, \quad \hat{\mathbf{b}} \in W, \ \mathbf{z} \in W^\perp

The component b^\hat{\mathbf{b}} is the orthogonal projection of b\mathbf{b} onto WW, and z=bb^\mathbf{z} = \mathbf{b} - \hat{\mathbf{b}} is the perpendicular residual.

The projection b^\hat{\mathbf{b}} is the closest point in WW to b\mathbf{b}. For any other vector wW\mathbf{w} \in W:

bw2=z2+b^w2z2=bb^2\|\mathbf{b} - \mathbf{w}\|^2 = \|\mathbf{z}\|^2 + \|\hat{\mathbf{b}} - \mathbf{w}\|^2 \geq \|\mathbf{z}\|^2 = \|\mathbf{b} - \hat{\mathbf{b}}\|^2


The inequality follows from the Pythagorean theorem: z\mathbf{z} is orthogonal to b^w\hat{\mathbf{b}} - \mathbf{w} (both b^\hat{\mathbf{b}} and w\mathbf{w} are in WW, so their difference is in WW, and zW\mathbf{z} \in W^\perp). The minimum distance z\|\mathbf{z}\| is achieved uniquely at w=b^\mathbf{w} = \hat{\mathbf{b}}.
u1×3u1u2u3proj1×3c·v1c·v2c·v3=u − proj1×3u1c·v1u2c·v2?
What is left after the projection is removed

Subtracting the projection leaves a remainder orthogonal to the direction projected onto. Every vector splits this way, into a part along a subspace and a part perpendicular to it, and the split is unique. That uniqueness is what makes least squares well posed later. Check the remainder's dot product on the vector projection visualizer.

The perpendicular part is the error, and minimising it is what the whole of least squares is about.

Projection with an Orthogonal Basis

When W=Span{u1,,uk}W = \text{Span}\{\mathbf{u}_1, \dots, \mathbf{u}_k\} and the basis {u1,,uk}\{\mathbf{u}_1, \dots, \mathbf{u}_k\} is orthogonal, the projection of b\mathbf{b} onto WW decomposes into independent vector projections:

projWb=u1bu1u1u1+u2bu2u2u2++ukbukukuk\text{proj}_W \mathbf{b} = \frac{\mathbf{u}_1 \cdot \mathbf{b}}{\mathbf{u}_1 \cdot \mathbf{u}_1}\,\mathbf{u}_1 + \frac{\mathbf{u}_2 \cdot \mathbf{b}}{\mathbf{u}_2 \cdot \mathbf{u}_2}\,\mathbf{u}_2 + \cdots + \frac{\mathbf{u}_k \cdot \mathbf{b}}{\mathbf{u}_k \cdot \mathbf{u}_k}\,\mathbf{u}_k


Each term is the projection of b\mathbf{b} onto one basis vector. Orthogonality prevents interference: projecting onto u1\mathbf{u}_1 does not affect the component along u2\mathbf{u}_2, because u1u2=0\mathbf{u}_1 \cdot \mathbf{u}_2 = 0.

When the basis is orthonormal, the denominators are all 11:

Projection onto Orthonormal Basis
projWb=i=1k(qib)qi\text{proj}_W \mathbf{b} = \sum_{i=1}^{k} (\mathbf{q}_i \cdot \mathbf{b})\,\mathbf{q}_i

This is the cleanest formula in all of linear algebra — kk dot products and kk scalar multiplications.

Projection with an Arbitrary Basis

When the basis for WW is not orthogonal, the individual vector projection formula does not apply — projecting onto one basis vector interferes with the others. Instead, the projection requires solving a system.

If the columns of the m×km \times k matrix AA form a basis for WW, the projection of b\mathbf{b} onto WW is

Projection onto Subspace
b^=A(ATA)1ATb\hat{\mathbf{b}} = A(A^TA)^{-1}A^T\mathbf{b}

This formula requires ATAA^TA to be invertible, which holds whenever the columns of AA are linearly independent.

The derivation comes from the orthogonality condition. The residual bAx^\mathbf{b} - A\hat{\mathbf{x}} must be perpendicular to every column of AA: AT(bAx^)=0A^T(\mathbf{b} - A\hat{\mathbf{x}}) = \mathbf{0}. Solving for x^\hat{\mathbf{x}} gives ATAx^=ATbA^TA\hat{\mathbf{x}} = A^T\mathbf{b}, so x^=(ATA)1ATb\hat{\mathbf{x}} = (A^TA)^{-1}A^T\mathbf{b}, and b^=Ax^=A(ATA)1ATb\hat{\mathbf{b}} = A\hat{\mathbf{x}} = A(A^TA)^{-1}A^T\mathbf{b}.

The alternative is to first orthogonalize the basis using Gram-Schmidt, then use the simpler orthogonal formula. Both approaches give the same projection.
Orthogonality · projection formulas

Four formulas, one operation

All four compute the same thing — the closest point of the target to b\mathbf{b}. They differ only in what is assumed about the basis, and the formula gets simpler as the assumption gets stronger.

4cases
Onto a single vector1
A line§ 1the target is Span{a}\operatorname{Span}\{\mathbf{a}\}
formulabaaaa\dfrac{\mathbf{b} \cdot \mathbf{a}}{\mathbf{a} \cdot \mathbf{a}}\,\mathbf{a}
requiresa0\mathbf{a} \neq \mathbf{0}
cost per projectiontwo dot products
The base case, and the one every formula below is built from. The denominator is what normalisation removes — for a unit vector it is 11 and disappears.
Onto a subspace — basis assumed orthogonal2
Orthogonal basis§ 3uiuj=0\mathbf{u}_i \cdot \mathbf{u}_j = 0 for iji \neq j
formulabuiuiuiui\sum \dfrac{\mathbf{b} \cdot \mathbf{u}_i}{\mathbf{u}_i \cdot \mathbf{u}_i}\,\mathbf{u}_i
requirespairwise orthogonal, nonzero
cost per projection2k2k dot products
A sum of independent line projections. Orthogonality is what makes the terms independent — each coefficient can be computed without knowing the others, and adding a basis vector does not disturb them.
Orthonormal basis§ 3orthogonal and qi=1\|\mathbf{q}_i\| = 1
formula(bqi)qi\sum (\mathbf{b} \cdot \mathbf{q}_i)\,\mathbf{q}_i
requirespairwise orthogonal, unit length
cost per projectionkk dot products
The denominators vanish because each is 11. This is the form worth arranging for — see orthonormal operations, where every operation simplifies the same way.
Onto a subspace — nothing assumed1
Arbitrary basis§ 4columns of AA span the target
formulaA(ATA)1ATbA(A^{\mathsf{T}}A)^{-1}A^{\mathsf{T}}\mathbf{b}
requirescolumns of AA independent
cost per projectiona k×kk \times k inverse
The general case, and the expensive one. (ATA)1(A^{\mathsf{T}}A)^{-1} exists exactly when the columns are independent — and when they happen to be orthonormal, ATA=IA^{\mathsf{T}}A = I and this collapses to the row above.
Reading upward is the argument for Gram–Schmidt. The general formula needs a matrix inverse; orthogonality removes the coupling between coefficients; normalisation removes the denominators. Each assumption bought by preprocessing is a computation avoided on every projection afterwards.
Four formulas, one operation·/linear-algebra/orthogonality/projectionsLearn Math Class
Ordered this way the four are a single formula losing assumptions. Start at the bottom with an arbitrary basis and the projection needs a k×kk \times k matrix inverse. Assume the basis orthogonal and the inverse disappears, because ATAA^{\mathsf{T}}A becomes diagonal and the coefficients stop depending on each other. Assume it orthonormal as well and the denominators go too, since each is one.

The Projection Matrix

The matrix P=A(ATA)1ATP = A(A^TA)^{-1}A^T maps any vector b\mathbf{b} to its projection onto Col(A)\text{Col}(A): b^=Pb\hat{\mathbf{b}} = P\mathbf{b}.

When the basis is orthonormal (A=QA = Q with QTQ=IQ^TQ = I), the formula simplifies:

Orthonormal Columns Projection
P=QQTP = QQ^T

The projection matrix satisfies two algebraic conditions. It is symmetric: PT=PP^T = P. And it is idempotent: P2=PP^2 = P — projecting twice gives the same result as projecting once, because vectors already in WW are fixed by PP.

The complementary matrix IPI - P projects onto the orthogonal complement WW^\perp:

Complementary Projection
IP projects onto WI - P \text{ projects onto } W^\perp

It satisfies (IP)T=IP(I - P)^T = I - P and (IP)2=IP(I - P)^2 = I - P, and for every b\mathbf{b}: Pb+(IP)b=bP\mathbf{b} + (I - P)\mathbf{b} = \mathbf{b}, decomposing b\mathbf{b} into its WW-component and its WW^\perp-component.

The eigenvalues of PP are 00 and 11: vectors in WW map to themselves (eigenvalue 11) and vectors in WW^\perp map to zero (eigenvalue 00). The rank of PP equals the trace of PP, which equals dim(W)\dim(W).
Property of P Statement Why it holds / what it means
Idempotent P² = P projecting a second time changes nothing; vectors already in W are fixed
Symmetric Pᵀ = P makes the projection orthogonal (residual ⊥ W); distinguishes from oblique projections, which satisfy P² = P but Pᵀ ≠ P
Complementary projection I − P projects onto W I − P is also symmetric and idempotent
Decomposition of every b b = Pb + (I − P) b unique split into a W-component and a W-component
Eigenvalues only 0 and 1 vectors in W are eigenvectors for λ = 1; vectors in W for λ = 0
Rank rank(P) = dim(W) number of independent directions preserved
Trace tr(P) = dim(W) trace = sum of eigenvalues = number of eigenvalues equal to 1
Orthonormal basis simplification P = QQᵀ when A = Q has Qᵀ Q = I the (AᵀA)⁻¹ factor disappears because QᵀQ = I
im Pker PPvv
The whole plane collapsed onto a line

Every point has been dropped perpendicularly onto the line, and points already on it have not moved at all. That is why applying the matrix twice changes nothing the second time: idempotence is a geometric fact here, not an algebraic coincidence. Move the line and watch the whole plane follow on the 2D projection explorer.

A projection matrix is therefore recognisable by squaring to itself, without any need to know which subspace it projects onto.

Properties of Orthogonal Projections

Orthogonal projections are characterized by two properties acting together:

Projection Matrix Properties
P2=P,PT=PP^2 = P, \quad P^T = P

Idempotence (P2=PP^2 = P): once a vector has been projected, projecting again changes nothing. Every vector in WW is a fixed point of PP. This distinguishes projections from other linear transformations — most transformations continue to change vectors on repeated application.

Symmetry (PT=PP^T = P): the projection is self-adjoint with respect to the dot product. This means Puv=uPvP\mathbf{u} \cdot \mathbf{v} = \mathbf{u} \cdot P\mathbf{v} for all u,v\mathbf{u}, \mathbf{v}. The symmetry condition is what makes the projection orthogonal rather than oblique — it ensures the residual is perpendicular to WW, not merely non-parallel.

A matrix satisfying P2=PP^2 = P and PT=PP^T = P is an orthogonal projection. A matrix satisfying P2=PP^2 = P but PTPP^T \neq P is an oblique projection — it projects onto the same subspace but along a different direction, not the perpendicular one.

The error bPb\|\mathbf{b} - P\mathbf{b}\| is the distance from b\mathbf{b} to WW. It is the smallest possible value of bw\|\mathbf{b} - \mathbf{w}\| over all wW\mathbf{w} \in W.
Orthogonality · projections

Properties of orthogonal projections

Two conditions define the whole object, and everything below them is a consequence. Idempotence alone gives a projection; symmetry is what makes it the perpendicular one.

07properties
Unconditional4
i
Idempotence§ 6P2=PP^2 = P
Projecting twice changes nothing — once a vector is in W it stays put, so every vector of W is…
Unconditional
Requires
defining condition

Projecting twice changes nothing — once a vector is in WW it stays put, so every vector of WW is a fixed point of PP. This is unusual among linear transformations, most of which keep changing a vector on repeated application.

ii
Symmetry§ 6PT=PP^{\mathsf{T}} = P
Self-adjoint with respect to the dot product, meaning Pu · v = u · Pv for every pair.
Unconditional
Requires
defining condition

Self-adjoint with respect to the dot product, meaning Puv=uPvP\mathbf{u} \cdot \mathbf{v} = \mathbf{u} \cdot P\mathbf{v} for every pair. This is the condition that makes the projection orthogonal rather than merely a projection — it forces the residual to be perpendicular to WW, not just outside it.

v
Complementary projection§ 2IPI - P projects onto WW^{\perp}
The residual is itself a projection, onto the orthogonal complement.
Unconditional
Requires
PP orthogonal

The residual is itself a projection, onto the orthogonal complement. Check: (IP)2=I2P+P2=IP(I-P)^2 = I - 2P + P^2 = I - P by idempotence, and (IP)T=IP(I-P)^{\mathsf{T}} = I - P by symmetry — so it satisfies both defining conditions.

vii
Eigenvalues§ 5λ{0,1}\lambda \in \{0, 1\}
From Pv = λv and idempotence, λ^2 = λ, so λ is 0 or 1.
Unconditional
Requires
follows from P2=PP^2 = P

From Pv=λvP\mathbf{v} = \lambda\mathbf{v} and idempotence, λ2=λ\lambda^2 = \lambda, so λ\lambda is 00 or 11. The eigenvectors for 11 span WW, those for 00 span WW^\perp, and rank(P)=tr(P)=dimW\operatorname{rank}(P) = \operatorname{tr}(P) = \dim W — the trace counts the ones. See spectral properties.

Conditional2
iv
Orthogonal decomposition§ 2b=Pb+(bPb)\mathbf{b} = P\mathbf{b} + (\mathbf{b} - P\mathbf{b})
Every vector splits uniquely into a part in W and a part perpendicular to it.
Conditional
Holds when
PP orthogonal — both conditions

Every vector splits uniquely into a part in WW and a part perpendicular to it. Uniqueness is what makes this a decomposition rather than merely one way of writing b\mathbf{b}, and it is the reason WW and WW^\perp intersect only at the origin.

vi
Minimal distance§ 7bPbbw\|\mathbf{b} - P\mathbf{b}\| \leq \|\mathbf{b} - \mathbf{w}\| for all wW\mathbf{w} \in W
The projection is the closest point of W to b, and the only one achieving the minimum.
Conditional
Holds when
equality iff w=Pb\mathbf{w} = P\mathbf{b}

The projection is the closest point of WW to b\mathbf{b}, and the only one achieving the minimum. This is the entire content of least squares — the best approximation is a projection, and the perpendicularity of the residual is why no other point can do better.

Fails or undefined1
iii
Oblique projection§ 6P2=PP^2 = P but PTPP^{\mathsf{T}} \neq P
Still a projection, and still onto the same subspace — but along a slanted direction rather…
Not orthogonal
Fails when
symmetry is dropped
Common error
treating idempotence alone as the definition of a projection onto WW

Still a projection, and still onto the same subspace — but along a slanted direction rather than the perpendicular one. The two conditions are independent, and this entry exists to show that the second is not implied by the first.

WitnessP = [[1, 1], [0, 0]]
P² = P, so it projects — onto the x-axis
Pᵀ ≠ P, so it projects along the line y = −x, not perpendicular
Unconditional
Conditional
Fails or undefined
Idempotence§ 6Unconditional
P2=PP^2 = P
Requires
defining condition
Projecting twice changes nothing — once a vector is in WW it stays put, so every vector of WW is a fixed point of PP. This is unusual among linear transformations, most of which keep changing a vector on repeated application.
Read the full section
Symmetry§ 6Unconditional
PT=PP^{\mathsf{T}} = P
Requires
defining condition
Self-adjoint with respect to the dot product, meaning Puv=uPvP\mathbf{u} \cdot \mathbf{v} = \mathbf{u} \cdot P\mathbf{v} for every pair. This is the condition that makes the projection orthogonal rather than merely a projection — it forces the residual to be perpendicular to WW, not just outside it.
Read the full section
P2=PP^2 = P but PTPP^{\mathsf{T}} \neq P
Fails when
symmetry is dropped
Common error
treating idempotence alone as the definition of a projection onto WW
Still a projection, and still onto the same subspace — but along a slanted direction rather than the perpendicular one. The two conditions are independent, and this entry exists to show that the second is not implied by the first.
WitnessP = [[1, 1], [0, 0]]
P² = P, so it projects — onto the x-axis
Pᵀ ≠ P, so it projects along the line y = −x, not perpendicular
Read the full section
b=Pb+(bPb)\mathbf{b} = P\mathbf{b} + (\mathbf{b} - P\mathbf{b})
Holds when
PP orthogonal — both conditions
Every vector splits uniquely into a part in WW and a part perpendicular to it. Uniqueness is what makes this a decomposition rather than merely one way of writing b\mathbf{b}, and it is the reason WW and WW^\perp intersect only at the origin.
Read the full section
IPI - P projects onto WW^{\perp}
Requires
PP orthogonal
The residual is itself a projection, onto the orthogonal complement. Check: (IP)2=I2P+P2=IP(I-P)^2 = I - 2P + P^2 = I - P by idempotence, and (IP)T=IP(I-P)^{\mathsf{T}} = I - P by symmetry — so it satisfies both defining conditions.
Read the full section
bPbbw\|\mathbf{b} - P\mathbf{b}\| \leq \|\mathbf{b} - \mathbf{w}\| for all wW\mathbf{w} \in W
Holds when
equality iff w=Pb\mathbf{w} = P\mathbf{b}
The projection is the closest point of WW to b\mathbf{b}, and the only one achieving the minimum. This is the entire content of least squares — the best approximation is a projection, and the perpendicularity of the residual is why no other point can do better.
Read the full section
Eigenvalues§ 5Unconditional
λ{0,1}\lambda \in \{0, 1\}
Requires
follows from P2=PP^2 = P
From Pv=λvP\mathbf{v} = \lambda\mathbf{v} and idempotence, λ2=λ\lambda^2 = \lambda, so λ\lambda is 00 or 11. The eigenvectors for 11 span WW, those for 00 span WW^\perp, and rank(P)=tr(P)=dimW\operatorname{rank}(P) = \operatorname{tr}(P) = \dim W — the trace counts the ones. See spectral properties.
Read the full section
Drop symmetry and PP still projects onto WW, but along some other direction — an oblique projection. The residual is then no longer perpendicular, the distance is no longer minimal, and least squares loses its justification entirely. That is how much rests on the second condition.
Properties of orthogonal projections·/linear-algebra/orthogonality/projectionsLearn Math Class

Projection and Least Squares

When the system Ax=bA\mathbf{x} = \mathbf{b} has no solution — when b\mathbf{b} is not in the column space of AA — the least-squares solution x^\hat{\mathbf{x}} produces the projection of b\mathbf{b} onto Col(A)\text{Col}(A):

Ax^=b^=PbA\hat{\mathbf{x}} = \hat{\mathbf{b}} = P\mathbf{b}


The least-squares solution does not solve Ax=bA\mathbf{x} = \mathbf{b}. It solves Ax=b^A\mathbf{x} = \hat{\mathbf{b}}, where b^\hat{\mathbf{b}} is the closest reachable vector to b\mathbf{b}.

The residual r=bAx^\mathbf{r} = \mathbf{b} - A\hat{\mathbf{x}} lies in Col(A)=Null(AT)\text{Col}(A)^\perp = \text{Null}(A^T) — it is orthogonal to every column of AA. The condition ATr=0A^T\mathbf{r} = \mathbf{0} is exactly the normal equation ATAx^=ATbA^TA\hat{\mathbf{x}} = A^T\mathbf{b}.

Every least-squares problem is a projection problem. Solving least squares means projecting the target b\mathbf{b} onto the column space and finding the input x^\hat{\mathbf{x}} that produces the projected output.

Worked Example: Full Projection Computation

Project b=(1,2,3)\mathbf{b} = (1, 2, 3) onto the subspace W=Span{(1,0,1),(0,1,1)}W = \text{Span}\{(1, 0, 1), (0, 1, 1)\} in R3\mathbb{R}^3.

The basis is not orthogonal: (1,0,1)(0,1,1)=0+0+1=10(1, 0, 1) \cdot (0, 1, 1) = 0 + 0 + 1 = 1 \neq 0. Use the general formula. Set A=(100111)A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 1 & 1 \end{pmatrix}.

ATA=(101011)(100111)=(2112)A^TA = \begin{pmatrix} 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 1 & 1 \end{pmatrix} = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}


(ATA)1=13(2112)(A^TA)^{-1} = \frac{1}{3}\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}


ATb=(1+0+30+2+3)=(45)A^T\mathbf{b} = \begin{pmatrix} 1 + 0 + 3 \\ 0 + 2 + 3 \end{pmatrix} = \begin{pmatrix} 4 \\ 5 \end{pmatrix}


x^=13(2112)(45)=13(36)=(12)\hat{\mathbf{x}} = \frac{1}{3}\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}\begin{pmatrix} 4 \\ 5 \end{pmatrix} = \frac{1}{3}\begin{pmatrix} 3 \\ 6 \end{pmatrix} = \begin{pmatrix} 1 \\ 2 \end{pmatrix}


b^=Ax^=1(101)+2(011)=(123)\hat{\mathbf{b}} = A\hat{\mathbf{x}} = 1\begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix} + 2\begin{pmatrix} 0 \\ 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix}


The projection equals b\mathbf{b} itself — meaning b\mathbf{b} was already in WW. The residual is 0\mathbf{0}, confirming bSpan{(1,0,1),(0,1,1)}\mathbf{b} \in \text{Span}\{(1, 0, 1), (0, 1, 1)\}. Indeed: (1,2,3)=1(1,0,1)+2(0,1,1)(1, 2, 3) = 1 \cdot (1, 0, 1) + 2 \cdot (0, 1, 1).

Summary: Where Projections Appear

Projection is not a single isolated construction — it threads through least squares, Gram–Schmidt, QR decomposition, the orthogonal decomposition of ℝⁿ, and every "closest point" or "best approximation" problem in linear algebra. The table below collects each context in which projection plays a role, alongside what is being projected and what the projection produces.
Where projection appears What is being projected What the projection gives
Component along an axis vector b onto a single direction q (q · b) q — the part of b along q
Best approximation in a subspace vector b onto subspace W the w ∈ W minimizing ‖b − w‖
Orthogonal decomposition of ℝⁿ every b onto W and onto W unique b = Pb + (I − P) b
Least squares b onto Col(A) when A x = b is inconsistent A x̂ = Pb; residual ⊥ Col(A); normal equations AᵀA x̂ = Aᵀ b
Gram–Schmidt orthogonalization each new basis vector onto the span of previous ones perpendicular remainder becomes the next orthogonal basis vector
QR decomposition columns of A successively onto previous orthonormal q's A = QR with Q orthonormal columns and R upper triangular

Projections FAQ

Is a projection matrix invertible?

+
Not unless it projects onto the whole space. The defining relation P2=PP^2 = P forces PP to be singular whenever the target subspace is smaller, and the reason is geometric rather than algebraic: projecting discards the component perpendicular to the subspace, and discarded information is exactly what no inverse can recover.Read more →

In proja\text{proj}_{\mathbf{a}}, what is the subscript doing?

+
Naming the destination, not counting anything. It is not the a\mathbf{a}-th projection of some sequence. The subscript's species also sets the target's size: proja\text{proj}_{\mathbf{a}} lands on a line, while projW\text{proj}_{W} lands on a subspace of any dimension, using the same operator with a wider aim.Read more →

Does the hat in b^\hat{\mathbf{b}} mean the vector has length 11?

+
Not here. Two hat conventions coexist in linear algebra: on a vector like u^\hat{\mathbf{u}} it usually promises unit length, but in projection and least squares it marks an approximation or estimate instead. Statistics uses the same hat for estimators, which is where this second meaning comes from rather than a coincidence.Read more →