Among the fundamental problems of analytic geometry in the coordinate plane is finding the distance from a point to a line.
At first glance, this might look like a purely mechanical exercise — one of those calculations you solve by plugging numbers into a formula. But behind this result lies something far more interesting. The point-to-line distance formula is an elegant synthesis of ideas we’ve already built: linear equations, the vector interpretation of lines in the plane, and the dot product.
What looks like a simple computation is really a meeting point between algebra and geometry.
In this article, given a point \(P(x_0,y_0)\) and a line \(r\) with equation \(ax+by+c=0\), we’ll see how to find the minimum distance between the point and the line — that is, the length of the perpendicular segment drawn from a point \(P\) to a line \(r\) lying in the plane.
More specifically, we’ll cover:
- The geometric definition of the problem
- The general formula for computing the distance
- Worked examples, step by step
- The special cases of vertical and horizontal lines
- The proof of the formula using the dot product
The goal, then, isn’t just to apply a formula correctly — it’s to understand its structure and its geometric meaning.
Geometric Definition of the Distance from a Point to a Line
Consider a line \(r\) in the coordinate plane and a point \(P\) not lying on it.
The distance from \(P\) to the line \(r\) can be thought of as the length of the perpendicular segment drawn from the point to the line.
Specifically, if we call \(H\) the foot of the perpendicular dropped from \(P\) to the line \(r\), then the distance we’re looking for, \(d\), is the length of the segment \(PH\), as shown in Fig. 1.

It’s worth stressing that this is the minimum distance between the point and the line.
Formula for Computing the Distance from a Point to a Line
Let the line \(r\) be given in general form \[r\;:\; ax+by+c=0\] and the point \[P(x_0,y_0)\]
It can be shown (see the proof section below) that the distance from the point \(P\) to the line \(r\) is given by:
\[d=\frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}}\tag{1}\]
Notice that if the point \(P\) coincides with the origin \(O\), we have \(x_0=y_0=0\), so formula (1) reduces to the simplified form:
\[d=\frac{|c|}{\sqrt{a^2+b^2}}\tag{2}\]
Interpreting the Terms
- \(a\) and \(b\) determine the direction of the line;
- the numerator \(ax_0+by_0+c\) measures how far the point “deviates” from satisfying the line’s equation;
- the denominator \(\sqrt{a^2 + b^2}\) normalizes that departure;
- the absolute value guarantees the distance is never negative.
Now let’s see how to put this formula to work.
Worked Examples on Computing the Distance Between a Point and a Line
Example 1 – Direct Application
Given the point \(P(1,2)\) and the line \(r:\,3x+4y-5=0\), find the distance from the point to the line.
SOLUTION
Since the line is already written in general form, we can read off the coefficients \(a\), \(b\), and \(c\) directly: \[a=3 \quad b=4 \quad c=-5\]
The coordinates of the point \(P\) are: \[x_0=1\quad y_0=2\]
We can now find the distance between \(P\) and \(r\) by applying formula (1) directly:
\[d=\frac{|3\cdot 1+4\cdot 2-5|}{\sqrt{3^2+4^2}}=\frac{6}{5}\]

Example 2 – Point P Lying on the Line
Find the distance from the point \(P(2,-1)\) to the line \(2x-y-5=0\).
SOLUTION
As in Example 1, we read off the line’s coefficients: \[a=2 \quad b=-1 \quad c=-5\]
The coordinates of point \(P\) are: \[x_0=2\quad y_0=-1\]
Again applying formula (1):
\[d=\frac{|2\cdot 2-(-1)-5|}{\sqrt{2^2+(-1)^2}}=0\]
Here the distance comes out to zero, so we can conclude that point \(P\) lies on the given line.

Example 3 – Line in Slope-Intercept Form with Point P at the Origin
Given the point \(P(0,0)\) and the line \(y=2x+1\), find the distance from \(P\) to the line.
Here the line is given in slope-intercept form, so the first step is converting it to general form.
Starting from the slope-intercept form: \[y=2x+1\]
we get the following general form: \[2x-y+1=0\]
The coefficients of this equation are: \[a=2 \quad b=-1 \quad c=1\]
Since point \(P\) coincides with the origin, we can compute the distance using the simplified formula (2):
\[d=\frac{|1|}{\sqrt{2^2+(-1)^2}}=\frac{1}{\sqrt{5}}\]

Special Cases
Horizontal Line
If the line has equation \[y=k\] the distance is:
\[d=|y_0-k|\tag{3}\]
where \(y_0\) is the \(y\)-coordinate of the point \(P(x_0,y_0)\).
Example:
Given the point \(P(3,2)\) and the line \(y=5\), the distance between the point and the line follows at once from (3):
\[d=|2-5|=3\]

Vertical Line
If the line has equation \[x=h\] the distance is:
\[d=|x_0-h|\tag{4}\]
where \(x_0\) is the \(x\)-coordinate of the point \(P(x_0,y_0)\).
Example:
Given the point \(P(-2,4)\) and the line \(x=6\), the distance between the point and the line follows from (4):
\[d=|-2-6|=8\]

Proof of the Distance Formula (Going Deeper)
Let’s see how formula (1) is derived using vectors and the dot product.
1️⃣ Given the line: \[r\;:\;ax+by+c=0,\tag{5}\]
it can be shown that \[\vec{n} = (a,b)\tag{6}\] is a vector normal to the line — that is, perpendicular to it.
2️⃣ Let \(Q(x_1, y_1)\) be a generic point on the line. Then it must satisfy: \[ax_1 + by_1 + c = 0\tag{7}\]
3️⃣ Let’s also define the vector \[\vec{PQ} = (x_1 – x_0, y_1 – y_0)\tag{8}\] connecting a generic point \(P(x_0,y_0)\) of the plane to the point \(Q\) on the line.
4️⃣ The distance we’re looking for is the length of the projection of \(\vec{PQ}\) onto the normal vector \(\vec{n}\), so we must have: \[d=\frac{|\vec{PQ} \cdot \vec{n}|}{|\vec{n}|}\tag{9}\]
5️⃣ Computing the dot product:
\[\vec{PQ} \cdot \vec{n} = a(x_1 – x_0) +b(y_1 – y_0)\tag{10}\]
Expanding the dot product gives:
\[\vec{PQ} \cdot \vec{n}=-ax_0+ax_1-by_0+by_1\]
which can be rewritten as:
\[\vec{PQ} \cdot \vec{n}=-ax_0-by_0+(ax_1+by_1)\tag{11}\]
From (7) we get immediately: \[-c=ax_1+by_1\]
Substituting this into (11) gives:
\[\vec{PQ} \cdot \vec{n}=-(ax_0 + by_0 + c)\tag{12}\]
⚠ Note: this result doesn’t depend on which point \(Q\) we chose on the line.
Indeed, if \(Q_1\) and \(Q_2\) are two points on the line, the vector \(\vec{Q_1Q_2}\) is parallel to the line \(r\), and therefore orthogonal to the normal vector \(\vec{n}\). As a result, the dot product in (12) doesn’t change.
6️⃣ We also know that the magnitude of the normal vector is: \[|\vec{n}| = \sqrt{a^2 + b^2}\tag{13}\]
Putting it together
Substituting (12) and (13) into (9) gives: \[d=\frac{|-(ax_0+by_0+c)|}{\sqrt{a^2+b^2}}\]
which is the same as: \[d=\frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}}\]
This matches formula (1) stated earlier, giving the distance between a generic point \(P\) of the plane and a line \(r\).
Common Mistakes to Avoid
- Forgetting the absolute value
- Not converting the line to general form first
- Leaving out the square root in the denominator
- Confusing \(a^2 + b^2\) with \(\sqrt{a^2 + b^2}\)
Connections to Other Topics
Computing the distance from a point to a line is closely tied to:
- the dot product;
- normal vectors;
- orthogonal projection;
- the distance between parallel lines;
- the study of conic sections.
This is a central result in analytic geometry, since it shows how a geometric problem can be solved effectively through algebraic tools.
The distance formula is one of several fundamental tools covered in the complete guide on the line in analytic geometry.
Conclusion
Computing the distance from a point to a line is a fundamental step in the study of analytic geometry.
The formula is simple to apply, but it holds a deep conceptual structure: it grows out of the notion of orthogonality and the use of the dot product.
Learning to use it correctly in exercises, and understanding its proof, means building a solid connection between algebra and geometry — the very core of analytic geometry in the plane.
Final Test
A quick check confirms whether the key ideas have landed. The following ten questions cover the geometric definition, the general formula, its special cases, and the reasoning behind the proof. Working through each one reinforces both the computation and the logic that supports it.
Cite this resource
"Behind this article: hours of writing, checking, and rewriting to get it right. If it was useful, a share or citation helps it find the next person who needs it."
Citation
HTML link to copy