# 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!

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}.$$

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.$

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...

• What is $v_1$?? Feb 14 '16 at 10:41
• Apparently that should be $v$ now. It seems the problem statement was edited after I had answered. Anyway, I've update my answer. Feb 15 '16 at 13:52
• How come $\pi_{U^\perp}(v_2)$ is in $U = \operatorname{span}(v)$ when it should be orthogonal to $\operatorname{span}(v)$? Jul 12 '16 at 8:36
• @IlikeSerena Note that $U$ is a span of the orthogonal. Therefore the distance between $v,U$ should be the norm of the projection onto the span of $v$. Since this question recieved many attention, I think you should fix it. Jul 6 '17 at 5:32
• @IlikeSerena, that is not the projection of $v_2$ onto $U$.
– Laz
Jul 26 '18 at 0:45