# Why is $\mathbf{\hat{x}} = \sum_{j=2}^n (\mathbf{x}\cdot\mathbf{u}_j)\mathbf{u}_j = \mathbf{x} - (\mathbf{x}\cdot \mathbf{u})\mathbf{u}$?

Let $\mathbf{u}, \mathbf{u}_2,\dots,\mathbf{u}_n$ be an orthonormal basis for $\mathbb{R}^n$, and let $W = Span\{\mathbf{u}_2, \dots, \mathbf{u}_n\}$ . Then the projection of $\mathbf{x}$ onto $W$ is given by:

$\hat{\mathbf{x}} = Proj_W (\mathbf{x}) = \sum_{j=2}^n (\mathbf{x}\cdot\mathbf{u}_j)\mathbf{u}_j = \mathbf{x} - (\mathbf{x}\cdot \mathbf{u})\mathbf{u}$

I understand the first two equalities, coming from the Gram-Schmidt process, and since the vectors in $W$ are orthonormal, the term $\frac{1}{\mathbf{u}_j \cdot \mathbf{u}_j}$ is omitted. But I'm unable to derive the right side of the equation. To me it looks like $(\mathbf{x}\cdot \mathbf{u})\mathbf{u} = \hat{\mathbf{x}}$, although I know this isn't true, since $\mathbf{u}$ is not in $W$. So what exactly is $\mathbf{u}$ in this case? Could anyone please help me derive the above?

My own thoughts is that, if $\mathbf{z}$ is a vector orthogonal to $\mathbf{\hat{x}}$, then $\mathbf{z}=\mathbf{x}-\mathbf{\hat{x}}$ and $-\mathbf{z}=-\mathbf{x}+\mathbf{\hat{x}} \implies \mathbf{\hat{x}} = \mathbf{x}-\mathbf{z}$. So from the above it looks like $\mathbf{z}=(\mathbf{x}\cdot \mathbf{u})\mathbf{u}$. But how would you get this last result?

-
You have a basis, what is $\bf x$ written in terms of this basis? – David Mitra Dec 7 '11 at 16:42
Thanks, David! That's what I needed! Weird how it's so obvious after someone told you where to look... – Jodles Dec 7 '11 at 16:57

Because $\mathbf{u}, \mathbf{u}_2,\dots,\mathbf{u}_n$ is the orthonormal basis in $\mathbb{R}^n$: $$\mathbf{x} = \sum_{j=1}^n (\mathbf{x} \cdot \mathbf{u}_i) \mathbf{u}_i$$ where $\mathbf{u}_1 = \mathbf{u}$. Now subtract the first term from both sides of this equality.

-