The Residual and the Orthogonal Complement
When a vector \(\mathbf{b}\in\mathbb{R}^n\) is projected onto a subspace \(W\), the projection is the component that belongs to \(W\). The difference between the original vector and that component is called the residual. The key condition in this tutorial is that this residual is perpendicular to every vector in \(W\). It gives a practical way to check a proposed projection: the projected vector must lie in the subspace, and the residual must be orthogonal to the subspace.
We use the standard dot product \(\mathbf{x}\cdot\mathbf{y}=\mathbf{x}^{\top}\mathbf{y}\) on \(\mathbb{R}^n\). For a subspace \(W\subseteq\mathbb{R}^n\), its orthogonal complement is the set of vectors perpendicular to every vector in \(W\).
In finite-dimensional Euclidean space, the orthogonal decomposition theorem gives a unique expression \(\mathbf{b}=\mathbf{p}+\mathbf{r}\), where \(\mathbf{p}\in W\) and \(\mathbf{r}\in W^\perp\). The vector \(\mathbf{p}\) is the orthogonal projection of \(\mathbf{b}\) onto \(W\). We will prove the residual condition using the matrix characterization of orthogonal projection from the earlier material, and then prove that the two conditions also identify the projection uniquely.
Why the Residual Is Orthogonal
Suppose \(P\) is the matrix of the orthogonal projection onto \(W\). By the characterization of orthogonal projection matrices, \(P^{\top}=P\), \(P^2=P\), and the range of \(P\) is \(W\). The projected vector is \(P\mathbf{b}\), so its residual is \((I_n-P)\mathbf{b}\). The identities \(P^{\top}=P\) and \(P^2=P\) let us test this residual against any vector in the range of \(P\), which is exactly \(W\).
Proof. Let \(\mathbf{b}\in\mathbb{R}^n\), and let \(\mathbf{w}\in W\) be arbitrary. Since \(W\) is the range of \(P\), there is a vector \(\mathbf{z}\in\mathbb{R}^n\) such that \(\mathbf{w}=P\mathbf{z}\). Using symmetry and idempotence of \(P\), we obtain
because \((I_n-P)P=P-P^2=0\). Thus the residual has dot product zero with every \(\mathbf{w}\in W\). By the definition of \(W^\perp\), \(\mathbf{b}-P\mathbf{b}\in W^\perp\). \(\square\)
Worked Example: Projection onto a Coordinate Plane
Let \(W=\{(x,y,0):x,y\in\mathbb{R}\}\subseteq\mathbb{R}^3\), and project \(\mathbf{b}=(3,2,4)\) onto \(W\). The vector \(\mathbf{p}=(3,2,0)\) lies in \(W\). Its residual is
Every vector in \(W\) has the form \(\mathbf{w}=(s,t,0)\). The dot product with the residual is
Therefore the residual is in \(W^\perp\), and \(\mathbf{p}\) satisfies the projection conditions. In this example the orthogonal complement is the \(z\)-axis: any \((0,0,c)\) is perpendicular to every \((s,t,0)\), and a vector perpendicular to both \((1,0,0)\) and \((0,1,0)\) must have its first two coordinates zero.
Check: \(\mathbf{p}+\left(\mathbf{b}-\mathbf{p}\right)=(3,2,0)+(0,0,4)=(3,2,4)=\mathbf{b}\), as required by the decomposition.
Membership and Orthogonality Characterize the Projection
The residual condition is not only necessary. Together with membership in \(W\), it is enough to identify the orthogonal projection. This characterization gives a direct verification method even when a projection matrix has not been computed. It is also important to keep both parts: a vector in \(W\) need not be the projection, and a residual orthogonal to \(W\) does not by itself say that the proposed projected vector belongs to \(W\).
Proof. First suppose \(\mathbf{q}=P\mathbf{b}\). The range of \(P\) is \(W\), so \(\mathbf{q}\in W\). The residual theorem just proved gives \(\mathbf{b}-\mathbf{q}=\mathbf{b}-P\mathbf{b}\in W^\perp\).
Conversely, suppose \(\mathbf{q}\in W\) and \(\mathbf{r}=\mathbf{b}-\mathbf{q}\in W^\perp\). Because \(P\) maps onto \(W\) and is idempotent, \(P\mathbf{q}=\mathbf{q}\). Also \(P\mathbf{r}\in W\), so \(\mathbf{r}\cdot P\mathbf{r}=0\) by \(\mathbf{r}\in W^\perp\). Symmetry and idempotence give
A vector has squared norm zero only if it is the zero vector, so \(P\mathbf{r}=\mathbf{0}\). Since \(\mathbf{b}=\mathbf{q}+\mathbf{r}\), linearity now gives \(P\mathbf{b}=P\mathbf{q}+P\mathbf{r}=\mathbf{q}\). Hence \(\mathbf{q}=P\mathbf{b}\), proving the reverse direction as well. \(\square\)
Worked Example: Projection onto a Subspace with Nonorthogonal Generators
Let \(W=\operatorname{span}\{\mathbf{u},\mathbf{v}\}\subseteq\mathbb{R}^3\), where \(\mathbf{u}=(1,1,0)\) and \(\mathbf{v}=(1,0,1)\). Find the projection of \(\mathbf{b}=(5,0,-1)\) onto \(W\) by imposing residual orthogonality.
Write a possible projection as \(\mathbf{p}=a\mathbf{u}+c\mathbf{v}\). The residual must be perpendicular to both generators, since both belong to \(W\). The needed dot products are \(\mathbf{u}\cdot\mathbf{u}=2\), \(\mathbf{u}\cdot\mathbf{v}=1\), \(\mathbf{v}\cdot\mathbf{v}=2\), \(\mathbf{b}\cdot\mathbf{u}=5\), and \(\mathbf{b}\cdot\mathbf{v}=4\). Thus
From the first equation, \(c=5-2a\). Substitution into the second gives \(4-a-2(5-2a)=0\), so \(4-a-10+4a=0\), \(3a=6\), and \(a=2\). Therefore \(c=5-2(2)=1\), and
The residual is \(\mathbf{b}-\mathbf{p}=(5,0,-1)-(3,2,1)=(2,-2,-2)\). Check its dot products with the generators:
Every vector in \(W\) is a linear combination of these generators, so orthogonality to both implies orthogonality to every vector in \(W\). Also, \(\mathbf{p}=2\mathbf{u}+\mathbf{v}\in W\). The characterization therefore confirms that this is the projection.
Check: \((3,2,1)+(2,-2,-2)=(5,0,-1)=\mathbf{b}\), and the two required dot products are zero.
Testing a Projection with a Matrix
For a subspace given as the column space of a matrix, the residual condition can be checked against each column. If \(\mathbf{A}\) has columns that span \(W\), then a vector is perpendicular to all of \(W\) exactly when it is perpendicular to every column of \(\mathbf{A}\). In matrix notation, the condition is \(\mathbf{A}^{\top}(\mathbf{b}-\mathbf{q})=\mathbf{0}\). Indeed, the entries of this product are the dot products of the residual with the respective columns. This is a test for a candidate; it does not require the columns to be orthogonal.
Worked Example: Verify a Projection Using Its Generating Matrix
Let \(W=\operatorname{Col}\mathbf{A}\), where
The columns of \(\mathbf{A}\) are \(\mathbf{a}_1=(1,0,1)\) and \(\mathbf{a}_2=(0,1,1)\). Try \(\mathbf{q}=\mathbf{a}_2=(0,1,1)\), which is in \(W\). Its residual is
Test both generating columns:
Equivalently, the matrix test gives
Thus \(\mathbf{r}\in W^\perp\), and \(\mathbf{q}\in W\), so the characterization proves that \(\mathbf{q}\) is the projection. For an additional matrix check, the projection matrix is
The matrix product agrees with the residual test.
Common Mistake: Checking Only Subspace Membership
A tempting but incorrect check is to verify only that a candidate \(\mathbf{q}\) lies in \(W\). In the matrix example, choose instead \(\mathbf{q}_{\mathrm{wrong}}=(1,1,2)\). It does lie in \(W\), because \(\mathbf{q}_{\mathrm{wrong}}=\mathbf{a}_1+\mathbf{a}_2\). But its residual for the same \(\mathbf{b}\) is
The first column already disproves orthogonality:
So \(\mathbf{q}_{\mathrm{wrong}}\) is not the projection. The correction is to check both conditions: the proposed vector must belong to \(W\), and its residual must be perpendicular to every generator of \(W\). Also take care with the subtraction order: the residual here is \(\mathbf{b}-\mathbf{q}\), not \(\mathbf{q}-\mathbf{b}\). Reversing the order changes the sign of every dot product but not whether those products equal zero.
Using the Condition Reliably
Residual orthogonality is useful because it turns a projection claim into checks involving subspace membership and dot products. For \(W=\operatorname{Col}\mathbf{A}\), checking \(\mathbf{A}^{\top}(\mathbf{b}-\mathbf{q})=\mathbf{0}\) checks all the generator directions at once. If the columns span \(W\), linearity ensures that zero dot product with each column gives zero dot product with every linear combination of those columns.
The condition also explains why the projection is determined uniquely. If two candidates both lie in \(W\) and both have residuals in \(W^\perp\), the projection characterization shows that each equals \(P\mathbf{b}\); therefore they are the same vector. This provides a proof of uniqueness without comparing their coordinates directly. The essential distinction is between the projected component, which belongs to \(W\), and the residual, which belongs to \(W^\perp\): together they decompose \(\mathbf{b}\) into orthogonal components.
Check Your Understanding
For each question, state the subspace membership and residual-orthogonality checks that justify your conclusion.
- For \(W=\{(x,y,0):x,y\in\mathbb{R}\}\) and \(\mathbf{b}=(2,-1,5)\), find the projection and verify its residual.
- Suppose \(W=\operatorname{span}\{(1,0,1),(0,1,1)\}\). What matrix product tests whether a proposed residual is in \(W^\perp\)?
- Let \(P\) be a symmetric idempotent matrix with range \(W\). Identify the identity that makes \((I_n-P)P\mathbf{z}\) zero in the residual-orthogonality proof.
- Explain why a candidate \(\mathbf{q}\in W\) is not necessarily the projection of \(\mathbf{b}\) onto \(W\).
- If \(\mathbf{q}\in W\) and \(\mathbf{b}-\mathbf{q}\in W^\perp\), what theorem justifies concluding that \(\mathbf{q}\) is the projection?