### What is the distance from a given line to a given point?

Given a line of the form Ax+By+C=0 and a point (h,k), the perpendicular
distance from the line to the point is

|Ah+Bk+C|/sqrt(A^{2}+B^{2})

### Proof

Consider all the lines perpendicular to Ax+By+C=0. They have the form
Bx-Ay+D=0, where A and B are fixed, and D varies to select one of the infinitely
many perpendicular lines. To select the line that goes through (h,k), just
select D=-(Bh-Ak), so the equation of the line perpendicular to

Ax+By+C=0

that passes through (h,k) is

Bx-Ay-(Bh-Ak)=0

Solving the two lines to find their point of intersection gives us

x = (B^{2}h-ABk-AC)/(A^{2}+B^{2})

and

y = (A^{2}k-ABh-BC)/(A^{2}+B^{2})

Now, the distance from this point of intersection (x,y) to (h,k) is

sqrt((x-h)^{2}+(y-k)^{2}),
and then plugging in x and y gives us

sqrt(((B^{2}h-ABk-AC)/(A^{2}+B^{2})-h)^{2}+((A^{2}k-ABh-BC)/(A^{2}+B^{2})-k)^{2}),

which, amazingly, simplifies to

sqrt((Ah+Bk+C)^{2}/(A^{2}+B^{2}))

so the final solution is

|Ah+Bk+C|/sqrt(A^{2}+B^{2})

### Internet references

### Related pages in this website

Lines in 3 dimensions: Equation of
a line in three dimensions, the distance between two lines, finding the closest
points of the two lines.

The distance from Ax+By+C=0 to a point is used in
Tangents to 2 Circles.

An aside in Point and Triangle2
gives the distance d_{AB} from (x,y) to
line AB where A=(x_{1},y_{1}),
B=(x_{2},y_{2})

Vectors, and their
dot product, cross product.

The webmaster and author of this Math Help site is
Graeme McRae.