The shortest distance \( D \) between two skew lines can be calculated using the formula:
\[
D = \frac{|\vec{b} \cdot (\vec{a}_1 \times \vec{a}_2)|}{|\vec{a}_1 \times \vec{a}_2|}
\]
where \( \vec{b} \) is the vector connecting a point on each line, and \( \vec{a}_1 \) and \( \vec{a}_2 \) are the direction vectors of the two lines.
Step 1:
Write the direction vectors and the point connecting the two lines.
For the first line, the direction vector \( \vec{a}_1 = (1, -1, -1) \).
For the second line, the direction vector \( \vec{a}_2 = (3, 2, -1) \).
The connecting vector \( \vec{b} \) can be taken as the vector from the point \( (-1, 3, 1) \) on the first line to the point \( (0, 1, -1) \) on the second line:
\[
\vec{b} = (0 - (-1), 1 - 3, -1 - 1) = (1, -2, -2)
\]
Step 2:
Compute the cross product \( \vec{a}_1 \times \vec{a}_2 \):
\[
\vec{a}_1 \times \vec{a}_2 = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} 1 & -1 & -1 3 & 2 & -1 \end{vmatrix}
\]
Expanding the determinant:
\[
= \hat{i} \begin{vmatrix} -1 & -1 2 & -1 \end{vmatrix} - \hat{j} \begin{vmatrix} 1 & -1 \\ 3 & -1 \end{vmatrix} + \hat{k} \begin{vmatrix} 1 & -1 \\ 3 & 2 \end{vmatrix}
\]
\[
= \hat{i}(1 - (-2)) - \hat{j}(1 - (-3)) + \hat{k}(2 + 3)
\]
\[
= \hat{i}(3) - \hat{j}(4) + \hat{k}(5)
\]
\[
= (3, -4, 5)
\]
Step 3:
Compute the dot product \( \vec{b} \cdot (\vec{a}_1 \times \vec{a}_2) \):
\[
\vec{b} \cdot (3, -4, 5) = (1, -2, -2) \cdot (3, -4, 5) = 1(3) + (-2)(-4) + (-2)(5) = 3 + 8 - 10 = 1
\]
Step 4:
Compute the magnitude of \( \vec{a}_1 \times \vec{a}_2 \):
\[
|\vec{a}_1 \times \vec{a}_2| = \sqrt{3^2 + (-4)^2 + 5^2} = \sqrt{9 + 16 + 25} = \sqrt{50} = \sqrt{14}
\]
Step 5:
Finally, compute the shortest distance:
\[
D = \frac{|1|}{\sqrt{14}} = \frac{3}{\sqrt{14}} \text{ unit.}
\]