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
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
The projection of \vec{QP} onto the normal \vec{n} = (A, B) has length
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:
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
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:
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}):
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
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):
- If Ax_1 + By_1 + C > 0, the point is on one side.
- If Ax_1 + By_1 + C < 0, the point is on the other side.
- If Ax_1 + By_1 + C = 0, the point is on the line itself.
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.
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
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
Distance between parallel lines
The distance between two parallel lines Ax + By + C_1 = 0 and Ax + By + C_2 = 0 is
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
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
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
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
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
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:
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:
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:
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 (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:
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:
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.
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
-
"Forget the absolute value." Without |\ldots|, the formula gives a signed distance — which is useful for determining which side of the line the point is on, but not for the geometric distance. If a problem asks for "the distance," it means the non-negative quantity.
-
"Use the formula with un-normalised parallel lines." The formula |C_1 - C_2|/\sqrt{A^2 + B^2} requires both lines to have the same A and B, not just proportional ones. If one line is 2x + 3y + 7 = 0 and the other is 4x + 6y - 5 = 0, first divide the second by 2 to get 2x + 3y - 5/2 = 0. Then |C_1 - C_2| = |7 - (-5/2)| = 19/2.
-
"The foot of perpendicular is the midpoint of the segment joining any two points on the line." No. The foot is a specific point — the one closest to P. It is the midpoint of the segment from P to its reflection P' across the line, not a midpoint of anything on the line itself.
-
"Two points on the same side of a line have equal distances from it." Same side, but not necessarily the same distance. Being on the same side means the signed values Ax_1 + By_1 + C and Ax_2 + By_2 + C have the same sign, but they can have very different magnitudes.
-
"The distance formula works only for non-vertical lines." It works for every line, including vertical (B = 0) and horizontal (A = 0) lines. For a vertical line x = k (written as x - k = 0, so A = 1, B = 0, C = -k), the distance from (x_1, y_1) is |x_1 - k| — exactly what you would expect geometrically.
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:
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:
- \delta(P) > 0: P is on the side of the line where the normal vector (A, B) points.
- \delta(P) < 0: P is on the opposite side.
- \delta(P) = 0: P is on the line.
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
The expression inside the absolute value is the 3 \times 3 determinant
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
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
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:
The "+" gives one bisector, the "-" gives the other. The full treatment is in Angle Bisectors.
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.
- Angle Bisectors — the equations of lines equidistant from two given lines, derived by setting perpendicular distances equal.
- Straight Line — General Equation — the general form Ax + By + C = 0 that the distance formula is built on.
- Area and Collinearity — the area of a triangle from coordinates, and the condition for three points to be collinear (zero area).
- Locus — using distance conditions to derive the equation of a curve (e.g., "find the locus of points equidistant from a point and a line" gives a parabola).
- Coordinate Geometry Basics — the distance between two points and the section formula, the tools that underlie everything here.