In short

The perpendicular distance from a point (x_1, y_1) to the line Ax + By + C = 0 is \dfrac{|Ax_1 + By_1 + C|}{\sqrt{A^2 + B^2}}. The distance between two parallel lines Ax + By + C_1 = 0 and Ax + By + C_2 = 0 is \dfrac{|C_1 - C_2|}{\sqrt{A^2 + B^2}}. The sign of Ax_1 + By_1 + C tells you which side of the line the point lies on, and the foot of the perpendicular from a point to a line can be found by projecting onto the line using its normal vector.

A farmer's rectangular field has one edge running along a straight canal. The canal follows the line 3x + 4y - 24 = 0 on the surveyor's map, and the farmer's well is at the point (1, 2). How far is the well from the canal?

You could draw the perpendicular from the well to the canal, find where it hits the canal, and then compute the distance between two points. That works — but it takes several steps. There is a formula that gives the answer in one line.

The distance is

\frac{|3(1) + 4(2) - 24|}{\sqrt{3^2 + 4^2}} = \frac{|3 + 8 - 24|}{\sqrt{9 + 16}} = \frac{|-13|}{5} = \frac{13}{5} = 2.6

The well is 2.6 units from the canal. That formula — plug in the point's coordinates into the line's equation, take the absolute value, divide by \sqrt{A^2 + B^2} — is the subject of this article. But first, you need to understand why it works.

The distance from a point to a line

The derivation

Given a line \ell: Ax + By + C = 0 and a point P = (x_1, y_1) not on the line. You want the shortest distance from P to \ell. The shortest path from a point to a line is always the perpendicular — any other path from P to a point on \ell is longer (the hypotenuse of a right triangle is always longer than either leg).

Method 1: Using the normal vector. The line Ax + By + C = 0 has a normal vector \vec{n} = (A, B) — a vector perpendicular to the line. The key insight is that the perpendicular distance from P to the line equals the length of the projection of the vector from any point on the line to P along this normal direction.

Pick any convenient point Q on the line. For instance, if B \neq 0, take Q = (0, -C/B) — the y-intercept of the line. The vector from Q to P is

\vec{QP} = (x_1 - 0, \; y_1 - (-C/B)) = (x_1, \; y_1 + C/B)

The projection of \vec{QP} onto the normal \vec{n} = (A, B) has length

d = \frac{|\vec{QP} \cdot \vec{n}|}{|\vec{n}|} = \frac{|A \cdot x_1 + B \cdot (y_1 + C/B)|}{\sqrt{A^2 + B^2}}

Why: the dot product \vec{QP} \cdot \vec{n} gives the component of \vec{QP} in the normal direction. Dividing by |\vec{n}| normalises it to a length. The absolute value ensures the distance is non-negative.

Expand the numerator:

|Ax_1 + By_1 + C|

Why: B \cdot (y_1 + C/B) = By_1 + C, so the numerator becomes |Ax_1 + By_1 + C|.

And the denominator is \sqrt{A^2 + B^2}. So

d = \frac{|Ax_1 + By_1 + C|}{\sqrt{A^2 + B^2}}
The line $3x + 4y - 24 = 0$ and the point $P(1, 2)$. The red segment is the perpendicular from $P$ to the line, landing at the foot $F$. Its length is $2.6$ — the shortest possible distance from $P$ to any point on the line.

Method 2: Direct construction using a parameter. Here is a second derivation that uses no vector language — just the idea of walking from P toward the line along the perpendicular.

The normal direction to \ell is (A, B). The perpendicular from P to \ell runs in this direction. Parametrise the perpendicular by setting x = x_1 + At and y = y_1 + Bt, where t is a parameter. When t = 0, you are at P. As t varies, you walk in the normal direction. The foot of the perpendicular is the value of t where you land on the line.

Substitute into Ax + By + C = 0:

A(x_1 + At) + B(y_1 + Bt) + C = 0
Ax_1 + A^2 t + By_1 + B^2 t + C = 0
t(A^2 + B^2) = -(Ax_1 + By_1 + C)
t = \frac{-(Ax_1 + By_1 + C)}{A^2 + B^2}

Why: parametrise the perpendicular line through P in the direction of the normal (A, B). The parameter t tells you how far along the normal you travel to reach the line.

The distance d = |PF| equals |t| \cdot \sqrt{A^2 + B^2} (since the step (At, Bt) has length |t|\sqrt{A^2 + B^2}):

d = \frac{|Ax_1 + By_1 + C|}{A^2 + B^2} \cdot \sqrt{A^2 + B^2} = \frac{|Ax_1 + By_1 + C|}{\sqrt{A^2 + B^2}}

Same formula as before, confirmed by a different route.

Distance from a point to a line

The perpendicular distance from the point (x_1, y_1) to the line Ax + By + C = 0 is

d = \frac{|Ax_1 + By_1 + C|}{\sqrt{A^2 + B^2}}

Reading the formula

The numerator |Ax_1 + By_1 + C| is what you get when you plug the point's coordinates into the left side of the line's equation and take the absolute value. If the point were on the line, this would be zero — the equation would be satisfied. The further the point is from the line, the larger this quantity gets.

The denominator \sqrt{A^2 + B^2} is a normalisation factor — the length of the normal vector (A, B). It ensures the answer does not change if you multiply the equation by a constant. (Multiplying Ax + By + C = 0 by k gives kAx + kBy + kC = 0; the numerator gets multiplied by |k| and the denominator by |k|, so they cancel.)

Position of a point relative to a line

The absolute value in the distance formula hides useful information. If you drop it, the sign of Ax_1 + By_1 + C tells you which side of the line the point lies on.

The line Ax + By + C = 0 divides the plane into two half-planes. For any point (x_1, y_1):

Which side is "positive" and which is "negative" depends on the specific coefficients A, B, C — there is no universal "above" or "below." But the key fact is: two points lie on the same side of the line if and only if they give the same sign when plugged in.

The line $3x + 4y - 18 = 0$. The point $P_1(1, 5)$ gives $3 + 20 - 18 = 5 > 0$ — it lies on the positive side. The point $P_2(5, 1)$ gives $15 + 4 - 18 = 1 > 0$ — also positive, so $P_1$ and $P_2$ are on the same side. The point $(2, 3)$ gives $6 + 12 - 18 = 0$ — it lies on the line.

This is particularly useful when you need to check whether two points are on the same side of a line — a question that arises in problems about triangles, quadrilaterals, and linear programming. Just evaluate Ax + By + C at both points. Same sign means same side. Opposite signs means opposite sides.

A concrete check. Take the line x + y - 4 = 0. Does the origin (0, 0) lie on the same side as the point (5, 6)?

For the origin: 0 + 0 - 4 = -4 < 0.

For (5, 6): 5 + 6 - 4 = 7 > 0.

Opposite signs — so the origin and (5, 6) lie on opposite sides of the line x + y = 4. This makes sense geometrically: the origin is below and to the left of the line, while (5, 6) is above and to the right.

Distance between parallel lines

Two parallel lines have the same A and B (or proportional A and B) but different C values. If you write them as

\ell_1: Ax + By + C_1 = 0 \qquad\text{and}\qquad \ell_2: Ax + By + C_2 = 0

then the distance between them is the perpendicular distance from any point on one line to the other line. Pick a point on \ell_1 — say, if B \neq 0, take (0, -C_1/B). Its distance from \ell_2 is

d = \frac{|A \cdot 0 + B \cdot (-C_1/B) + C_2|}{\sqrt{A^2 + B^2}} = \frac{|-C_1 + C_2|}{\sqrt{A^2 + B^2}} = \frac{|C_1 - C_2|}{\sqrt{A^2 + B^2}}

Distance between parallel lines

The distance between two parallel lines Ax + By + C_1 = 0 and Ax + By + C_2 = 0 is

d = \frac{|C_1 - C_2|}{\sqrt{A^2 + B^2}}

Important: the two equations must have the same A and B — not just proportional. If one line is 3x + 4y - 12 = 0 and the other is 6x + 8y + 5 = 0, first divide the second by 2 to get 3x + 4y + 5/2 = 0. Then C_1 = -12, C_2 = 5/2, and

d = \frac{|-12 - 5/2|}{\sqrt{9 + 16}} = \frac{29/2}{5} = \frac{29}{10} = 2.9
Two parallel lines: $3x + 4y - 12 = 0$ and $6x + 8y + 5 = 0$. They have the same slope ($-3/4$) and are everywhere $2.9$ units apart. The dashed segment shows the perpendicular distance between them.

Foot of perpendicular

The foot of the perpendicular from a point P(x_1, y_1) to a line Ax + By + C = 0 is the point F on the line closest to P. You have already seen the parametric trick in the derivation above. Using t = -\frac{Ax_1 + By_1 + C}{A^2 + B^2}, the foot is

F = \left(x_1 + At, \; y_1 + Bt\right)

where t = \dfrac{-(Ax_1 + By_1 + C)}{A^2 + B^2}.

Foot of perpendicular

The foot of the perpendicular from (x_1, y_1) to Ax + By + C = 0 is the point

F = \left(x_1 - \frac{A(Ax_1 + By_1 + C)}{A^2 + B^2}, \;\; y_1 - \frac{B(Ax_1 + By_1 + C)}{A^2 + B^2}\right)

This formula comes directly from the parametric construction: start at P, walk distance t in the normal direction (A, B), and land on the line.

Reflection of a point across a line. The foot of the perpendicular is the midpoint between P and its reflection P' across the line. So if F is the foot, the reflection is

P' = (2F_x - x_1, \; 2F_y - y_1)

This is useful in optics-style problems (the reflection of a light ray off a mirror follows this rule) and in coordinate geometry problems that ask for the image of a point in a line.

Example of a reflection. Find the reflection of the point (3, -1) across the line 5x + 12y - 26 = 0. First, find the foot of the perpendicular (you will do this in full in Example 1 below): F = (622/169, \, 107/169). Then the reflection is

P' = \left(2 \cdot \frac{622}{169} - 3, \;\; 2 \cdot \frac{107}{169} - (-1)\right) = \left(\frac{1244 - 507}{169}, \;\; \frac{214 + 169}{169}\right) = \left(\frac{737}{169}, \;\; \frac{383}{169}\right)

The reflected point lies on the opposite side of the line, at the same distance from it as the original.

Worked examples

Example 1: Distance from a point to a line, with geometric verification

Find the perpendicular distance from the point P(3, -1) to the line 5x + 12y - 26 = 0, and locate the foot of the perpendicular.

Step 1. Apply the distance formula. With A = 5, B = 12, C = -26:

d = \frac{|5(3) + 12(-1) - 26|}{\sqrt{5^2 + 12^2}} = \frac{|15 - 12 - 26|}{\sqrt{25 + 144}} = \frac{|-23|}{\sqrt{169}} = \frac{23}{13}

Why: plug the point's coordinates into the line equation's left side, take the absolute value, and divide by the length of the normal vector. The denominator \sqrt{169} = 13 is exact — this is a (5, 12, 13) Pythagorean triple.

Step 2. Find the foot F. Compute t:

t = \frac{-(5 \cdot 3 + 12 \cdot (-1) - 26)}{5^2 + 12^2} = \frac{-(-23)}{169} = \frac{23}{169}

Why: the parameter t measures how far from P you walk in the normal direction (5, 12) to reach the line.

Step 3. Compute the foot:

F_x = 3 + 5 \cdot \frac{23}{169} = 3 + \frac{115}{169} = \frac{507 + 115}{169} = \frac{622}{169} \approx 3.68
F_y = -1 + 12 \cdot \frac{23}{169} = -1 + \frac{276}{169} = \frac{-169 + 276}{169} = \frac{107}{169} \approx 0.63

Why: start at P, add t times the normal direction. This lands exactly on the line.

Step 4. Verify: F should lie on the line. 5 \cdot \frac{622}{169} + 12 \cdot \frac{107}{169} - 26 = \frac{3110 + 1284}{169} - 26 = \frac{4394}{169} - 26 = 26 - 26 = 0. Confirmed.

Why: if the foot computation is correct, plugging F into the line equation must give exactly zero.

Result: The distance is d = 23/13 \approx 1.769, and the foot of the perpendicular is F = (622/169, \, 107/169) \approx (3.68, 0.63).

The line $5x + 12y - 26 = 0$ and the point $P(3, -1)$. The perpendicular from $P$ meets the line at the foot $F \approx (3.68, 0.63)$. The distance $23/13 \approx 1.77$ is the length of the red segment — the shortest path from $P$ to the line.

The (5, 12, 13) Pythagorean triple makes the denominator exact, which is a common trick in textbook problems — the numbers are chosen so that \sqrt{A^2 + B^2} simplifies cleanly.

Example 2: Distance between two parallel lines

Find the distance between the lines 8x - 15y + 34 = 0 and 8x - 15y - 51 = 0.

Step 1. Verify parallelism. Both lines have A = 8, B = -15. The coefficients are identical (not just proportional), so the lines are parallel and the formula applies directly.

Why: the distance formula requires both equations to have the same A and B. Here they already do, so no scaling is needed.

Step 2. Identify C_1 and C_2. C_1 = 34 and C_2 = -51.

Why: the C values are everything after Ax + By in each equation.

Step 3. Apply the formula:

d = \frac{|C_1 - C_2|}{\sqrt{A^2 + B^2}} = \frac{|34 - (-51)|}{\sqrt{64 + 225}} = \frac{|85|}{\sqrt{289}} = \frac{85}{17} = 5

Why: 8^2 + 15^2 = 64 + 225 = 289 = 17^2, another Pythagorean triple (8, 15, 17). The distance is exactly 5 units.

Step 4. Cross-check by picking a point on one line. From 8x - 15y + 34 = 0, set x = 2: 16 - 15y + 34 = 0, so y = 50/15 = 10/3. The distance from (2, 10/3) to 8x - 15y - 51 = 0:

\frac{|8(2) - 15(10/3) - 51|}{17} = \frac{|16 - 50 - 51|}{17} = \frac{|-85|}{17} = 5 \quad\checkmark

Why: picking any point on one line and computing its distance to the other should give the same answer as the direct formula.

Result: The two parallel lines are exactly 5 units apart.

The parallel lines $8x - 15y + 34 = 0$ (black) and $8x - 15y - 51 = 0$ (red), exactly $5$ units apart. The dashed segment shows the perpendicular distance from a point on one line to the other. The $(8, 15, 17)$ triple makes the arithmetic clean.

Pythagorean triples appear frequently in distance problems — (3, 4, 5), (5, 12, 13), (8, 15, 17), (7, 24, 25). Recognising them saves time and guards against arithmetic errors.

Common confusions

Going deeper

If you came here for the distance formula and how to use it, you have everything. The rest explores the algebraic structure behind the formula and its connection to the area of triangles.

The signed distance and half-planes

Drop the absolute value from the distance formula:

\delta(P) = \frac{Ax_1 + By_1 + C}{\sqrt{A^2 + B^2}}

This is the signed distance from the point P(x_1, y_1) to the line \ell. The sign tells you which half-plane P is in:

The signed distance is linear in P: if P and Q are on opposite sides of \ell, then \delta(P) and \delta(Q) have opposite signs, and the segment PQ crosses the line at the point that divides PQ in the ratio |\delta(P)| : |\delta(Q)| internally.

This linearity is the reason the distance formula is so useful in proofs: signed distances obey the same algebra as coordinates.

Connection to the area of a triangle

The signed distance from a point to a line is closely related to the area of a triangle. If a triangle has vertices A = (x_1, y_1), B = (x_2, y_2), C = (x_3, y_3), its area is

\text{Area} = \frac{1}{2} |x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2)|

The expression inside the absolute value is the 3 \times 3 determinant

\begin{vmatrix} x_1 & y_1 & 1 \\ x_2 & y_2 & 1 \\ x_3 & y_3 & 1 \end{vmatrix}

Now think of the area differently: the base of the triangle is the line BC, and the height is the perpendicular distance from A to that base. The line through B and C has equation

\frac{y_2 - y_3}{x_2 - x_3}(x - x_2) = y - y_2

or in general form, (y_2 - y_3)x - (x_2 - x_3)y + (x_2 - x_3)y_2 - (y_2 - y_3)x_2 = 0.

The distance from A(x_1, y_1) to this line, multiplied by the base length |BC| and divided by 2, gives the area. The distance formula and the area formula are two views of the same determinant.

Perpendicular distance in the normal form

If the line is given in normal form x\cos\alpha + y\sin\alpha = p, the distance from (x_1, y_1) to the line is

d = |x_1\cos\alpha + y_1\sin\alpha - p|

No square root in the denominator — because in normal form, A^2 + B^2 = \cos^2\alpha + \sin^2\alpha = 1. The normal form is already normalised.

Application: equidistant loci

The set of all points equidistant from two parallel lines Ax + By + C_1 = 0 and Ax + By + C_2 = 0 is a third line, parallel to both, with C = (C_1 + C_2)/2. This is the midline — the line exactly halfway between the two.

The set of all points equidistant from two intersecting lines is the pair of angle bisectors. The equation of the bisectors is derived from setting the signed distances equal:

\frac{A_1x + B_1y + C_1}{\sqrt{A_1^2 + B_1^2}} = \pm\, \frac{A_2x + B_2y + C_2}{\sqrt{A_2^2 + B_2^2}}

The "+" gives one bisector, the "-" gives the other. The full treatment is in Angle Bisectors.

Two parallel lines (black) and their midline (red dashed). Every point on the midline is equidistant from both original lines. The midline's $C$-value is the average of the two $C$-values.

Where this leads next

The distance formula is one of the most-used tools in coordinate geometry. It feeds directly into the next set of topics.