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}:

Projection onto a Vector
projab=a⋅ba⋅a a\text{proj}_{\mathbf{a}}\mathbf{b} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{a} \cdot \mathbf{a}}\,\mathbf{a}

The scalar c^=a⋅ba⋅a\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 b−c^ a\mathbf{b} - \hat{c}\,\mathbf{a} is orthogonal to a\mathbf{a}:

Projection onto a Vector
(b−c^ a)⋅a=b⋅a−c^(a⋅a)=b⋅a−b⋅a=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):

Projection onto a Vector
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: b−projab=(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.

Pitfall: Dividing by the length instead of its square
Dividing a⋅b=7\mathbf{a} \cdot \mathbf{b} = 7 by ∥a∥=3\|\mathbf{a}\| = \sqrt{3} instead of a⋅a=3\mathbf{a} \cdot \mathbf{a} = 3 gives 73(1,1,1)\frac{7}{\sqrt{3}}(1, 1, 1), of length 77, more than ∥b∥=5\|\mathbf{b}\| = 5. The projection is 73(1,1,1)\frac{7}{3}(1, 1, 1).

The residual check is the quickest test of a computed projection. Only one multiple of a\mathbf{a} leaves a remainder perpendicular to a\mathbf{a}, so a slip in the coefficient shows up as a nonzero dot product. A second test is size: the projection and the residual are the two legs of a right triangle whose hypotenuse is b\mathbf{b}, so the projection is never longer than b\mathbf{b}.
cu·v/‖v‖²·v1×3v1​v2​v3​=proj1×3c·v1​c·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; W⊥W^{\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 W≠RnW \neq \mathbb{R}^n — projection discards the W⊥W^{\perp} component, and discarded information is exactly what an inverse cannot recover.

The Orthogonal Decomposition

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

Orthogonal Decomposition
b=b^+z,b^∈W, z∈W⊥\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=b−b^\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 w∈W\mathbf{w} \in W:

The Orthogonal Decomposition
∥b−w∥2=∥z∥2+∥b^−w∥2≥∥z∥2=∥b−b^∥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

Fact: Closest, yet 9% too high
The Fourier partial sums of a square wave are its projections onto more and more waves, yet beside each jump they overshoot by about 9% of the jump, however many terms are taken. Closest means least total squared error, and the spike narrows as terms are added, so its share of that error shrinks to zero.

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 z∈W⊥\mathbf{z} \in W^\perp). The minimum distance ∥z∥\|\mathbf{z}\| is achieved uniquely at w=b^\mathbf{w} = \hat{\mathbf{b}}.

The argument uses nothing but the Pythagorean theorem, so it holds in any inner product space, including spaces of functions where the dot product is the integral of a product. There, projecting a function onto the span of 1,cos⁡x,sin⁡x,…,cos⁡nx,sin⁡nx1, \cos x, \sin x, \dots, \cos nx, \sin nx gives the combination of those waves with the least total squared error, and that projection is exactly the Fourier partial sum of the function.
u1×3u1​u2​u3​−proj1×3c·v1​c·v2​c·v3​=u − proj1×3u1​−c·v1​u2​−c·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:

Projection with an Orthogonal Basis
projWb=u1⋅bu1⋅u1 u1+u2⋅bu2⋅u2 u2+⋯+uk⋅buk⋅uk uk\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 u1⋅u2=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(qi⋅b) 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.

Pitfall: Splitting the inverse of a product
Writing (ATA)−1=A−1(AT)−1(A^TA)^{-1} = A^{-1}(A^T)^{-1} cancels the formula to P=IP = I, but an m×km \times k matrix AA with k<mk < m has no inverse. For the columns (1,0,1)(1, 0, 1) and (0,1,1)(0, 1, 1), P=13(2−11−121112)P = \frac{1}{3}\begin{pmatrix} 2 & -1 & 1 \\ -1 & 2 & 1 \\ 1 & 1 & 2 \end{pmatrix}, not II.

The derivation comes from the orthogonality condition. The residual b−Ax^\mathbf{b} - A\hat{\mathbf{x}} must be perpendicular to every column of AA: AT(b−Ax^)=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}\}
formulab⋅aa⋅a a\dfrac{\mathbf{b} \cdot \mathbf{a}}{\mathbf{a} \cdot \mathbf{a}}\,\mathbf{a}
requiresa≠0\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§ 3ui⋅uj=0\mathbf{u}_i \cdot \mathbf{u}_j = 0 for i≠ji \neq j
formula∑b⋅uiui⋅ui ui\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∑(b⋅qi) 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

Pitfall: Taking QQ transpose to be the identity
Concluding QQT=IQQ^T = I from QTQ=IQ^TQ = I fails for a non-square QQ: with the single column 12(1,1,0)\frac{1}{\sqrt{2}}(1, 1, 0), QTQ=(1)Q^TQ = (1), but QQT=12(110110000)QQ^T = \frac{1}{2}\begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 0 & 0 & 0 \end{pmatrix} sends (1,0,0)(1, 0, 0) to (12,12,0)(\frac{1}{2}, \frac{1}{2}, 0).

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 I−PI - P projects onto the orthogonal complement W⊥W^\perp:

Complementary Projection
I−P projects onto W⊥I - P \text{ projects onto } W^\perp

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

The eigenvalues of PP are 00 and 11: vectors in WW map to themselves (eigenvalue 11) and vectors in W⊥W^\perp map to zero (eigenvalue 00).

RULE
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.

Fact: An evening shadow outgrows its pole
With the sun lower than 45°45°, a pole casts a shadow longer than itself: sunlight projects onto the ground along a slanted direction, an oblique projection with P2=PP^2 = P but PT≠PP^T \neq P. An orthogonal projection never lengthens a vector, and a projection that never lengthens one is always orthogonal.

Symmetry (PT=PP^T = P): the projection is self-adjoint with respect to the dot product. This means Pu⋅v=u⋅PvP\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 PT≠PP^T \neq P is an oblique projection — it projects onto the same subspace but along a different direction, not the perpendicular one.

The error ∥b−Pb∥\|\mathbf{b} - P\mathbf{b}\| is the distance from b\mathbf{b} to WW. It is the smallest possible value of ∥b−w∥\|\mathbf{b} - \mathbf{w}\| over all w∈W\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 Pu⋅v=u⋅PvP\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§ 2I−PI - P projects onto W⊥W^{\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: (I−P)2=I−2P+P2=I−P(I-P)^2 = I - 2P + P^2 = I - P by idempotence, and (I−P)T=I−P(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 W⊥W^\perp, and rank⁡(P)=tr⁡(P)=dim⁡W\operatorname{rank}(P) = \operatorname{tr}(P) = \dim W — the trace counts the ones. See spectral properties.

Conditional2
iv
Orthogonal decomposition§ 2b=Pb+(b−Pb)\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 W⊥W^\perp intersect only at the origin.

vi
Minimal distance§ 7∥b−Pb∥≤∥b−w∥\|\mathbf{b} - P\mathbf{b}\| \leq \|\mathbf{b} - \mathbf{w}\| for all w∈W\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 PT≠PP^{\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 Pu⋅v=u⋅PvP\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 PT≠PP^{\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+(b−Pb)\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 W⊥W^\perp intersect only at the origin.
Read the full section
I−PI - P projects onto W⊥W^{\perp}
Requires
PP orthogonal
The residual is itself a projection, onto the orthogonal complement. Check: (I−P)2=I−2P+P2=I−P(I-P)^2 = I - 2P + P^2 = I - P by idempotence, and (I−P)T=I−P(I-P)^{\mathsf{T}} = I - P by symmetry — so it satisfies both defining conditions.
Read the full section
∥b−Pb∥≤∥b−w∥\|\mathbf{b} - P\mathbf{b}\| \leq \|\mathbf{b} - \mathbf{w}\| for all w∈W\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 W⊥W^\perp, and rank⁡(P)=tr⁡(P)=dim⁡W\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
Squaring to itself makes a matrix a projection; symmetry is what makes it drop straight down, onto the closest point.

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):

Projection and Least Squares
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}.

RULE
The residual r=b−Ax^\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=1≠0(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}.

Worked Example: Full Projection Computation
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}

Worked Example: Full Projection Computation
(ATA)−1=13(2−1−12)(A^TA)^{-1} = \frac{1}{3}\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}

Worked Example: Full Projection Computation
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}

Worked Example: Full Projection Computation
x^=13(2−1−12)(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}

Worked Example: Full Projection Computation
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}

Pitfall: Adding projections onto a non-orthogonal basis
Summing the single-vector projections onto (1,0,1)(1, 0, 1) and (0,1,1)(0, 1, 1) gives 2(1,0,1)+52(0,1,1)=(2,52,92)2(1, 0, 1) + \frac{5}{2}(0, 1, 1) = (2, \frac{5}{2}, \frac{9}{2}), which is not even b\mathbf{b}. The general formula gives b^=(1,2,3)\hat{\mathbf{b}} = (1, 2, 3).

The projection equals b\mathbf{b} itself — meaning b\mathbf{b} was already in WW. The residual is 0\mathbf{0}, confirming b∈Span{(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

Common Pitfalls

Four slips account for many wrong projection computations. Each is marked with a box where it happens in the sections above. Here each is worked through in full, with the wrong and the right working side by side.

Dividing by the length instead of its square

The coefficient is computed as a⋅b∥a∥\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|}, the signed length of the projection, and then multiplied by a\mathbf{a} itself rather than by the unit vector in its direction. The result points the right way but has the wrong length, unless a\mathbf{a} is a unit vector.

Wrong working: with b=(3,4,0)\mathbf{b} = (3, 4, 0) and a=(1,1,1)\mathbf{a} = (1, 1, 1),
a⋅b∥a∥ a=73(1,1,1)\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|}\,\mathbf{a} = \frac{7}{\sqrt{3}}(1, 1, 1)

a vector of length 73⋅3=7\frac{7}{\sqrt{3}} \cdot \sqrt{3} = 7.

Right working: divide by a⋅a=∥a∥2=3\mathbf{a} \cdot \mathbf{a} = \|\mathbf{a}\|^2 = 3.
projab=a⋅ba⋅a a=73(1,1,1)\text{proj}_{\mathbf{a}}\mathbf{b} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{a} \cdot \mathbf{a}}\,\mathbf{a} = \frac{7}{3}(1, 1, 1)

of length 73≈4.04\frac{7}{\sqrt{3}} \approx 4.04. Written with the unit vector, the same result is a⋅b∥a∥⋅a∥a∥\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|} \cdot \frac{\mathbf{a}}{\|\mathbf{a}\|}, with two divisions by ∥a∥\|\mathbf{a}\|.

Why it happens: the scalar projection a⋅b∥a∥\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|} has a single division, and it is mixed up with the vector projection, which needs two.

How to check: the projection is never longer than b\mathbf{b}, and here ∥b∥=5<7\|\mathbf{b}\| = 5 < 7. The residual test fails too: ((3,4,0)−73(1,1,1))⋅(1,1,1)=7−73≠0\left((3, 4, 0) - \frac{7}{\sqrt{3}}(1, 1, 1)\right) \cdot (1, 1, 1) = 7 - 7\sqrt{3} \neq 0.

Splitting the inverse of a product

The rule (XY)−1=Y−1X−1(XY)^{-1} = Y^{-1}X^{-1} is applied to (ATA)−1(A^TA)^{-1}, although it holds only when both factors are square and invertible. Everything then cancels, and the projection matrix comes out as II, as if every vector were its own projection.

Wrong working:
A(ATA)−1AT=A A−1(AT)−1AT=IA(A^TA)^{-1}A^T = A\,A^{-1}(A^T)^{-1}A^T = I


Right working: AA is m×km \times k with k<mk < m, so A−1A^{-1} does not exist, and only the k×kk \times k matrix ATAA^TA is inverted. With the columns (1,0,1)(1, 0, 1) and (0,1,1)(0, 1, 1) of the worked example, (ATA)−1=13(2−1−12)(A^TA)^{-1} = \frac{1}{3}\begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix} and
P=A(ATA)−1AT=13(2−11−121112)P = A(A^TA)^{-1}A^T = \frac{1}{3}\begin{pmatrix} 2 & -1 & 1 \\ -1 & 2 & 1 \\ 1 & 1 & 2 \end{pmatrix}

This PP sends (1,1,−1)(1, 1, -1), which is perpendicular to both columns, to 0\mathbf{0}, while II would leave it unchanged.

Why it happens: the inverse rule for products is remembered without its condition, and ATAA^TA looks like a product of two matrices that can be inverted one at a time.

How to check: the trace of PP equals dim⁡W\dim W. Here tr⁡(P)=2+2+23=2\operatorname{tr}(P) = \frac{2 + 2 + 2}{3} = 2, the dimension of the plane, while tr⁡(I)=3\operatorname{tr}(I) = 3.

Taking QQ transpose to be the identity

For a matrix QQ with orthonormal columns, QTQ=IQ^TQ = I is turned around into QQT=IQQ^T = I. The reversed product is the identity only when QQ is square. With k<mk < m columns, QQTQQ^T is the m×mm \times m projection onto Col(Q)\text{Col}(Q), of rank kk.

Wrong working: for QQ with the single column 12(1,1,0)\frac{1}{\sqrt{2}}(1, 1, 0), QTQ=(1)Q^TQ = (1), so QQTQQ^T is taken to be II and every b\mathbf{b} is its own projection.

Right working:
QQT=12(110110000),QQT(100)=(12120)QQ^T = \frac{1}{2}\begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 0 & 0 & 0 \end{pmatrix}, \quad QQ^T\begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \\ 0 \end{pmatrix}

which matches the single-vector formula: (1,1,0)⋅(1,0,0)(1,1,0)⋅(1,1,0)(1,1,0)=12(1,1,0)\frac{(1, 1, 0) \cdot (1, 0, 0)}{(1, 1, 0) \cdot (1, 1, 0)}(1, 1, 0) = \frac{1}{2}(1, 1, 0).

Why it happens: for a square orthogonal matrix both products are the identity, and the two products differ only in the order of the factors.

How to check: compare sizes and rank. QTQQ^TQ is k×kk \times k, while QQTQQ^T is m×mm \times m with rank kk. Here the rank is 11, so QQTQQ^T cannot be the 3×33 \times 3 identity.

Adding projections onto a non-orthogonal basis

The sum formula from the orthogonal basis section is used with a basis that is not orthogonal. Each term is a correct projection onto one line, but the lines are not perpendicular, so the terms overlap and their sum is not the projection onto WW.

Wrong working: with b=(1,2,3)\mathbf{b} = (1, 2, 3) and the basis (1,0,1)(1, 0, 1), (0,1,1)(0, 1, 1) of the worked example,
42(1,0,1)+52(0,1,1)=(2,52,92)\frac{4}{2}(1, 0, 1) + \frac{5}{2}(0, 1, 1) = \left(2, \frac{5}{2}, \frac{9}{2}\right)


Right working: the general formula gives x^=(1,2)\hat{\mathbf{x}} = (1, 2) and b^=1⋅(1,0,1)+2⋅(0,1,1)=(1,2,3)\hat{\mathbf{b}} = 1 \cdot (1, 0, 1) + 2 \cdot (0, 1, 1) = (1, 2, 3), which is b\mathbf{b} itself, because b\mathbf{b} lies in WW.

Why it happens: the sum formula is shorter, and the condition that the basis be orthogonal is easy to skip when the basis vectors look simple.

How to check: test the basis first, (1,0,1)⋅(0,1,1)=1≠0(1, 0, 1) \cdot (0, 1, 1) = 1 \neq 0. Or test the residual: (1,2,3)−(2,52,92)=(−1,−12,−32)(1, 2, 3) - (2, \frac{5}{2}, \frac{9}{2}) = (-1, -\frac{1}{2}, -\frac{3}{2}), whose dot product with (1,0,1)(1, 0, 1) is −52-\frac{5}{2}, not 00.

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 →