In two dimensions, two lines either meet or are parallel. In three dimensions there is a third case: skew lines, which are not parallel and never meet because they don't lie in a common plane. Which formula you use depends on which case you have.
Which formula to use
Lines
How to tell
Shortest distance
Intersecting
Not parallel, and (a2−a1)⋅(b1×b2)=0
0
Skew
Not parallel, and that product is not 0
∣b1×b2∣(a2−a1)⋅(b1×b2)
Parallel
b1 and b2 are multiples of each other
∣b∣b×(a2−a1)
The formula
For two lines r=a1+λb1 and r=a2+μb2 that don't intersect, the shortest distance between them is:
d=∣b1×b2∣(a2−a1)⋅(b1×b2)
Why it works:b1×b2 is perpendicular to both lines, so the shortest connecting segment runs along it. Dividing by its length gives a unit vector in that direction, and the dot product projects the gap between the two starting points a2−a1 onto it.
Worked example
Find the shortest distance between r=i^+2k^+λ(i^+2j^−k^) and r=3j^−k^+μ(2i^−j^+k^).
Solution: Here a2−a1=−i^+3j^−3k^, b1=(1,2,−1), b2=(2,−1,1).
The dot product came out negative, which only means the cross product points the other way. The absolute value in the formula takes care of it.
Worked example: parallel lines
Find the distance between r=i^−j^+2k^+λ(i^+2j^+2k^) and r=3i^−k^+μ(i^+2j^+2k^).
Solution: Both lines have direction b=(1,2,2), so they are parallel and b1×b2=0: the skew-line formula would divide by zero. Use the parallel-line formula with a2−a1=(2,1,−3):
For a1x−x1=b1y−y1=c1z−z1 and a2x−x2=b2y−y2=c2z−z2, read off a1=(x1,y1,z1) and b1=(a1,b1,c1), and the same for the second line. The numerator of the skew-line formula is then a single determinant:
x2−x1a1a2y2−y1b1b2z2−z1c1c2
If that determinant is 0 and the lines aren't parallel, they intersect.
Common mistakes
Using the skew formula on parallel lines. If b1×b2=0, switch to the parallel-line formula instead of reporting an undefined answer.
Reading the point and direction the wrong way round. In 2x+1, the point has x1=−1 (the sign flips) and the direction ratio is 2.
Dropping the absolute value. A distance can't be negative. A negative dot product just means the cross product happened to point the other way.
Forgetting to check for intersection. A numerator of 0 means the lines meet, so the distance is 0, not "no answer".
Where this comes up in exams
Skew lines and the shortest distance between them are listed in the three-dimensional geometry units of the JEE Main 2026 and JEE Advanced 2026 syllabi, and in the 2025-26 CBSE Class XII mathematics syllabus.