<s>[INST] Let $M=\{(x,y,z):z=3x-y\}$. Find the orthogonal projection of a vector $v \in \mathbb{R}^3$ on $M$ and a matrix representation of $p_M$. Let $M=\{(x,y,z):z=3x-y\}$. Find the orthogonal projection of a vector $v \in \mathbb{R}^3$ on $M$ and a matrix representation of $p_M$.
I know that the orthogonal projection of two vectors is $p_vu=\frac{u \cdot v}{\|v\|^2}u$ How would I apply this to an equation.
$\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 3 &-1 \end{pmatrix} (\begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 3 &-1 \end{pmatrix})^{-1}\begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \end{pmatrix}=\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 3 &-1 \end{pmatrix} (\begin{pmatrix} 10 & -3 \\ -3 & 2 \end{pmatrix})^{-1}\begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \end{pmatrix}=\frac{1}{11}\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 3 &-1 \end{pmatrix}\begin{pmatrix} 2 & 3 \\ 3 & 10 \end{pmatrix}\begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \end{pmatrix}=\frac{1}{11}\begin{pmatrix} 2 & 3 \\ 3 & 10 \\ 3 & -11 \end{pmatrix}\begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \end{pmatrix}=\frac{1}{11}\begin{pmatrix}2 & 3 & 3 \\ 3 & 10 & -11 \\ 3 & -11 & 20 \end{pmatrix}$
 [/INST] Hints: find a set of basis $\{x_1,x_2\}$ for $M$ and write $X=[x_1 x_2]$ (each $x_i$ is a column vector and $X$ is $3\times 2$). Then, the matrix representation of $p_M$ is $X(X'X)^{-1}X'$. You need to verify that $p_M$, represented this way, is indeed the orthogonal projection onto $M$.
In general, if $X$ has full column rank, then $X(X'X)^{-1}X'$ projects orthogonally onto the column space of $X$.
Edit: To find a basis, note that each vector in $M$ can be written as
$$
(x,y,3x-y)'=(x,0,3x)'+(0,y,-y)'=x(1,0,3)'+y(0,1,-1)'.
$$
</s>