How to find distance between vector and a subspace? 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!
 A: Using Lagrange multipliers: minimum of
$$(x - 9)^2 + y^2 + z^2$$
(distance from $(x,y,z)$ to $(9,0,0)$)
with restriction
$$x + 2y + 2z = 0.$$
($(x,y,z)\in U$)
The Lagrange system:
$$2(x-9) = \lambda,$$
$$2y = 2\lambda,$$
$$2z = 2\lambda,$$
$$x + 2y + 2z = 0.$$
Solution:
$y = \lambda = z\implies -8z = 2x = 18 + \lambda = 18 + z\implies  y = z = -2\implies x = 9 + z/2 = 8.$
A: 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}.$$
A: The projection of $v_2$ on $U^\perp=\operatorname{span}(v)$ is:
$$\pi_{U^\perp}(v_2) = \frac{(v_2 \cdot v)}{(v\cdot v)}v$$
This is the connecting vector between $U$ and $v_2$, which is perpendicular to U.
Therefore the requested distance is its length:
$$d(v_2,U)=\|\pi_{U^\perp}(v_2)\| = \left\|\frac{(v_2 \cdot v)}{(v\cdot v)}v\right\|$$
Fill in the numbers...
