# Find the shortest distance between two lines and their coordinates.

$$g_1: \vec x = \vec b_1 +s \vec r_1, s, \in \mathbb{R}$$ $$g_2: \vec x = \vec b_2 +t \vec r_2, t, \in \mathbb{R}$$

Given this information calculate the values of $$s$$ and $$t$$. Using that find the coordinates where the distance is the shortest and then calculate the actual shortest distance between $$g_1$$ and $$g_2$$.

Here is my attempt.

$$F_{g_1}=(1+2s \ | \ 6 \ | \ 1+s)$$ $$F_{g_2}=(6+9t \ | \ 8+6t \ | \ 9+9t)$$

$$\vec {F_{g_1}F_{g_2}}= \vec f_{g_2}-\vec f_{g_1}= \begin{bmatrix}5+9t-2s\\2+6t\\8+9t-s\end{bmatrix}$$

1. $$\vec {F_{g_1}F_{g_2}} \cdot \vec r_1= \vec 0 \implies 27t-5s= -18$$
2. $$\vec {F_{g_1}F_{g_2}} \cdot \vec r_2= \vec 0 \implies 198t-27s= -129$$

Using Gaussian Elimination I get that $$t= \frac {-53}{87}$$ and $$\frac {9}{29}$$, which I then put back into the equation and I get the coordinates:

$$F_{g_1}=(\frac{47}{29} \ | \ 6 \ | \ \frac{38}{29})$$ $$F_{g_2}=(\frac{15}{29} \ | \ \frac{126}{29} \ | \ \frac{102}{29})$$

$$\vec {F_{g_1}F_{g_2}}= \vec f_{g_2}-\vec f_{g_1}=\begin{bmatrix}\frac{-32}{29}\\\frac{-48}{29}\\\frac{64}{29}\end{bmatrix}$$

Therefore $$d(g_1,g_2) = |\vec {F_{g_1}F_{g_2}}|= \frac{16\sqrt{29}}{29} \approx 3.0$$

Im confused about two things. Firstly, if this is correct and if it is correct then how do we know that this is actually the shortest distance between the two line?

• Why would you want to find the points when there is a direct formula for the shortest distance between two skew lines?
– Sam
Dec 29, 2019 at 15:36
• It's just a question from a past paper. It just says to find them.
– user736003
Dec 29, 2019 at 15:39
• When you are asking to see why it's minimum, are you talking about your equations 1 and 2? Dec 29, 2019 at 15:48
• The minimum distance is referring to the minimum distance between the lines $g_1$ and $g_2$.
– user736003
Dec 29, 2019 at 15:50
• Duplicate of math.stackexchange.com/questions/1414285/…
– Sam
Dec 29, 2019 at 16:36

Let's choose a point on $$g_1$$ and a point on $$g_2$$. The relative position of one point with respect to the other is $$\vec l(s,t) =(\vec b_2+t\vec r_2)-(\vec b_1+s\vec r_1)$$ We say that the distance between lines is the minimum of $$|\vec l(s,t)|$$. To simplify calculations, this will also be the minimum of $$|\vec l(s,t)|^2=\vec l(s,t)\cdot \vec l(s,t)$$. Now just take the derivatives with respect to $$s$$ and $$t$$ and set them to $$0$$: \begin{align}\frac{d}{ds}(\vec l(s,t)\cdot \vec l(s,t))&=-2\vec r_1\cdot \vec l(s,t)&=0\\\frac{d}{dt}(\vec l(s,t)\cdot \vec l(s,t))&=2\vec r_2\cdot \vec l(s,t)&=0\end{align} These is how you get your equations 1 and 2.
Decompose $$\vec{F_{g_1}F_{g_2}}=\lambda_1\vec{r_1}+\lambda_2\vec{r_2}+\vec{v}$$ where $$\vec{v}\in\operatorname{span}\{\vec{r_1},\vec{r_2}\}^{\perp}$$ then is it easy to see if $$\vec{v}\neq \vec{0}$$ that: $$\vec{v}=\pm\langle \vec{b_2-b_1},\frac{\vec{v}}{||\vec{v}||}\rangle \frac{\vec{v}}{||\vec{v}||}$$ is indenpendant from $$\lambda_1$$ and $$\lambda_2$$ and clearly $$|\vec{F_{g_1}F_{g_2}}|^2=\langle\lambda_1\vec{r_1}+\lambda_2\vec{r_2},\lambda_1\vec{r_1}+\lambda_2\vec{r_2}\rangle +\langle \vec{v},\vec{v}\rangle$$ is minimal if and only if $$\lambda_1=\lambda_2=0$$.
The line joining the two points $$\vec x_1=\vec b_1 +s \vec r_1$$ and $$\vec x_2=\vec b_2 +t \vec r_2$$ is parallel to
$$\vec x_1-\vec x_2=\vec b_1-\vec b_2+s\vec r_1-t\vec r_2$$
And if this is the shortest line between $$g_1$$ and $$g_2$$, it must be perpendicular to both $$\vec r_1$$ and $$\vec r_2$$. You can evaluate all the products in the two equations $$(\vec b_1-\vec b_2+s\vec r_1-t\vec r_2).\vec r_1=0$$ $$(\vec b_1-\vec b_2+s\vec r_1-t\vec r_2).\vec r_2=0$$
and get two equations in $$s$$ and $$t$$ of the form $$as+bt=e$$ $$cs+dt=f$$ which I expect you know how to solve.