The first line is
$ \ell_1 = P_1 + t d_1 $
with $P_1 = (2, 4, 0) $ and $ d_1 = (1 , -3 , 1 ) $
While the second line is given by
$ \ell_2 = (1,1,3) + s (-1, 4, -2) $
The vector extending from a point on $\ell_1$ to a point on $\ell_2$ is given by
$ v = P_2 + s d_2 - (P_1 + t d_1 ) = (P_2 - P1) + s d_2 - t d_1 \\
= (1,1,3) - (2, 4, 0) + s (-1, 4, -2) - t (1, -3, 1) \\
= (-1, -3, 3) + s (-1, 4, -2) - t (1, -3, 1) \\
= (-1 - s - t , - 3 + 4 s + 3 t , 3 - 2 s - t ) $
We want this vector to be perpendicular to $d_1$ and $d_2$, so we get the following two equations
$ v \cdot d_1 = 0 $, i.e. $(-1 - s - t, -3 + 4s + 3 t , 3 - 2 s - t) \cdot (1, -3, 1) = 0 $
and
$ v \cdot d_2 = 0 $, i.e. $(-1 -s -t , -3 +4s + 3 t, 3 -2 s - t) \cdot (-1, 4, -2) = 0 $
These two equations, after carrying out the dot product simplify to
$11 - 15 s - 11 t = 0$
$-17 + 21 s + 15 t = 0 $
Re-arranging, we get
$ 11 t + 15 s = 11 $
$ 15 t + 21 s = 17 $
Solving these two equations using Cramer's rule gives
$ t = \dfrac{ (11)(21) - (17)(15) }{ (11)(21) - (15)^2 } = -4 $
$ s = \dfrac{ (11)(17) - (15)(11) }{ (11)(21) - (15)^2 } = \dfrac{11}{3} $
Therefore, the first point on the first line is
$ P = P_1 + t d_1 = (2, 4, 0) - 4 (1, -3, 1) = (-2, 16, - 4) $
And the second point on the second line is
$ Q = P_2 + s d_2 = (1, 1, 3) + \dfrac{11}{3} (-1, 4, -2) = \dfrac{1}{3} (-8, 47, - 13 ) $
Therefore, the distance between the two lines is just the length $\overline{PQ}$
$\overline{PQ} = \dfrac{1}{3} \sqrt{ (-6 + 8)^2 + (48 - 47)^2 + (-12 + 13)^2 } = \dfrac{\sqrt{6}}{3} = \sqrt{ \dfrac{2}{3} } $
To verify this result, very quickly, with a more efficient method, calculate $d_1 \times d_2$:
$ N = d_1 \times d_2 = (1, -3, 1) \times (-1, 4, -2) = ( 2, 1 , 1 ) $
So the plane containing the first line and parallel to the second line is
$ \pi_1: N \cdot (r - P_1) = 0 $ , i.e. $2 (x- 2) + (y - 4) + z = 0$
(Note that $r = (x,y,z) $ )
Now use the distance formula, to find the distance of $P_2$ from $\pi_1$
$d = \dfrac{ | N \cdot (P_2 - P_1) | }{\sqrt{ N \cdot N }} = \dfrac{ |2 (-1) + (-3) + 3 |}{\sqrt{ 6} } = \dfrac{2}{\sqrt{6}} = \sqrt{ \dfrac{2}{3} } $
So the answers match.