Computing the Two Components
Suppose a vector \(\mathbf{x}\) is to be written as a sum of one vector in a subspace \(W\) and another vector orthogonal to every vector in \(W\). The orthogonal decomposition theorem guarantees that such a sum exists uniquely in a finite-dimensional inner product space. If an orthonormal basis of \(W\) is known, the two parts can be calculated directly: take inner products with the basis vectors to find the coefficients of the part in \(W\), then subtract it from \(\mathbf{x}\).
We work over \(\mathbb{R}\). Let \(V\) be a finite-dimensional real inner product space, with inner product \(\langle\cdot,\cdot\rangle\). A list \((\mathbf{q}_1,\dots,\mathbf{q}_k)\) is an orthonormal basis of \(W\) if it is a basis of \(W\), each \(\mathbf{q}_i\) has norm \(1\), and distinct vectors in the list are orthogonal. Here \(\|\mathbf{q}\|=\sqrt{\langle\mathbf{q},\mathbf{q}\rangle}\). The orthogonal complement of \(W\) in \(V\), denoted \(W^\perp\), is the set of vectors in \(V\) orthogonal to every vector in \(W\).
The coefficient of \(\mathbf{q}_i\) is the inner product \(\langle\mathbf{x},\mathbf{q}_i\rangle\), not an arbitrary scaling factor. Orthonormality is what makes the coefficients this simple. For a general basis, taking these inner products does not in general give the coefficients of the component in \(W\).
Why the Formula Gives the Components
The formula both constructs a decomposition and identifies its two parts uniquely. The proof uses only the basis property, orthonormality, and the definition of the orthogonal complement.
Proof. Define \(\mathbf{w}=\sum_{i=1}^{k}\langle\mathbf{x},\mathbf{q}_i\rangle\mathbf{q}_i\) and \(\mathbf{z}=\mathbf{x}-\mathbf{w}\). Because each \(\mathbf{q}_i\in W\) and \(W\) is a subspace, \(\mathbf{w}\in W\). By construction, \(\mathbf{x}=\mathbf{w}+\mathbf{z}\). For each \(j\) with \(1\le j\le k\), orthonormality gives \(\langle\mathbf{q}_i,\mathbf{q}_j\rangle=1\) when \(i=j\) and \(0\) otherwise. Therefore \(\langle\mathbf{z},\mathbf{q}_j\rangle=\langle\mathbf{x},\mathbf{q}_j\rangle-\sum_{i=1}^{k}\langle\mathbf{x},\mathbf{q}_i\rangle\langle\mathbf{q}_i,\mathbf{q}_j\rangle=0\). Every vector in \(W\) is a linear combination of the basis vectors, so \(\mathbf{z}\) is orthogonal to every vector in \(W\), and \(\mathbf{z}\in W^\perp\). For uniqueness, suppose also \(\mathbf{x}=\mathbf{w}'+\mathbf{z}'\) with \(\mathbf{w}'\in W\) and \(\mathbf{z}'\in W^\perp\). Then \(\mathbf{w}-\mathbf{w}'=\mathbf{z}'-\mathbf{z}\). The left side belongs to \(W\); the right side belongs to \(W^\perp\). A vector in both \(W\) and \(W^\perp\) must be zero, since it is orthogonal to itself and hence has squared norm zero. Thus \(\mathbf{w}=\mathbf{w}'\) and \(\mathbf{z}=\mathbf{z}'\). \(\square\)
This proof also explains a practical shortcut: once \(\mathbf{x}_W\) has been calculated, it is enough to subtract it from \(\mathbf{x}\) to obtain the other component. The subtraction is justified because the theorem shows that the result is orthogonal to \(W\), not merely because it is the leftover vector.
Worked Components in Three Settings
Worked Example: A Subspace of \(\mathbb{R}^3\)
Let \(W\subseteq\mathbb{R}^3\) have orthonormal basis \(\mathbf{q}_1=\frac{1}{\sqrt{2}}(1,1,0)^\top\) and \(\mathbf{q}_2=\frac{1}{\sqrt{6}}(1,-1,2)^\top\). Find the two components of \(\mathbf{x}=(2,0,1)^\top\).
The basis vectors have norm \(1\), since their squared norms are \(2/2=1\) and \(6/6=1\). Their inner product is \((1-1+0)/\sqrt{12}=0\). Thus the stated list is orthonormal. The coefficients are
Using the component formula gives
Subtract to find the other component: \(\mathbf{x}_{W^\perp}=\mathbf{x}-\mathbf{x}_W=(\frac{1}{3},-\frac{1}{3},-\frac{1}{3})^\top\).
Check: The inner products with the basis of \(W\) are \(\langle\mathbf{x}_{W^\perp},\mathbf{q}_1\rangle=(\frac13-\frac13)/\sqrt2=0\) and \(\langle\mathbf{x}_{W^\perp},\mathbf{q}_2\rangle=(\frac13+\frac13-\frac23)/\sqrt6=0\). Also \(\mathbf{x}_W+\mathbf{x}_{W^\perp}=(2,0,1)^\top=\mathbf{x}\).
Worked Example: A Polynomial Subspace
In \(P_2\), the real polynomials of degree at most \(2\), use the inner product \(\langle p,q\rangle=\int_{-1}^{1}p(t)q(t)\,dt\). Let \(W=\operatorname{span}\{1,t\}\) and \(\mathbf{x}(t)=t^2+t+1\). Find its components in \(W\) and \(W^\perp\).
An orthonormal basis of \(W\) is \(q_1(t)=1/\sqrt{2}\) and \(q_2(t)=\sqrt{3/2}\,t\). Indeed, \(\langle q_1,q_1\rangle=2/2=1\), \(\langle q_2,q_2\rangle=(3/2)(2/3)=1\), and \(\langle q_1,q_2\rangle=0\) because the integral of the odd function \(t\) over \([-1,1]\) is zero. The coefficients are
Therefore \(\mathbf{x}_W=(4\sqrt2/3)q_1+\sqrt{2/3}\,q_2=4/3+t\). Subtracting gives \(\mathbf{x}_{W^\perp}=t^2+t+1-(4/3+t)=t^2-1/3\).
Check: The remainder is orthogonal to both basis polynomials: \(\langle t^2-1/3,1\rangle=2/3-(1/3)2=0\), and \(\langle t^2-1/3,t\rangle=\int_{-1}^{1}(t^3-t/3)\,dt=0\), since the integrand is odd. Finally, \((4/3+t)+(t^2-1/3)=t^2+t+1\).
Worked Example: A Matrix Subspace
In the space of real \(2\times2\) matrices, use the Frobenius inner product \(\langle\mathbf{A},\mathbf{B}\rangle=\sum_{i=1}^{2}\sum_{j=1}^{2}a_{ij}b_{ij}\). Let \(W\) be spanned by \(\mathbf{Q}_1=\begin{bmatrix}1&0\\0&0\end{bmatrix}\) and \(\mathbf{Q}_2=\frac{1}{\sqrt2}\begin{bmatrix}0&1\\1&0\end{bmatrix}\). Find the components of \(\mathbf{X}=\begin{bmatrix}2&3\\1&4\end{bmatrix}\).
The two spanning matrices are orthonormal: \(\langle\mathbf{Q}_1,\mathbf{Q}_1\rangle=1\), \(\langle\mathbf{Q}_2,\mathbf{Q}_2\rangle=(1+1)/2=1\), and \(\langle\mathbf{Q}_1,\mathbf{Q}_2\rangle=0\). The coefficients are \(\langle\mathbf{X},\mathbf{Q}_1\rangle=2\) and \(\langle\mathbf{X},\mathbf{Q}_2\rangle=(3+1)/\sqrt2=2\sqrt2\). Hence
Check: The inner products of the remainder with \(\mathbf{Q}_1\) and \(\mathbf{Q}_2\) are \(0\) and \((1-1)/\sqrt2=0\), respectively. Adding the displayed matrices gives \(\mathbf{X}\).
A Consequence: The Components Meet at Right Angles
Since \(\mathbf{x}_W\in W\) and \(\mathbf{x}_{W^\perp}\in W^\perp\), the two components are orthogonal. The norm of the original vector therefore splits into the sum of the squared norms of its components.
Proof. Write \(\mathbf{x}=\mathbf{x}_W+\mathbf{x}_{W^\perp}\). Expanding the squared norm using the inner product gives \(\|\mathbf{x}\|^2=\langle\mathbf{x}_W,\mathbf{x}_W\rangle+\langle\mathbf{x}_W,\mathbf{x}_{W^\perp}\rangle+\langle\mathbf{x}_{W^\perp},\mathbf{x}_W\rangle+\langle\mathbf{x}_{W^\perp},\mathbf{x}_{W^\perp}\rangle\). The middle terms are zero because the components are orthogonal. The first and last terms are their squared norms, proving the identity. \(\square\)
For an orthonormal basis of \(W\), the squared norm of the component in \(W\) can also be read from its coefficients: \(\|\mathbf{x}_W\|^2=\sum_{i=1}^{k}\langle\mathbf{x},\mathbf{q}_i\rangle^2\). To verify this, expand \(\langle\mathbf{x}_W,\mathbf{x}_W\rangle\); every cross term with distinct basis vectors vanishes, and each diagonal term is the square of its coefficient. This gives a useful numerical check alongside verifying that the remainder is orthogonal.
Common Pitfall: Forgetting to Normalize
For \(\mathbf{x}=(2,0)^\top\) and \(W=\operatorname{span}\{(1,1)^\top\}\), a tempting but incorrect calculation is to use \((1,1)^\top\) directly as though it were a unit basis vector. That gives the claimed component \(2(1,1)^\top=(2,2)^\top\), using the inner product \((2,0)\cdot(1,1)=2\). But the remainder would be \((0,-2)^\top\), and \((0,-2)\cdot(1,1)=-2\ne0\). So this is not an orthogonal decomposition.
The unit vector in the direction of \((1,1)^\top\) is \(\mathbf{q}=(1,1)^\top/\sqrt2\). Its coefficient is \(\mathbf{x}\cdot\mathbf{q}=\sqrt2\), so the correct component is \(\sqrt2\,\mathbf{q}=(1,1)^\top\), and the orthogonal-complement component is \((1,-1)^\top\). The check \((1,-1)\cdot(1,1)=0\) confirms the correction. The formula requires an orthonormal basis, not merely a basis of the subspace.
Check Your Understanding
For each proposed decomposition, identify the component in the subspace and verify that the other component is orthogonal to it.
- In \(\mathbb{R}^2\), let \(W\) have orthonormal basis \(\frac{1}{\sqrt2}(1,1)^\top\), and take \(\mathbf{x}=(3,1)^\top\). Find both components.
- In \(P_2\) with \(\langle p,q\rangle=\int_{-1}^{1}p(t)q(t)\,dt\), decompose \(t^2\) relative to \(W=\operatorname{span}\{1,t\}\).
- For the matrix inner product in the worked example, find the two components of \(\begin{bmatrix}1&2\\2&0\end{bmatrix}\) relative to the same \(W\).
- Explain why subtracting the component in \(W\) produces a vector in \(W^\perp\), using the orthonormal-basis formula.
- State which part of the formula fails if the vectors spanning \(W\) are not normalized or are not mutually orthogonal.