# Vector Project onto Subspace

So the question is:
Let S be the subspace of $\mathbb{R}^3$ spanned by the vectors $u_2 = \begin{pmatrix} \frac{2}{3}\\\frac{2}{3}\\\frac{1}{3}\end{pmatrix} u_3 = \begin{pmatrix} \frac{1}{\sqrt{2}}\\\frac{-1}{\sqrt{2}}\\0\end{pmatrix}$. Let $x=(1,2,2)^T$. Find the projection p of x onto S. Show that $(p-x)\perp u_2$ and $(p-x)\perp u_2$.

I understand how to show that they are perpendicular and I actually found the answer for the projection. It's:
$\begin{pmatrix} \frac{23}{18}\\\frac{41}{18}\\\frac{8}{9} \end{pmatrix}$

The problem is, i have no idea why i am doing what I am doing, I just followed my notes. Can someone explain why I was supposed to do:
$(xu_2)u_2 + (xu_3)u_3$
To find p.

-
So, the orthogonal projection. (This has nothing to do with projective space BTW.) Notice $\mathcal{B}=\{u_2,u_3\}$ forms an orthonormal basis for the subspace spanned by the two vectors, hence if $p$ is in the space it can be written as $p=\alpha u_2+\beta u_3$, and dot-producting this expression with $u_2$ (respectively $u_3$) gives $\alpha=p\cdot u_2$ (respectively $\beta=p\cdot u_3$). Furthermore, the orthogonality conditions tell us that $p\cdot u_2=x\cdot u_2$ and $p\cdot u_3=x\cdot u_3$, so there you have it. – anon Oct 12 '12 at 2:02
@anon i kind of had you until $p=\alpha u_2 + \beta u_3$ and then the whole "dot-producting this expression" lost me. Can you rephrase that please? – Charlie Yabben Oct 12 '12 at 2:08
Sure. Since $u_2,u_3$ are basis vectors for the subspace that $p$ is an element of, $p$ can be written as a linear combination of $u_2$ and $u_3$, say with coefficients $\alpha,\beta$. That is, $p=\alpha u_2+\beta u_3$ for some $\alpha,\beta$. We can solve for the coefficients using dot products and the fact that $u_2,u_3$ are orthonormal. For instance, to solve for $\alpha$, take the dot product with $u_2$: $$p\cdot u_2=(\alpha u_2+\beta u_3)\cdot u_2=\alpha(u_2\cdot u_2)+\beta(u_2\cdot u_3)=\alpha(1)+\beta(0)=\alpha,$$ i.e. $\alpha=p\cdot u_2$ and similarly $\beta=p\cdot u_3$. Anything else? – anon Oct 12 '12 at 2:14
@anon omg that is so freakin easy, i don't know why i didn't get it before, that makes perfect sense. So out of curiosity a vector dotted with itself will always be 1? $u_2 \cdot u_2 =1$? P.S: Please submit an answer, I would love to accept it – Charlie Yabben Oct 12 '12 at 2:19
A vector dotted with itself will be $1$ if and only if it is a "unit" vector, which in Euclidean space means of length one. It just so happens that the $u_2$ and $u_3$ you were given were each unit vectors and were orthogonal to each other; if these facts weren't the case, this computation would be much more involved. Now that you understand the solution (hopefully), you can submit an answer to your own question and have it peer reviewed and graded and constructively criticized and so forth - much better in my opinion. – anon Oct 12 '12 at 2:23

Let $\{v_1,\dotsc,v_m\}$ be a basis for a subspace $V$ of $\Bbb R^n$. The matrix of the orthogonal projection onto $V$ is $$P=A\left(A^\top A\right)^{-1}A^\top$$ where $A$ is the matrix whose columns are $\{v_1,\dotsc,v_m\}$. A nice discussion of this can be found in these notes.
In our case we have $$A= \left[\begin{array}{rr} \frac{2}{3} & \frac{1}{2} \, \sqrt{2} \\ \frac{2}{3} & -\frac{1}{2} \, \sqrt{2} \\ \frac{1}{3} & 0 \end{array}\right]$$ Thus $$P = \left[\begin{array}{rrr} \frac{17}{18} & -\frac{1}{18} & \frac{2}{9} \\ -\frac{1}{18} & \frac{17}{18} & \frac{2}{9} \\ \frac{2}{9} & \frac{2}{9} & \frac{1}{9} \end{array}\right]$$ Now, the projection of $v=(1,2,2)$ is $$Pv= \left(\frac{23}{18},\,\frac{41}{18},\,\frac{8}{9}\right)$$