TITLE: Projection into a subspace?
QUESTION [6 upvotes]: Let $S$ be a nonzero subspace with orthogonal basis $(v_1, \ldots, v_k)$. Then the projection of $u$ onto $S$ is given by:
$$\operatorname{proj}_S u = \frac {v_1 \dot{} u}{\operatorname{norm} (v_1)^2}v_1 + \cdots + \frac {v_k \dot{} u}{\operatorname{norm}(v_k)^2}v_k$$

Why does the basis have to be orthogonal? Doesn't the same formula allow you to "extract" the components even if the basis isn't orthogonal?

REPLY [6 votes]: There is certainly a way to find the projection if the basis is not orthogonal, but it's more complicated.  Say you have the two non-orthogonal vectors $\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}$ and $\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix}$.  The projection of the vector $\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}$ onto the first of these vectors is found by your formula to be $\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}$ and the projection onto the second is $\begin{bmatrix} 3/2 \\ 3/2 \\ 0 \end{bmatrix}$.  If you add those together, you get $\begin{bmatrix} 5/2 \\ 3/2 \\ 0 \end{bmatrix}$.  But the orthogonal projection of that third vector onto the space spanned by the first two is actually $\begin{bmatrix} 1 \\ 2 \\ 0 \end{bmatrix}$.  So in order for the formula above to give correct results, you need orthogonality.
Generally, the orthogonal projection of the vector $x\in\mathbb R^{n\times1}$ onto the space spanned by the columns of an $n\times k$ matrix $M$ of rank $k$ is
$$
M(M^\top M)^{-1}M^\top x.
$$
(If $k=n$ then $M(M^\top M)^{-1}M^\top$ is the $n\times n$ identity matrix; if $k<n$, then $M(M^\top M)^{-1}M^\top$ is an $n\times n$ matrix of rank $k$.  The matrix is the middle that gets inverted is a $k\times k$ matrix.)