[Math] How to find distance between vector and a subspace

linear algebravector-spaces

Well, this is question from a test that I had, I didn't know how to answer it so I am forwarding this to you:

Consider $v\:=\:\begin{pmatrix}\frac{1}{3} \\\frac{2}{3}\: \\\frac{2}{3}\end{pmatrix}$. Let $U\:=(\:span\left(v\right))^⊥$
and let $v_2\:=\:\begin{pmatrix}9 \\0 \\0\end{pmatrix}$

How to find the distance between $v_2$ and $U$? I don't know the right method, tnx!

Best Answer

The projection matrix is given as $P=A(A^TA)^{-1}A$. In this case $A=v$, so the projection matrix reduces to $$ P = \frac19\begin{bmatrix}1&2&2\\2&4&4\\2&4&4\end{bmatrix}.$$ Thus evaluating $Pv_2$, we get $$ Pv_2 = \frac19\begin{bmatrix}9\\18\\18\end{bmatrix} = \begin{bmatrix}1\\2\\2\end{bmatrix}. $$ The question is reduced to finding the distance between $v_2$ and this vector. This is easy; the answer is $$\sqrt{(9-1)^2+2^2+2^2} = \sqrt{72} = 6\sqrt{2}.$$