Welcome to our community

Be a part of something great, join today!

Distance from a vector to a subspace

smile

New member
Oct 15, 2013
19
Hello everyone

Here is the question

Find the distance from a vector $v=(2,4,0,-1)$ to the subspace $U\subset R^4$ given by the following system of linear equations:
$2x_1+2x_2+x_3+x_4=0$
$2x_1+4x_2+2x_3+4x_4=0$

do I need to find find a point $a$ in the subspace $U$ and write the vector $a-v$ and find the length of it?
 

Sudharaka

Well-known member
MHB Math Helper
Feb 5, 2012
1,621
Hello everyone

Here is the question

Find the distance from a vector $v=(2,4,0,-1)$ to the subspace $U\subset R^4$ given by the following system of linear equations:
$2x_1+2x_2+x_3+x_4=0$
$2x_1+4x_2+2x_3+4x_4=0$

do I need to find find a point $a$ in the subspace $U$ and write the vector $a-v$ and find the length of it?
Hi smile, :)

Let \((X,\,d)\) be a metric space and \(U\subset X\). Distance between a point \(a\in X\) and \(U\) is defined as,

\[d(a,\, U)=\mbox{Inf }\{d(a,\,y):\, y\in U\}\]

In the given problem \(v=(2,4,0,-1)\) and take any vector \(u=(x_1,\,x_2,\,x_3,\,x_4)\in U\). Then,

\[d(v,\,u)=|(x_1,\,x_2,\,x_3,\,x_4)-(2,4,0,-1)|\]

This would give you a quadratic function with four variables. Since \(v\) satisfies the given equations you can reduce that into a quadratic with two variables. Then find the minimum of that quadratic (suggestion: use the second partial derivative test).

Hope this helps. :)
 

Evgeny.Makarov

Well-known member
MHB Math Scholar
Jan 30, 2012
2,502
You could also use the fact that the shortest vector connecting $v$ to $U$ is perpendicular to $U$.

First find a basis in $U$. One way is to subtract the first equation from the second. Then you could pick any $x_3$, $x_4$, and $x_1$, $x_2$ would be uniquely determined. For example, $x_3=2$, $x_4=0$ gives vector $u_1=(0,-1,2,0)$, and $x_3=0$, $x_4=2$ gives $u_2=(2.-3,0,2)$. We have the following data:
\begin{align*}
|u_1|^2&=9\\
|u_2|^2&=17\\
(u_1,u_2)&=3\\
(v,u_1)&=-4\\
(v,u_2)&=-10
\end{align*}
Now state that the connecting vector is perpendicular to $U$:
\begin{align*}
(v-y_1u_1-y_2u_2,u_1)&= (v,u_1)-y_1|u_1|^2-y_2(u_2,u_1)=0\\
(v-y_1u_1-y_2u_2,u_2)&= (v,u_2)-y_1(u_1,u_2)-y_2|u_2|^2=0
\end{align*}
This gives two equations in $y_1$, $y_2$. The final answer is $|v-y_1u_1-y_2u_2|$.

All calculations should be rechecked.
 

Opalg

MHB Oldtimer
Staff member
Feb 7, 2012
2,725
Hello everyone

Here is the question

Find the distance from a vector $v=(2,4,0,-1)$ to the subspace $U\subset R^4$ given by the following system of linear equations:
$2x_1+2x_2+x_3+x_4=0$
$2x_1+4x_2+2x_3+4x_4=0$

do I need to find find a point $a$ in the subspace $U$ and write the vector $a-v$ and find the length of it?
Yet another method is to find an orthonormal basis for the orthogonal complement $U^\perp$ of $U$. The two given equations say that the vectors $(2,2,1,1)$ and $(1,2,1,2)$ are in $U^\perp$. By a happy coincidence, the sum and the difference of those vectors, namely $(3,4,2,3)$ and $(1,0,0,-1)$, are orthogonal to each other. So if we divide them by their lengths, we see that the vectors $e_1 = \frac1{\sqrt{38}}(3,4,2,3)$ and $e_2 = \frac1{\sqrt2}(1,0,0,-1)$ form an orthonormal basis for $U^\perp$. The projection of $v$ onto $U^\perp$ is the vector $\langle v,e_1\rangle e_1 + \langle v,e_2\rangle e_2$, and the length of that vector is the distance from $v$ to $U$. I make it $\sqrt{14}$.
 

Sudharaka

Well-known member
MHB Math Helper
Feb 5, 2012
1,621
Hi smile, :)

Let \((X,\,d)\) be a metric space and \(U\subset X\). Distance between a point \(a\in X\) and \(U\) is defined as,

\[d(a,\, U)=\mbox{Inf }\{d(a,\,y):\, y\in U\}\]

In the given problem \(v=(2,4,0,-1)\) and take any vector \(u=(x_1,\,x_2,\,x_3,\,x_4)\in U\). Then,

\[d(v,\,u)=|(x_1,\,x_2,\,x_3,\,x_4)-(2,4,0,-1)|\]

This would give you a quadratic function with four variables. Since \(v\) satisfies the given equations you can reduce that into a quadratic with two variables. Then find the minimum of that quadratic (suggestion: use the second partial derivative test).

Hope this helps. :)
Sorry, I guess my method is incorrect, as I have misread the question and calculated the distance from the point \((2,4,0,-1)\) to the subspace as opposed to the distance from the vector to the subspace. :)
 

Sudharaka

Well-known member
MHB Math Helper
Feb 5, 2012
1,621
Yet another method is to find an orthonormal basis for the orthogonal complement $U^\perp$ of $U$. The two given equations say that the vectors $(2,2,1,1)$ and $(1,2,1,2)$ are in $U^\perp$. By a happy coincidence, the sum and the difference of those vectors, namely $(3,4,2,3)$ and $(1,0,0,-1)$, are orthogonal to each other. So if we divide them by their lengths, we see that the vectors $e_1 = \frac1{\sqrt{38}}(3,4,2,3)$ and $e_2 = \frac1{\sqrt2}(1,0,0,-1)$ form an orthonormal basis for $U^\perp$. The projection of $v$ onto $U^\perp$ is the vector $\langle v,e_1\rangle e_1 + \langle v,e_2\rangle e_2$, and the length of that vector is the distance from $v$ to $U$. I make it $\sqrt{14}$.
I have a little question that perhaps you could clarify. :) How do we know that \(e_1\mbox{ and }e_2\) form a basis for \(U^\perp\)? Don't we have to show that?
 

smile

New member
Oct 15, 2013
19
I have a little question that perhaps you could clarify. :) How do we know that \(e_1\mbox{ and }e_2\) form a basis for \(U^\perp\)? Don't we have to show that?
they are obtained by using the Gram-Schmidt orthogonalization, so I think they are basis automatically, if you want to prove that just using the definition of basis.
Hope that helps.