Linear algebra projection on to a subspace What will be the projection of 
$w=(-1,2,6,0)$ on to a subspace spanned by vectors $P$ and $Q$ 
$P= ( -1,0,1,2)$ and $Q=(0,1,0,1)$
as $P$ and $Q$ are not orthogonal I don't know how to proceed further .
Kindly help
 A: First calculate the Gram matrix $G$ of $P$ and $Q$ and its inverse $G^{-1}$ to
$$G=\begin{pmatrix}\langle P,P\rangle&\langle P,Q\rangle\\
\langle Q,P\rangle&\langle Q,Q\rangle\end{pmatrix}=
\begin{pmatrix}6&2\\2&2\end{pmatrix}\text{ and }
G^{-1}=\frac{1}{8}\begin{pmatrix}2&-2\\-2&6\end{pmatrix}.$$
Call $A$ the matrix which column vectors are $P$ and $Q$.  Then $G^{-1}A^tW=\frac{1}{4}\begin{pmatrix}5\\-1\end{pmatrix}$. Now this is the coordinate vector of the projection of $W$ onto the subspace spanned by $P$ and $Q$, i.e.,
$$\frac{5}{4}P-\frac{1}{4}Q=\frac{1}{4}\begin{pmatrix}-5\\-1\\5\\9\end{pmatrix}.$$
REMARK: The key point here is that you don't have to perform the Gram-Schmidt orthogonalization explicitly to calculate the projection.
A: Like Travis suggested one way is to apply Gram-Schmidt process.
$$
{v_1 = P \\
v_2 = Q - proj_p (Q) \\
v_2 = \left[
    \begin{array}{cc|c} 0\\1\\0\\1
\end{array}
\right] - ({P .Q\over P.P}) P \\
v_2 = \left[
    \begin{array}{cc|c} 0\\1\\0\\1
\end{array}
\right] - {0+0+2\over 1+1+4} 
\left[
    \begin{array}{cc|c} -1\\0\\1\\2
\end{array}
\right]\\
}
$$
Finally we get 
$$
v_2= \left[
    \begin{array}{cc|c} 1/3\\1\\-1/3\\1/3
\end{array}
\right]
$$
$${v_1\, and\, v_2 \, forms \, orthogonal \, basis}$$ 
Now you  project w on to $${v_1 \, and \, v_2}$$
$${ proj_{subspace}(w) = ({v_1 .w\over v_1.v_1}) w + ({v_2 .w\over v_2.v_2}) w }$$
