Assume that the two lines are given in parametric form
L1(s1) = n1s1 + C1 and
L2(s2) = n2s2 + C2
where s1, s2 in (-infinity, infinity), C1 and C2 are points on their respective lines and n1 and n2 are tangent vectors.
(If they are not in parametric form, or the parametrization is not linear (w.r.t. the coordinates), a linear parametrization can always be found. E.g, starting from two planes (themselves specified as a linear relation between the three Cartesian coordinates), the two normals to each can be found. The tangent to the intersection line is the cross product or wedge product of these two normals. Then C can be found by requiring that the line belong to the two planes.)
(What is a non-linear parametrization of a line? Consider the line given by:
L(s) = (1/s)i + (0,2,3). The closure of the set of points is the line parallel to the X-axis which intersects the y-z plane at y=2, z= 3, although in terms of the s parameter you never reach that point. This line can be parametrized as L(t) = t i + (0,2,3).)
M mode: Construct |L1 – L2| or its square and minimize by taking the derivative w.r.t. s1 and s2. What a lot of work!
Pretty answer next week!