[Math] How to write the matrix of the orthogonal projection spanned by these two vectors

linear algebralinear-transformationsorthogonality

From Treil's Linear Algebra Done Wrong:

Apply Gram-Schmidt orthogonalization to the system of vectors $(1,2,3)^T, (1, 3, 1)^T$. Write the matrix of the orthogonal projection onto $2$-dimensional subspace spanned by these vectors.


Using Gram-Schmidt, I found an orthogonal basis to be
$$\left\{(1,2,3), \left(\frac{2}{7}, \frac{11}{7}, -\frac{8}{7}\right)\right\}.$$

If I define the map $$T{\bf x}= \frac{({\bf x},{\bf v}_1)}{\|{\bf v}_1\|^2}{\bf v}_1+\frac{({\bf x},{\bf v}_2)}{\|{\bf v}_2\|^2}{\bf v}_2$$
and then find where the basis vectors of $\mathbb R^3$ map to, I believe can find the matrix. But this is a mess.

Is there an easier way?

Best Answer

If you rearrange your equation just a bit, you’ll have a formula for the projection matrix: $$\begin{align} \frac{({\bf x},{\bf v}_1)}{\|{\bf v}_1\|^2}{\bf v}_1+\frac{({\bf x},{\bf v}_2)}{\|{\bf v}_2\|^2}{\bf v}_2 &= {1 \over \mathbf v_1^T \mathbf v_1} \mathbf v_1^T \mathbf x\mathbf v_1 + {1 \over \mathbf v_2^T \mathbf v_2} \mathbf v_2^T \mathbf x\mathbf v_2 \\ &= {1 \over \mathbf v_1^T \mathbf v_1} \mathbf v_1\mathbf v_1^T \mathbf x + {1 \over \mathbf v_2^T \mathbf v_2} \mathbf v_2\mathbf v_2^T \mathbf x \\ &= \left({\mathbf v_1\mathbf v_1^T\over\mathbf v_1^T\mathbf v_1} + {\mathbf v_2\mathbf v_2^T\over\mathbf v_2^T\mathbf v_2}\right)\mathbf x\end{align}.$$ Each of the terms inside of the parentheses is a $3\times3$ matrix, the matrix of orthogonal projection onto the respective basis vector, in fact.