Distance between two straight lines in space
Calculate the distance between:
$$r:(x,y,z)=(2,1,3)+k\cdot(2,1,-1)$$
$$r':(x,y,z)=(-1,-1,4)+k\cdot(1,3,-2)$$
We start by determining the relative position of the straight lines.
First we verify that the governing vectors are not linearly dependent: $$\left. \begin{array}{l} \vec{v}=(2,-1,1) \\ \vec{v}'=(1,3,-2) \end{array} \right\} \Rightarrow \dfrac{2}{1}\neq\dfrac{-1}{3}\neq\dfrac{1}{-2}$$
The straight lines $r$ and $r'$ intersect or cross.
We take a point $A$ of $r$ and a point $A'$ of $r'$, and see if $\{\overrightarrow{AA'},\vec{v},\vec{v}'\}$ are linearly dependent or independent: $$\left. \begin{array}{l} A = (2, 1, 3)\\ A' = (-1, -1, 4) \end{array} \right\} \Rightarrow \overrightarrow{AA'}=(-3,-2,1)$$
$$\begin{vmatrix} 2 & 1 & -3 \\ -1 & 3 & -2 \\ 1 & -2 & 1 \end{vmatrix} =0 \Rightarrow \text{rank}\big(\{\overrightarrow{AA'},\vec{v},\vec{v}'\}\big)=0$$
Therefore the straight lines r and r' intersect and $\text{d}(r,r') = 0$.
$\text{d}(r,r') = 0$