Find the distance between two lines

A point on $L_1$ has the form $(-1,2-t,t)$ and a point on $L_2$ has the form $(1+s,2-s,1)$. The square of the distance between these points is $$ D = (2+s)^2 + (s-t)^2 + (t-1)^2.$$ The problem is to find the points where $D$ is minimized. $$\frac{\partial D}{\partial s} = 2(2+s) + 2 (s-t) = 4 + 4s - 2t $$ $$\frac{\partial D}{\partial t} = -2(s-t) + 2(t-1) = -2s + 4t - 2.$$ The critical point is where both partial derivatives vanish, i.e., when $s = -1$ and $t=0$.

Plug these back into $D$ to get the minimum square distance $D = 1^2 + 1^2 + 1^2 = 3$. The distance between the lines is $\sqrt{3}$.