Distance Between a Point and a Line

Distance Between a Point and a Line

The distance from a point to a line is the length of the shortest segment connecting them, which is always perpendicular to the line. This distance is given by a compact formula involving the line's equation and the point's coordinates.

Quick Reference

Formula Description
d = | a x 0 + b y 0 + c | a 2 + b 2 Distance from ( x 0 , y 0 ) to the line a x + b y + c = 0

The Distance Formula

Point-to-Line Distance Theorem

The perpendicular distance from the point P ( x 0 , y 0 ) to the line L with equation a x + b y + c = 0 is:

d = | a x 0 + b y 0 + c | a 2 + b 2

The absolute value in the numerator ensures the distance is always non-negative, regardless of which side of the line the point lies on. The denominator a 2 + b 2 is the length of the normal vector ( a , b ) to the line.

Diagram showing a point P(x₀, y₀) above a line L with equation ax + by + c = 0. A perpendicular segment of length d connects P to the foot Q on the line.
The perpendicular distance d from point P to line L
Proof (click to expand)

Drop a perpendicular from P ( x 0 , y 0 ) to L and call the foot Q ( x 1 , y 1 ) . Since the slope of L is a b , the perpendicular L 1 through P has slope b a , giving:

y y 0 = b a ( x x 0 ) .

Since Q ( x 1 , y 1 ) lies on L 1 :

y 1 y 0 = b a ( x 1 x 0 ) y 1 y 0 b = x 1 x 0 a .

Let r denote this common ratio. Then x 1 x 0 = a r and y 1 y 0 = b r . The distance is:

d = | P Q | = ( a r ) 2 + ( b r ) 2 = a 2 + b 2 | r | .

To find r , use the fact that Q ( x 1 , y 1 ) satisfies a x 1 + b y 1 + c = 0 . Substituting x 1 = a r + x 0 and y 1 = b r + y 0 :

a ( a r + x 0 ) + b ( b r + y 0 ) + c = 0 ( a 2 + b 2 ) r = ( a x 0 + b y 0 + c ) ,

so r = a x 0 + b y 0 + c a 2 + b 2 . Therefore:

d = a 2 + b 2 | a x 0 + b y 0 + c | a 2 + b 2 = | a x 0 + b y 0 + c | a 2 + b 2 .

Note: The proof above assumes a 0 and b 0 , but the formula remains valid when either a = 0 or b = 0 .

How to Apply the Formula

Step-by-Step Procedure

  1. Rewrite the line equation in the form a x + b y + c = 0 (move all terms to one side).
  2. Identify a , b , c , and the point ( x 0 , y 0 ) .
  3. Substitute into d = | a x 0 + b y 0 + c | a 2 + b 2 .
  4. Simplify. Rationalize the denominator if needed.

Worked Examples

Example 1. Find the distance between the point ( 3 , 1 ) and the line y = 2 x 1 .

Solution. Rewrite the line equation:

y = 2 x 1 2 x y 1 = 0.

Here a = 2 , b = 1 , c = 1 , x 0 = 3 , y 0 = 1 :

d = | 2 ( 3 ) + ( 1 ) ( 1 ) + ( 1 ) | 2 2 + ( 1 ) 2 = | 6 + 1 1 | 5 = 6 5 = 6 5 5 .

Example 2. Find the distance between the parallel lines 3 x 4 y + 10 = 0 and 3 x 4 y 5 = 0 .

Solution. Since the two lines have equal slopes, the distance between them is constant. Choose any convenient point on the second line. Setting x = 3 :

3 ( 3 ) 4 y 5 = 0 4 = 4 y y = 1.

So $(3, 1)$ lies on the second line. Now apply the formula with the first line 3 x 4 y + 10 = 0 , where a = 3 , b = 4 , c = 10 , x 0 = 3 , y 0 = 1 :

d = | 3 ( 3 ) 4 ( 1 ) + 10 | 3 2 + ( 4 ) 2 = | 9 4 + 10 | 9 + 16 = 15 5 = 3.

The distance between the two parallel lines is $3$.

Frequently Asked Questions

Why is the distance formula measured perpendicularly?

The perpendicular distance is the shortest distance from a point to a line. Any other path from the point to the line is longer than the perpendicular segment. This makes the perpendicular distance the natural and most meaningful measure of how far the point is from the line.


How do I rewrite a line equation in the form ax + by + c = 0? Move all terms to one side of the equation. For example:
  • y = 3 x 5 becomes 3 x y 5 = 0 (so a = 3 , b = 1 , c = 5 ).
  • 2 x + 3 y = 7 becomes 2 x + 3 y 7 = 0 (so a = 2 , b = 3 , c = 7 ).
The coefficients a , b , c can be any real numbers, as long as a and b are not both zero.

How do I find the distance between two parallel lines? Choose any point on one line, then compute its perpendicular distance to the other line using the formula. The result is the constant distance between the lines. This works because all perpendicular distances between parallel lines are equal.

What if the point lies on the line? If P ( x 0 , y 0 ) lies on the line a x + b y + c = 0 , then a x 0 + b y 0 + c = 0 . The numerator of the distance formula is zero, so d = 0 . This makes sense: the distance from a point to a line it belongs to is zero.

What does the denominator √(a² + b²) represent? The expression a 2 + b 2 is the magnitude (length) of the normal vector ( a , b ) to the line a x + b y + c = 0 . The normal vector is perpendicular to the line. Dividing by its magnitude normalizes the projection calculation, ensuring the result is a true geometric distance rather than a scaled value.