At time t=t, the positions are A′ and B′.
Now, OA′=d1−v1t and OB′=d2−v2t
Separation is l=√OA′2+OB′2=√(d1−v1t)2+(d2−v2t)2
For shortest distance, dldt=0
⟹−2v1(d1−v1t)−2v2(d2−v2t)2√(d1−v1t)2+(d2−v2t)2=0
⟹(v1d1+v2d2)−t(v21+v22)=0
⟹t=v1d1+v2d2v21+v22 for least separation.
Now, separation at this time is-
OA′=d1−v1t=v2(v2d1−v1d2)v21+v22
OB′=d2−v2t=−v1(v2d1−v1d2)v21+v22
l=√OA′2+OB′2=|v2d1−v1d2| as distance is always +ve.