Distance from a point to a line

The distance from a point to a line is the length of the perpendicular segment from the point to the line, which is the shortest path between them. Write the line as ax+by+c=0ax+by+c=0, plug the point (x1,y1)(x_1, y_1) into the left side, take the absolute value, and divide by a2+b2\sqrt{a^2+b^2}.

Chalcack concept card · Reviewed by the Chalcack team ·

The length of the perpendicular segment from point P to the line is the distance d.

Formulas

  • d=∣ax1+by1+c∣a2+b2d=\frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}}
  • distance from the origin: d=∣c∣a2+b2\text{distance from the origin: } d=\frac{|c|}{\sqrt{a^2+b^2}}

When to use it

Use it when you need the distance (the shortest distance) between a point and a line on the coordinate plane.

Worked example

Find the distance between the point (1,2)(1, 2) and the line 3x+4y−5=03x+4y-5=0. The numerator is ∣3×1+4×2−5∣=6|3 \times 1+4 \times 2-5| = 6, and the denominator is 32+42=25=5\sqrt{3^2+4^2} = \sqrt{25} = 5. So the distance is 65\frac{6}{5}.

Common mistake

Plugging straight into a line written like y=2x+1y=2x+1 gives a wrong answer. First rearrange it so one side is 0, as in 2x−y+1=02x-y+1=0, then use the formula, and do not forget the absolute value in the numerator.

Related concepts

All 181 math concepts