# Distance between point in $\mathbb{R}^4$ and a subspace

Let $$L = (\operatorname{span}{(1,0,2,1),(2,1,2,3),(0,1,-2,1)})^\perp$$ What is the distance between the point $p = (1,0,0,1)$ and the subspace $L$?

Here is what I have done:

1) calculated the orthogonal base to be:

$$L = \operatorname{span}\{ (-2,2,1,0),(-1,-1,0,1)\}$$

2) calculated the orthonormal base to be:

$$L=\operatorname{span}\left\{\left(-\frac23, \frac23, \frac13, 0\right),\left(-\frac1{\sqrt3},-\frac1{\sqrt3},0,\frac1{\sqrt3}\right)\right\}$$

so it looks like the subspace is of $\dim L = 2$ and therefore a plain. my thoughts are that I need to figure out the projection of $p$ on to the plain spanned by $L$ and then calculate $\| p - \operatorname{proj}(p) \|$.

where I'm stuck is: I'm not sure if to calculate the projection of $p$ onto $L$ by using the orthonormal base or the orthogonal space. I get two different results.

I'm also not sure how to figure out this projection. I know that the projection of $p$ onto another vector $w$ is calculated by $$\frac{\langle p, w\rangle}{\langle w,w\rangle}$$ but onto a plain I'm not sure.

• I have edited your question to make it readable. Please use Mathjax next time. – mechanodroid Mar 20 '18 at 13:06

You're almost there.

The ONB for $L$ is

$$\{a_1, a_2\} = \left\{\frac13 (-2,2,1,0), \frac1{\sqrt{3}}(-1,-1,0,1)\right\}$$ The orthogonal projection of $x \in \mathbb{R}^4$ onto $L$ is given by

$$Px = \langle x, a_1\rangle a_1 + \langle x, a_2\rangle a_2$$

In particular, for $x = (1,0,0,1)$ we get

$$Px = \frac19 (4,-4,-2,0)$$

The distance of $x$ to $L$ is given by $\|x - Px\|$.

You can also solve it by projecting onto $L^\perp$. To find the ONB for $L^\perp$, first note that $$(0,1,-2,1) = 2(1,0,2,1)-(2,1,2,3)$$

so in fact $L^\perp = \operatorname{span}\{(1,0,2,1), (2,1,2,3)\}$.

Now apply Gram-Schmidt:

$$e_1 = \frac1{\sqrt{6}}(1,0,2,1)$$ $$(2,1,2,3) - \frac1{6}\Big\langle (2,1,2,3), (1,0,2,1)\Big\rangle (1,0,2,1) = \frac12 (1,2,-2,3) \implies e_2 = \frac{1}{\sqrt{18}}(1,2,-2,3)$$

Thus $\{e_1, e_2\}$ is an ONB for $L^\perp$.

The orthogonal projection of $x \in \mathbb{R}^4$ onto $L^\perp$ can be calculated as $$Qx = \langle x, e_1\rangle e_1 + \langle x, e_2\rangle e_2$$

For $x = (1,0,0,1)$ we get

$$Qx = \frac19(5,4,2,9)$$

and then the distance of $x$ towards $L$ is $\|Qx\|$. To check the result is correct, verify that indeed $Px + Qx = x$.

• Thank you very much for the very detailed explanation – eventhorizon02 Mar 20 '18 at 19:30