Finding points on a line that are closest 
Find the points that give the shortest distance between the lines$$\begin{pmatrix}x\\y\\z\end{pmatrix}=\begin{pmatrix}2-t\\-1+2t\\-1+t\end{pmatrix}\\\begin{pmatrix}x\\y\\z\end{pmatrix}=\begin{pmatrix}5+3s\\0\\2-s\end{pmatrix}$$

So I subtracted the second line from the first to get these two equations:
$\begin{pmatrix}-t-3s-3\\ -1+2t\\ t+s-3\end{pmatrix}\cdot \begin{pmatrix}-1\\ 2\\ 1\end{pmatrix}=0$
$\begin{pmatrix}-t-3s-3\\ -1+2t\\ t+s-3\end{pmatrix}\cdot \begin{pmatrix}3\\ 0\\ -1\end{pmatrix}=0$
I know I am supposed to rearrange them together two get a system of equations but I am not sure how.
Any help please?
 A: $$\begin{pmatrix}-t-3s-3\\ -1+2t\\ t+s-3\end{pmatrix}\cdot \begin{pmatrix}-1\\ 2\\ 1\end{pmatrix}=0\implies t+3s+3-2+4t+t+s-3 = 6t+4s=2$$
$$\begin{pmatrix}-t-3s-3\\ -1+2t\\ t+s-3\end{pmatrix}\cdot \begin{pmatrix}3\\ 0\\ -1\end{pmatrix}=0\implies -3t-9s+9-t-s+3=-4t-10s=-12$$
Sove above equations for $t$ and $s$. 
A: Another approach is to use calculus and minimize the distance between arbitrary points on the lines, which is a function of $s$ and $t$. Distance is non-negative, so it suffices to minimize the squared distance, which is easier to differentiate.
The squared distance $dsq(s,t)$ between two arbitrary points, one on each line, is $$dsq(s,t)=\big((2-t)-(5+3s)\big)^2+\big(-1+2t\big)^2+\big((-1+t)-(2-s)\big)^2.$$
Then compute the partial derivatives and solve $\dfrac{\partial\,dsq(s,t)}{\partial s}=\dfrac{\partial\,dsq(s,t)}{\partial t}=0$. Don’t bother to expand or simplify anything until after finding the derivatives with the chain rule.
You should get $12t+8s-4=8t+20s+12=0$, which is pretty easy to solve.
A: Two lines in $\mathbb R^3$ either intersect (distance = 0) or not intersect (distance = the distance between two parallel planes on which the two lines lie accordingly). Classify it first, then use $u\times v$, where $u, v$ indicate the direction of the two lines, to find the normal for the plane. Hope that helps!
