How to find matrix of orthogonal projection from gram-schmidt orthogonalization I'm having a little difficulty understanding Gram-Schmidt orthogonalization. I have a problem to apply Gram-Schmidt orthogonalization to the system of vectors $(1,1,1)^T, (1,2,1)^T$ then write the matrix of the orthogonal projection onto 2-dimensional subspace spanned by these vectors. After applying gram-schmidt I found $v_1 = (1,1,1)^T, v_2 = (-\frac{1}{3}, \frac{2}{3}, \frac{1}{3})^T$. I'm not sure what to do next to find the matrix of the orthogonal projection onto 2-dimensional subspace spanned by these vectors. Also, what exactly does gram-schmidt orthogonalization find? I'm just a little confused.
 A: Hint; your final vectors are not correct. The point of GS it to get an orthogonal set of vectors. Are yours orthogonal? You are starting off with two non orthogonal vectors , that is
$v_1=( 1 , 1 , 1)$ and $v_2= ( 1 , 2 ,1)$
The GS algorithm proceeds as follows;
let $w_1=(1,1,1)$
then we define $$w_2= v_2- \frac{\langle v_1 , w_1 \rangle}{\langle w_1 , w_1 \rangle} w_1$$
$$w_2=(1,2,1)-(4/3,4/3,4/3)=(-1/3,2/3,-1/3)$$
and it can be shown now that the set
$$S=\{w_1,w_2\}$$ is orthogonal and also spans the same subspace as the original vectors v.
If we normalize S to say $$S_n=\{(1/3,1/3,1/3),(\frac{-1}{\sqrt6},\sqrt{\frac{2}{3}},\frac{-1}{\sqrt6})\}$$
In general to find the projection matrix P, you first consider the matrix A with your vectors from $S_n$ as columns, that is $$A=\begin{bmatrix} 1/3 & \frac{-1}{\sqrt6} \\ 1/3 & \sqrt{\frac{2}{3}} \\ 1/3 & \frac{-1}{\sqrt6} \\ \end{bmatrix}$$
that is, we will have the orthogonal projection matrix equal to, 
$P=A(A^{T}A)^{-1}A^{T}$
A: Gram-Schmidt finds, given a basis of a subspace, an orthonormal basis of this subspace. Its main tool is the following formula, which defines the orthogonal projection of a vector $\vec v$ onto another vector $\vec u$:
$$p_{\vec u}(\vec v)=\frac{(\vec u,\vec v)}{(\vec u,\vec u)}\vec u.$$
What you should do:
Find an orthonormal basis of your subspace and complete it in an orthonormal basis of $\mathbf R^3$. In this orthonormal basis, the matrix of the orthogonal projection on the subspace (generated by the first two vectors) is simply:
$$B=\begin{bmatrix} 1&0&0\\0&1&0\\0&0&0 \end{bmatrix}$$
Now the matrix of the projection in the original basis is given by:
$$A=PBP^{-1}$$
where $P$ is the change of basis matrix from the original basis to the new one.
