The distance between a point and a line is defined to be the length of the perpendicular line segment connecting the point to the given line.

Let (x_{1},y_{1}) be the point not on the line and let (x_{2},y_{2}) be the point on the line.

To find the distance between the point (x_{1},y_{1}) and the line with equation ax + bx + c = 0, you can use the formula below.

$$ d = \frac{|ax_1 + by_1 + c|}{\sqrt{a^2 + b^2}} $$

Example #1

Find the distance between a point and a line using the point (5,1) and the line y = 3x + 2.

Rewrite y = 3x + 2 as ax + by + c = 0

Using y = 3x + 2, subtract y from both sides.

y - y = 3x - y + 2

0 = 3x - y + 2

3x - y + 2 = 0

a = 3, b = -1, and c = 2

x_{1} = 5 and y_{1} = 1

$$ d = \frac{|3 \times 5 + -1 \times 1 + 2|}{\sqrt{3^2 + (-1)^2}} $$

$$ d = \frac{|15 + -1 + 2|}{\sqrt{9 + 1}} $$

$$ d = \frac{|16|}{\sqrt{10}} $$

$$ d = \frac{16}{3.16} = 5.06 $$

Example #2

Find the distance between a point and a line using the point (-4,2) and the line y = -2x + 5.

Rewrite y = -2x + 5 as ax + by + c = 0

Using y = -2x + 5, subtract y from both sides.

y - y = -2x - y + 5

0 = -2x - y + 5

-2x - y + 5 = 0

a = -2, b = -1, and c = 5

x_{1} = -4 and y_{1} = 2

$$ d = \frac{|-2 \times -4 + -1 \times 2 + 5|}{\sqrt{(-2)^2 + (-1)^2}} $$

$$ d = \frac{|8 + -2 + 5|}{\sqrt{4 + 1}} $$

$$ d = \frac{|11|}{\sqrt{5}} $$

$$ d = \frac{11}{2.23} = 4.92 $$

We can redo example #1 using the distance formula. To use the distance formula, we need two points. We already have (5,1) that is not located on the line y = 3x + 2.

We can just look for the point of intersection between y = 3x + 2 and the line that is perpendicular to y = 3x + 2 and passing through (5, 1)

The line that is perpendicular to y = 3x + 2 is given by y = (-1/3)x + b.

Use the point (5, 1) to find b by letting x = 5 and y = 1.

1 = (-1/3) × 5 + b

1 = -5/3 + b

b = 1 + 5/3 = 8/3

y = (-1/3)x + 8/3

Now, set the two equations equal to themselves

(-1/3)x + 8/3 = 3x + 2

3x + (1/3)x = 8/3 - 2

(10/3)x = (8 - 6)/3

(10/3)x = 2/3

x = (2/3) × 3/10 = 2/10 = 1/5

y = 3x + 2 = 3 × 1/5 + 2 = 3/5 + 2 = 13/5

The point of intersection between y = 3x + 2 and y = (-1/3)x + 8/3 is

(1/5, 13/5) or (0.25, 2.6)

Find the distance using the points (5,1) and (0.25, 2.6).

$$ d = \sqrt{(5 - 0.25)^2 + (1-2.6)^2} $$

$$ d = \sqrt{(4.75)^2 + (-1.6)^2} $$

$$ d = \sqrt{22.5625 + 2.56} $$

$$ d = \sqrt{25.1225} = 5.01 $$

To derive the formula at the beginning of the lesson that helps us to find the distance between a point and a line, we can use the distance formula and follow a procedure similar to the one we followed in the last section when the answer for d was 5.01.

Hang in there tight. Deriving the distance between a point and a line is among of the toughest things you have ever done in life.

The steps to take to find the formula are outlined below.

1) Write the equation ax + by + c = 0 in slope-intercept form.

2) Use (x_{1}, y_{1}) to find the equation that is perpendicular to ax + by + c = 0

3) Set the two equations equal to each other to find expressions for the points of intersection (x_{2}, y_{2})

4) Use the distance formula, (x_{1}, y_{1}), and the expressions found in step 3 for (x_{2}, y_{2}) to derive the formula.

1)

ax + by + c = 0

ax - ax + by + c = -ax

by + c = -ax

by + c - c = -ax - c

by = -ax - c

y = -ax/b - c/b**y = (-a/b)x - c/b**

2) The line that is perpendicular to y = (-a/b)x - c/b can be written as

y = (b/a)x + y-intercept

Use (x_{1}, y_{1}) to find y-intercept

y_{1} = (b/a)x_{1} + y-intercept

y-intercept = y_{1}- (b/a)x_{1}

**y = (b/a)x + y _{1}- (b/a)x_{1}**

3) Set the two equations equal to each other to find expressions for the points of intersection (x_{2}, y_{2})

Set y = (-a/b)x - c/b and y = (b/a)x + y_{1}- (b/a)x_{1} equal to each other

(-a/b)x - c/b = (b/a)x + y_{1}- (b/a)x_{1}

(b/a)x + (a/b)x = -c/b + (b/a)x_{1} - y_{1}

(b/a)x + (a/b)x = (ba/ba) × [(-c/b + (b/a)x_{1} - y_{1}]

(b/a + a/b)x = (-ca + b^{2}x_{1} - y_{1}ba) / ba

[ (a^{2} + b^{2})/ab ] / x = (-ca + b^{2}x_{1} - y_{1}ba) / ba

x = (-ca + b^{2}x_{1} - y_{1}ba) / a^{2} + b^{2 }( this is x_{2 })

Now, let us find y_{2} using the equation y = (-a/b)x - c/b

(-a/b)x = -a/b[ (-ca + b^{2}x_{1} - bay_{1}) / (a^{2} + b^{2}) ]

(-a/b)x = (ca^{2} - ab^{2}x_{1} + ba^{2}y_{1}) / b(a^{2} + b^{2})

(-a/b)x - c/b = [(ca^{2} - ab^{2}x_{1} + ba^{2}y_{1}) / b(a^{2} + b^{2})] - c/b

(-a/b)x - c/b = (ca^{2} - ab^{2}x_{1} + ba^{2}y_{1} - ca^{2} - b^{2}c) / b(a^{2} + b^{2})

(-a/b)x - c/b = (- ab^{2}x_{1} + ba^{2}y_{1} - b^{2}c) / b(a^{2} + b^{2})

(-a/b)x - c/b = b[(- abx_{1} + a^{2}y_{1} - bc)] / b(a^{2} + b^{2})

(-a/b)x - c/b = (- abx_{1} + a^{2}y_{1} - bc) / (a^{2} + b^{2})

y = (- abx_{1} + a^{2}y_{1} - bc) / (a^{2} + b^{2}) (this is y_{2})

To summarize,

x_{2} = (-ca + b^{2}x_{1} - y_{1}ba) / a^{2} + b^{2}

y_{2} = (- abx_{1} + a^{2}y_{1} - bc) / (a^{2} + b^{2})

Now, find the distance between a point and a line using (x_{1},y_{1}) and (x_{2},y_{2})

$$ d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} $$

$$ d = \sqrt{(\frac{-ca + b^2x_1 - y_1ba}{a^2 + b^2} - x_1)^2 + (\frac{-bc + a^2y_1 - abx_1}{a^2 + b^2} - y_1)^2} $$

$$ d = \sqrt{(\frac{-ca - y_1ba- a^2x_1 }{a^2 + b^2})^2 + (\frac{-bc - abx_1 - b^2y_1}{a^2 + b^2})^2} $$

$$ d = \sqrt{[\frac{-a(c + y_1b + ax_1) }{a^2 + b^2}]^2 + [\frac{-b(c + ax_1 + by_1}{a^2 + b^2}]^2} $$

$$ d = \sqrt{\frac{(-a)^2(c + y_1b + ax_1)^2 }{(a^2 + b^2)^2} + \frac{(-b)^2(c + ax_1 + by_1)^2}{(a^2 + b^2)^2}} $$

$$ d = \sqrt{\frac{a^2(c + y_1b + ax_1)^2 }{(a^2 + b^2)^2} + \frac{b^2(c + ax_1 + by_1)^2}{(a^2 + b^2)^2}} $$

$$ d = \sqrt{\frac{(a^2+ b^2)(c + y_1b + ax_1)^2 }{(a^2 + b^2)^2} } $$

$$ d = \sqrt{\frac{(c + y_1b + ax_1)^2 }{(a^2 + b^2)} } $$

$$ d = \frac{\left\lvert c + y_1b + ax_1 \right\rvert} {\sqrt{a^2 + b^2}}$$