Sub topic 12
Distance from a Point to a Line
Assume you know coordinates, basic fraction arithmetic, and how to solve linear equations. This chapter uses standard form for a line:
\[ Ax+By+C=0 \]
Here, \(A\), \(B\), and \(C\) are constants, and \((x,y)\) represents any point on the line.
The distance formula
The shortest distance from a point to a line is measured along a perpendicular segment. For the point \((x0,y0)\) and the line
\[ Ax+By+C=0, \]
the distance is
\[ d=\frac{|Ax0+By0+C|}{\sqrt{A^2+B^2}}. \]
The numerator evaluates the line expression at the point. The absolute value makes the distance positive. The denominator adjusts for the direction of the line.
Worked example
Find the distance from \(P=(0,0)\) to the line
\[ 3x+4y-10=0. \]
Identify the coefficients:
- \(A=3\)
- \(B=4\)
- \(C=-10\)
- \(x_0=0\)
- \(y_0=0\)
Substitute into the formula:
\[ d=\frac{|3(0)+4(0)-10|}{\sqrt{3^2+4^2}} \]
\[ d=\frac{|-10|}{\sqrt{9+16}} =\frac{10}{5} =2. \]
The point is 2 units from the line.
Why the formula uses the coefficients
The line’s normal vector is
\[ \langle A,B\rangle. \]
A normal vector points perpendicular to the line. The length of this vector is
\[ \sqrt{A^2+B^2}, \]
which explains the denominator. The expression \(Ax0+By0+C\) measures the point’s position relative to the line. Its sign tells which side of the line contains the point, while its absolute value gives a nonnegative distance after scaling.
For example, the lines
\[ 2x+3y-6=0 \]
and
\[ 4x+6y-12=0 \]
describe the same line. Multiplying all coefficients by a nonzero number does not change the geometric line. The distance formula still gives the same result because the numerator and denominator are multiplied by matching factors.
Using a line written in another form
Suppose the line is written as
\[ y=2x+1. \]
Move all terms to the left:
\[ 2x-y+1=0. \]
For the point \((3,0)\),
\[ d=\frac{|2(3)-0+1|}{\sqrt{2^2+(-1)^2}} =\frac{7}{\sqrt5}. \]
You may rationalize the denominator if required:
\[ \frac{7}{\sqrt5}=\frac{7\sqrt5}{5}. \]
Both forms represent the same distance.
Common errors
- Forgetting the absolute value can produce a negative “distance.”
- Using \(A^2+B^2\) instead of \(\sqrt{A^2+B^2}\) in the denominator changes the answer.
- Substituting the point’s coordinates incorrectly is especially common when \(C\) is negative.
- Treating the slope as the denominator ignores the line’s vertical and horizontal cases.
- Leaving the equation as \(y=mx+b\) without first converting it to standard form can lead to incorrect coefficients.
The formula works for vertical lines, too. For \(x=5\), write the equation as \(x-5=0\). The distance from \((2,7)\) is
\[ \frac{|2-5|}{\sqrt{1^2+0^2}}=3. \]
import math
def point_line_distance(A, B, C, point):
"""Return the distance from point (x0, y0) to Ax + By + C = 0."""
x0, y0 = point
if A == 0 and B == 0:
raise ValueError("A and B cannot both be zero")
return abs(A * x0 + B * y0 + C) / math.hypot(A, B)
distance = point_line_distance(3, 4, -10, (0, 0))
print(distance) # 2.0Exercise
Find the distance from (1, 2) to the line 6x - 8y + 10 = 0.
Show answer
Substitute into the formula: d = |6(1) - 8(2) + 10| / √(6² + (-8)²) = |0| / 10 = 0. The point lies on the line.