Distance from a point to a line in the plane
Derive and apply the point-to-line distance formula, including signed coefficients, vertical lines, and the zero-distance case.
Content updated: October 22, 2026
The distance from a point to a line is the length of its shortest, perpendicular segment to the line. The normal-vector formula provides a quick calculation and explains why an absolute value is needed.
Learning goals: compute point-to-line distances in Oxy, check signs and denominators, and recognize distance zero.
Prerequisites: normal vectors, vector lengths, and orthogonal projection.
On this page: Concepts · Method · Examples · Practice · Further learning
1. Distance and the shortest segment
Let a point $M$ lie outside a line $d$, and let $H$ be the projection of $M$ onto $d$. For $Q\in d$ with $Q\ne H$, the triangle $MHQ$ is right-angled at $H$, so $MQ^2=MH^2+HQ^2>MH^2$. Thus $MH$ is the minimum length and is called the distance from $M$ to $d$. If $M\in d$, the distance is zero.
2. Formula from the general equation
Let $M(x_0;y_0)$ and $d:ax+by+c=0$, where $a^2+b^2>0$. Then
Set $q=ax_0+by_0+c$. By the projection formula, $\overrightarrow{MH}=-q(a;b)/(a^2+b^2)$. Taking lengths gives $MH=|q|/\sqrt{a^2+b^2}$. The distance denominator is the length of the normal vector; the sum of squares occurs instead in the coefficient used to find the projection.
When $q=0$, the point lies on the line and the distance is zero. Multiplying the equation by $\lambda\ne0$ multiplies both numerator and denominator by $|\lambda|$, leaving the result unchanged. Do not use the formula when $a=b=0$, since the equation then does not define a line.
Procedure: rearrange the equation with zero on one side, read the signed coefficients correctly, substitute the point into the numerator, take the absolute value, and divide by the normal-vector length. For a vertical line $x=k$ and a horizontal line $y=\ell$, the formula reduces to $|x_0-k|$ and $|y_0-\ell|$, respectively.
3. Worked examples
Example 1. Retaining the correct constant term
Find the distance from $M_0(-1;2)$ to $d:4x+3y-1=0$. We have $q=4(-1)+3\cdot2-1=1$ and $\sqrt{4^2+3^2}=5$. Hence
Writing the same line as $-8x-6y+2=0$ gives numerator $|-2|$ and denominator 10, again yielding $1/5$.
Example 2. A negative numerator and a point on the line
For $O(0;0)$ and the same line $4x+3y-1=0$, the numerator before taking its absolute value is $-1$, so the distance is again $1/5$. The point $A(1;-1)$ satisfies $4-3-1=0$ and therefore has distance zero. A negative distance would contradict its definition as a length.
Example 3. Vertical and horizontal lines
Let $M(-2;3)$. Its distance to $x=1$ is $|-2-1|=3$; its distance to $y=-2$ is $|3-(-2)|=5$. No slope conversion is needed, and a vertical line still has a well-defined distance.
4. Practice exercises
- Find the distance from $M(1;2)$ to $3x+4y-5=0$.
- Find the distance from $M(-2;3)$ to $2x-y+1=0$.
- Find the distance from $(0;4)$ to $y=4$.
Show answers and hints
- $q=3+8-5=6$, and the normal-vector length is 5, so the distance is $6/5$.
- $q=-4-3+1=-6$ and denominator $\sqrt5$ give distance $6/\sqrt5$.
- The point already lies on the line, so its distance is zero.
5. Common mistakes
- Omitting the absolute value when the numerator is negative.
- Using $a^2+b^2$ instead of its square root in the distance denominator.
- Changing the sign of the constant term incorrectly when rearranging the equation.
- Assuming that a vertical line has no point-to-line distance because it has no slope.
6. Related lessons and resources
- Projection and reflection across a line (English lesson)
- The general equation of a line (English lesson)
- Normal and direction vectors (English lesson)
Open the original exercise resource on Scribd. This lesson includes practice exercises with answers.
Original source resources
These original source resources have not been translated.
Leave a Reply