# [SOLVED]Distance Between a Subspace and a Vector

#### Sudharaka

##### Well-known member
MHB Math Helper
Hi everyone,

I just want to confirm my answer to this question.

Question:

Find the distance between a vector $$v$$ and a subspace $$U$$ in a Euclidean space $$V$$.

Here what we have to find essentially, is the length of the projection of $$v$$ to the orthogonal compliment, $$U^\perp$$ of $$U$$. Hence if we can find a orthogonal basis of $$U^\perp$$; say $$\{e_1,\,e_2,\,\cdots,\,e_n\}$$ then the distance is given by,

$d=\left|\frac{v.e_1}{e_1. e_1}e_1+\cdots+\frac{v.e_n}{e_n. e_n}e_n\right|$

To find the orthogonal basis we might want to use the Gram-Schimdt orthogonalization procedure.

Let us take an example. Let $$v=(1,\,2,\,3,\,4,\,5)$$ and the subspace $$U\subset \mathbb{R}^5$$ given by,

$x_1+2x_2+3x_3+4x_4=0$

$5x_1+6x_2+7x_3+8x_4=0$

Therefore we have that $$v_1=(1,\,2,\,3,\,4,\,0)\mbox{ and }v_2=(5,\,6,\,7,\,8,\,0)$$ as linearly independent vectors of $$U^\perp$$. Now using the Gram-Schimdt orthogonalization procedure we get,

$e_1=v_1=(1,\,2,\,3,\,4,\,0)$

$e_2=v_2-\frac{v_2 . e_1}{e_1. e_1}e_1=\left(\frac{8}{3},\,\frac{4}{3},\,0,\,-\frac{4}{3},\,0\right)$

Now that we have found a orthogonal basis for $$U^\perp$$ we can find the distance as,

$d=\left|\frac{v.e_1}{e_1. e_1}e_1+\frac{v.e_2}{e_2. e_2}e_2\right|=|e_1|=\sqrt{30}$

Am I correct?

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Yup. All correct.

#### Sudharaka

##### Well-known member
MHB Math Helper
Yup. All correct.
Wow, that's great. I have finally understood something. Thanks very much for the confirmation.