# Orthogonal projection onto a subspace

Let $$v_1=\begin{pmatrix}1\\ 1\\ 1\\ 0\end{pmatrix}$$ and $$v_2 = \begin{pmatrix}0\\ 1\\ 1\\ 1\end{pmatrix}$$. Find the orthogonal projection of $$v = \begin{pmatrix}3\\ 2\\ 1\\ 0\end{pmatrix}$$ onto $$V= \operatorname{span} (v_1,v_2)$$.

If I have $$A= \begin{pmatrix}1&0\\ \:1&1\\ \:1&1\\ \:0&1\end{pmatrix}$$ and compute the projection matrix $$P=A(A^TA)^{-1}A^T = \begin{pmatrix}\frac{3}{5}&\frac{1}{5}&\frac{1}{5}&-\frac{2}{5}\\ \frac{1}{5}&\frac{2}{5}&\frac{2}{5}&\frac{1}{5}\\ \frac{1}{5}&\frac{2}{5}&\frac{2}{5}&\frac{1}{5}\\ -\frac{2}{5}&\frac{1}{5}&\frac{1}{5}&\frac{3}{5}\end{pmatrix}$$ then how does this help? I'm not sure I've entirely understood the idea of orthogonal projection?

If you apply Gram-Schmidt to $$\{v_1,v_2\}$$, you will get $$\{e_1,e_2\}$$, with$$e_1=\frac1{\sqrt3}(1,1,1,0)\quad\text{and}\quad e_2=\frac1{\sqrt{15}}(-2,1,1,3).$$Therefore, the orthogonal projection of $$v$$ onto $$\operatorname{span}\bigl(\{v_1,v_2\}\bigr)$$ is $$\langle v,e_1\rangle e_1+\langle v,e_2\rangle e_2$$, which happens to be equal to $$=\frac15\left(12,9,9,-3\right)$$.