Minimum distance between two lines in $\mathbb R^n$ Given $x_0,y_0\in \mathbb R^n$ and $u,v\in \mathbb R^n\!\setminus\!\{0\}$.


*

*How to find the minimum distance between two lines $X(s)=x_0+su$ and $Y(t)=y_0+tv$?

*I am also required to set up an unconstrained convex program and solve it. There are two cases: Uniformly convex and non-uniformly convex objective functions.
 A: We notice that the decision variables are $s,\ t$ which are scalar according to the problem statement. $X(s)$ and $Y(t)$ give us two points in $n$ dimension for a given value of $s$ and $t$. The distance between two points can be given by $\lVert X(s) -Y(t) \rVert$. Now, we need to solve the following optimization problem:
$$ \min_{s,t} \ \lVert X(s) -Y(t) \rVert^2 = \min_{s,t} \ \lVert \mathbf{x}_0+s\mathbf{u}-\mathbf{y}_0-t\mathbf{v}  \rVert^2 = \min_{\mathbf{\mu} } \ \lVert \mathbf{A} \mathbf{\mu}-\mathbf{z}_0\rVert^2$$
where, $\mathbf{z}_0 = \mathbf{y}_0-\mathbf{x}_0$, $\mathbf{A}= \left[ \mathbf{u} \ -\mathbf{v} \right]$ and $\mathbf{\mu} =\left[ s \ t \right]^\top$. If we consider $\mathbf{u}$ and $\mathbf{v}$ are linearly independent, then the solution is given by:
$$\mu = (\mathbf{A}^\top \mathbf{A})^{-1}\mathbf{A}^{\top}\mathbf{z}_0.$$
If $\mathbf{v}=\lambda \mathbf{u}$, in that case, the solution can be given as: 
$$s-\lambda t = \frac{\mathbf{u}^{\top}\mathbf{z}_0}{\mathbf{\lVert \mathbf{u} \rVert^2}}.$$
