Solution (source code)

= Solution

The nonzero direction <vectors> now have <linear dependence>, so the <lines> are parallel or coincident. Subtract from $\mathbf d=\mathbf a_2-\mathbf a_1$ its <orthogonal projection> along $\mathbf v_1$; the remaining component is the shortest joining displacement. The <distance between parallel lines> is
$$
\boxed{d(L_1,L_2)=\left\|\mathbf d-\frac{\mathbf d\cdot\mathbf v_1}{\mathbf v_1\cdot\mathbf v_1}\mathbf v_1\right\|=\frac{\|\mathbf d\times\mathbf v_1\|}{\|\mathbf v_1\|}.}
$$
The second expression follows from the relation between the <cross product> and the perpendicular component. It includes distance zero for coincident <lines>.