Search 83,450 tutors
FIND TUTORS

How to find a distance between two parallel lines?

Suppose, one have two parallel lines given by the equations:
 
y=mx+b1 and y=mx+b2. Remember, if the lines are parallel, their slopes must be the same, so m is the same for two lines, hence no subscript for m. How would one approach the problem of finding the distance between those lines?
 
First, if one draws a picture, he or she shall immediately realize that if a point  is A chosen on one of the lines, with coordinates (x1, y1), and a perpendicular line is drawn from that point to the second line, the length of the segment of this new line between two parallel lines give us the sought distance. Let us denote the point of intersection of our perpendicular line with the second line as B(x2,y2).
 
What do we know of point A and B?
 
First, since A lies on the first parallel line, its coordinates must satisfy the equation for the first line, that is,
 
y1=mx1+b1       (1)
 
Same is true for B and the second line. So we can write:
 
y2=mx2+b2       (2)
 
We also know that line AB is perpendicular to both parallel lines. It is a known fact that the slope of the line, which is perpendicular to the given line, is inverse reciprocal of the slope of that line. So the line AB MUST have the slope equal to -1/m. The slope of the line connecting two points, A and B, is given by:
 
slope=(y2-y1)/(x2-x1). In this case it is -1/m. So we obtain:
 
(y2-y1)/(x2-x1)=-1/m           (3)
 
The distance between two points, A and B, is given by:
 
d=√[(y2-y1)2+(x2-x1)2]        (4)
 
From equations (1) and (2) we obtain:
 
(y2-y1)=m(x2-x1)+(b2-b1)    (5)
 
Plug in (y2-y1) from eq. (5) into eq. (3) and solve for (x2-x1). We obtain upon solving:
 
(x2-x1)=m(b2-b1)/(m2+1);   (6)
 
 
Substituting (6) into (3) immediately yields the following:
 
(y2-y1)=-(b2-b1)/(m2+1)      (7)
 
Now final step is to plug eq. (6) and (7) into eq. (4). After some transformation we obtain:
 
d=√[(b2-b1)2/(m2+1)2+m2(b2-b1)2/(m2+1)2]=[|b2-b1|/(m2+1)]√(m2+1)
 
Final answer is as follows:
 

d=|b2-b1|/√(m2+1)   (8)

Comments

Hi Kirill,
You can also get this formula without using coordinates, by relating the perpendicular distance d between the two lines to their vertical distance Δb=|b2-b1| in a right triangle whose hypotenuse is Δb. The slope of either line can be written as m=tanθ, where θ is the slope angle and, by similarity, also the angle between d and Δb, so that
m = tanθ = √(Δb2-d2) /d ⇒ m2 = (Δb2-d2) /d2 = Δb2/d2 -1 ⇒ Δb2/d2 = m2+1 ⇒ d = Δb/√(m2+1).
Hi, Andre:
 
I realize that. However, I met a few students, who need to operate with slopes and need to know that slopes of a line and a perpendicular to it are inverse reciprocal to each other, but those students have no idea about trigonometry. I will make a second post citing your derivation, for more advanced students.
Thanks for citing me in your second post. Actually, the students do not need to know trigonometry for this, only the Pythagorean theorem and the similarity theorem AAA.
You can nicely demonstrate the formula by shining two flashlights (better: laser pointers) parallel to each other at an angle at a surface. You can even measure the distance d between the flashlights and Δb between the light spots on the surface as a function of the angle of incidence. When they later learn about refraction/interference in a thin film this will be very useful!
Dear Kirill, 
I was using your formula to find the distance between lines y=-3x+10 and y=-3+2.  I got a distance of 2.53, however my teacher went through it, and got a distance of 7.59. I do believe 7.59 is correct, could you please explain why I got 2.53? You seem to to know more on this then my teacher does.
Krill, Andre,
Here is an alternative proof of the formula that requires only some knowledge of the Pythagorian Theorem, absolute value, the definition of slope, and areas of rectangles and parallelograms; all available to pre-Algebra or beginning Algebra students.  There is no need for trig or complex algebra manipulations.  The proof is MUCH easier to see and explain with a drawing but for you two, I think the following will allow you to make the drawing and see the (what I consider) beautiful result.
 
Draw the two lines (y=mx+ b1; y=mx+b2) showing them intersecting the y axis at b1 and b2.  Without loss of generality, we can assume b1 >b2. Assume m>0, so that the lines go up as x increases.  Connecting points (0,b1) and (0,b2) gives a line segment of length abs(b1-b2).  From (0,b2) draw a horizontal segment to the right of length 1.  The right-hand endpoint of this line segment will be the point (1,b2). By the definition of slope, the point on y=mx+b2 directly above (1,b2) will have length m.  Draw the vertical line from (1,b2) up to the point on y=mx+b2 (which is (1,m+b2) and continue vertically until you reach y=mx+b1.  Call the intersection of the vertical line and y=mx+b1 the point C.  You now have constructed a parallelogram with a right triangle below it. The hypotenuse of the right triangle is the same as the base of the parallelogram and it's length is sqr(m^2 +1). Next construct another right triangle above y=mx+b1 by drawing a horizontal line connecting C with the y axis.  The entirety of your construction is now a rectangle with sides 1 and m+ abs(b1-b2).  The are of this rectangle is m+abs(b1-b2).
The area of each right triangle is  1/2(1)m.  The area of the 2 right triangles together is m.  The area of the parallelogram is the area of the rectangle minus the area of the 2 right triangles or m+ abs((b1-b2) - m = abs(b1-b2). But area of the parallelogram is also base times height where the height of the parallelogram is the shortest distance between the parallel lines.  So sqr(m^2+1) times height of parallelogram = abs(b1-b2) and finally, the shortest distance between the two lines = the height of the parallelogram  = abs(b1-b2)/sqr(m^2+1)