Whilst working on vectors I have come across a lot of problems like this. I am able to work it out for the shortest distance from a vector to a point, but not from a vector to a vector. Here is my usual method for a question asking the shortest distance from a vector (passing through $A$ and $B$) to a point $C$: $$\vec{OA}=a$$ $$\vec{OB}=b$$ $$\vec{OC}=c$$ Where $O$ is the origin. We know that the equation for a line passing through $A$ and $B$ is: $$\vec{r}=\mu(b-a)+a$$ we also know that at the closest distance a line from $C$ to $\vec{r}$ is perpendicular to $\vec{r}$. I would now define: $$\vec{r}=\begin{pmatrix}\mu(b_1-a_1)+a_1\\\mu(b_2-a_2)+a_2\\\mu(b_3-a_3)+a_3\end{pmatrix}=\begin{pmatrix}d_1\\d_2\\d_3\end{pmatrix}$$ so the distance from $\vec{r}$ to $C$ is: $$l=\sqrt{(d_1-c_1)^2+(d_2-c_2)^2+(d_3-c_3)^2}$$ now find the point at which $\frac{dl}{d\mu}=0$ solving for $\mu$ and subbing into the equation.
However, I am aware that there are much easier methods for find the point $N$ and the shortest distance $|\vec{NC}|$ involving the fact that $\vec{r}\bullet\vec{NC}=0$ or potentially cross product as well. Does anyone have a tutorial for this method? Also, how would I solve this same problem but finding the minimum distance between two vectors? Thanks
For problems like this one you don't need derivatives.
Suppose that you know the coordinates of points $A(x_A, y_A, z_A)$, $B(x_B, y_B, z_B)$ and components of vectors $\vec a=(a_x,a_y,a_z)$, $\vec b=(b_x,b_y,b_z)$. The shortest distance between lines is represented with segment $CD$ and that segment is prependicular both to $\vec a$ and $\vec b$.
Now you have:
$$AC=\mu \vec a$$
$$BD=\lambda \vec b$$
$$\vec {CD} \bot \vec a \implies \vec{CD}\cdot \vec a=0$$
$$\vec {CD} \bot \vec b \implies \vec{CD}\cdot \vec b=0$$
...or, in scalar form:
$$x_C-x_A=\lambda a_x$$
$$y_C-y_A=\lambda a_y$$
$$z_C-z_A=\lambda a_z$$
$$x_D-x_B=\mu b_x$$
$$y_D-y_B=\mu b_y$$
$$z_D-z_B=\mu b_z$$
$$(x_D-x_C)a_x+(y_D-y_C)a_y+(z_D-z_C)a_z=0$$
$$(x_D-x_C)b_x+(y_D-y_C)b_y+(z_D-z_C)b_z=0$$
You have 8 linear equations and 8 unknowns: $x_C, y_C, z_C, x_D, y_D, z_D, \lambda, \mu$: