Finding coordinates of closest approach Given two lines $l_1=\mathbf E_1+k\mathbf E'_1$ and $l_2=\mathbf E_2+\mu\mathbf E'_2$ in 3D, there exists a shortest distance between the two lines. How does one find the coordinates of the points $P$ on $l_1$ and $Q$ on $l_2$, such that $P$ and $Q$ are the points where the distance between the two lines is the shortest?
 A: $\newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}%
 \newcommand{\yy}{\Longleftrightarrow}$
${\bf d} = {\bf l}_{1} - {\bf l}_{2}$
$$
{\bf d}^{2}
=
\pars{{\bf E}_{1} + k{\bf E}_{1}' - {\bf E}_{2} - \mu{\bf E}_{2}'}^{2}
=
\pars{{\bf E} + k{\bf E}_{1}' - \mu{\bf E}_{2}'}^{2}\,,
\quad
{\bf E} \equiv {\bf E}_{1} - {\bf E}_{2}
$$
$$
{\bf d}^{2}
=
{\bf E}^{2}  + {\bf E}_{1}'^{2}k^{2} + {\bf E}_{2}'^{2}\mu^{2}
+
2{\bf E}\cdot{\bf E}_{1}'k
-
2{\bf E}\cdot{\bf E}_{2}'\mu
-
2{\bf E}_{1}'\cdot{\bf E}_{2}'k\mu
$$
Minimize ${\bf d}^{2}$ respect of $k$ and $\mu$:
\begin{align}
\partiald{{\bf d}^{2}}{k}
=
0
&\imp\quad
2{\bf E}_{1}'^{2}k
+
2{\bf E}\cdot{\bf E}_{1}'
-
2{\bf E}_{1}'\cdot{\bf E}_{2}'\mu
=
0
\\[3mm]
\partiald{{\bf d}^{2}}{\mu}
=
0
&\imp\quad
2{\bf E}_{2}'^{2}\mu
-
2{\bf E}\cdot{\bf E}_{2}'
-
2{\bf E}_{1}'\cdot{\bf E}_{2}'k
=
0
\end{align}
Now, we have two equations for $k$ and $\mu$:
$$
\left\lbrace%
\begin{array}{rcrcl}
{\bf E}_{1}'^{2}\,k
& - &
{\bf E}_{1}'\cdot{\bf E}_{2}'\,\mu
& = &
-{\bf E}\cdot{\bf E}_{1}'
\\
{\bf E}_{1}'\cdot{\bf E}_{2}'\,k
& - &
{\bf E}_{2}'^{2}\,\mu
& = &
-{\bf E}\cdot{\bf E}_{2}'
\end{array}\right.
$$
Find the values of $k$ and $\mu$. They determine the points we are looking for on the lines ${\bf l}_{1}$ and ${\bf l}_{2}$, respectively.
A: Since we can take any value on two parameters K and μ, 
let k=0 then we have a point on the line, which has coordinate same as $\overrightarrow{E1}$. (note: you can let k be other numbers but zero makes question easier.)
Now, this question becomes finding the shortest distance from a point to a line.
Let's call the point we just got point P, the shortest distance would be the length of the linesegment formed by point P and a point on the other line, we then assume the point lies on line2 is point Q. 
vector: $\overrightarrow {PQ}$= $\overrightarrow {OQ}$-$\overrightarrow {OP}$ = ($\overrightarrow{E2}$-$\overrightarrow{E1}$)+μ$\overrightarrow{E'2}$ (note: I used bracket for the sake of calculating and to emphasize that E2&E1 doesn't have parameter)
 will be the shortest distance when it's perpendicular to the parallel vector of Line2. so the dot product of $\overrightarrow {AX}$ and E'2 will be zero
$\overrightarrow {PQ}$. $\overrightarrow{E'2}$=0
[($\overrightarrow{E2}$-$\overrightarrow{E1}$)+μ$\overrightarrow{E′2}$].$\overrightarrow{E}$=0
Then you can solve μ as a constant and bring it back into $\overrightarrow{PQ}$ and find the magnitude of $\overrightarrow{PQ}$ which is the shortest distance you want.
