# Shortest distance between lines and the lines

1. May 29, 2012

### ezsmith

1. The problem statement, all variables and given/known data
Find the shortest distance between the lines r = (0,7,6) + t (-3,2,2) and the line r = (-3,6,-4) + s (2,-5,6)

3. The attempt at a solution
What I did was I cross product s(2,-5,6) & t(-3,2,2) then I took (0,7,6) - (-3,6,-4)
After getting both answer from the 2 steps I took the 2 equation I got and times (x) with each other. It is even correct? Because I referred this step from Shortest distance between 2 skewed lines since I have no notes or example regarding 2 lines

2. May 29, 2012

### algebrat

I didn't understand why you were doing what you said after cross product. Try giving us a conceptual recipe for your steps, such as:

The shortest segment connecting these two lines I would guess would be orthogonal to both of them. This is hard to justify (unless you come up with a slick reason), but it seems lie it might be right. So the segment should be parallel to the cross product of the directions.

We can express the connecting line as a point on the first curve plus some multiple call it u times the cross product we found earlier. We'll set this expression for the connecting line to be equal to the other skew line.

So we now have three unknowns, s,t and u, and one equation, the one for the line. So we don't have enough equations? Actually, our equation is a vector equation, so it is actually three equations, so we'll be able to solve.

Here's another method. Consider the distance squared function,

$f(s,t)=d^2(r_1(s),r_2(t))=|r_1(s)-r_2(t)|^2.$

This is a function from ℝ^2 to ℝ. Since we are trying to minimize it, we can just check for the partials $\frac{\partial}{\partial s}f(s,t)$ and $\frac{\partial}{\partial t}f(s,t)$ are both zero. The reason I squared the distance is so you wouldn't have to take the derivative of a square root. This is okay since distance is nonnegative, and is an increasing function there.

3. May 29, 2012

### ehild

You can take any vector that connects the two lines. It can be the vector b=(0,7,6)-(-3,6,-4)=(3,1,10) The projection of b onto the direction of the common normal is the distance between the lines. $$d=\vec b \cdot \vec n$$ where n is the unit normal vector and the dot means dot product.

You need to multiply the difference vector by the unit normal vector, that is, the cross product divided by its magnitude. Find the magnitude of the cross product and divide your result with it. That will be all right.

4. May 29, 2012

### algebrat

Oops, that must be what ezsmith was going for. That works nice, very fast, clever trick.

5. May 29, 2012

### ezsmith

Sorry for the late reply and thanks for the reply algebrat and ehild.. Its really helpful as I am pretty stuck earlier. Just to make sure whether I am on the right track. After doing cross product which is -22i-22j+11k. I found the magnitude of the cross product which is 33 and then I took the (3,1,10)x(-22,-22,11) and got 198. Lastly, I took 198/33 and the final answer I got was 6.

6. May 29, 2012

### ehild

The cross product is 22i+22j+11k. The magnitude is correct. When multiplying with 3,1,10, it is dot product, so use dot instead of cross. The result is correct, that means you used the correct normal vector instead of the written one.

ehild