ArticleslgStudy

mathematics

Distance from a point to a line

Distance from a point to a line is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Distance from a point to a line rather than just read about it. In short: The distance (or perpendicular distance) from a point to a line is the shortest distance from a fixed point to any point on a fixed infinite line in Euclidean geometry. It is the length of the line segment that joins the point to the line and is perpendicular to the line.

Distance from a point to a line — main illustration
Distance from a point to a line — illustration

Key takeaways

  • Distance from a point to a line belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Distance from a point to a line to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Distance from a point to a line from memory before moving on to harder problems.

Reference excerpt

The distance (or perpendicular distance) from a point to a line is the shortest distance from a fixed point to any point on a fixed infinite line in Euclidean geometry. It is the length of the line segment that joins the point to the line and is perpendicular to the line. The formula for calculating it can be derived and expressed in several ways. Knowing the shortest distance from a point to a line can be useful in various situations—for example, finding the shortest distance to reach a road, quantifying the scatter on a graph, etc. In Deming regression, a type of linear curve fitting, if the dependent and independent variables have equal variance, this results in orthogonal regression in which the degree of imperfection of the fit is measured for each data point as the perpendicular distance of the point from the regression line.

Cartesian coordinates

Line defined by an equation In the case of a line in the plane given by the equation ax+by+c=0 where a, b and c are real constants with a and b not both zero, the distance from the line to a point (x0,y0) is

distance⁡(ax+by+c=0,(x0,y0))=|ax0+by0+c|a2+b2. The point on this line that is closest to (x0,y0) has coordinates:

x=b(bx0−ay0)−aca2+b2 and y=a(−bx0+ay0)−bca2+b2 or equivalentlyx=x0−aax0+by0+ca2+b2 and y=y0−bax0+by0+ca2+b2Horizontal and vertical lines In the general equation of a line, ax+by+c=0, a and b cannot both be zero unless c is also zero; in that case, the equation does not define a line. If a=0 and b≠0, the line is horizontal and has equation y=−c/b. The distance from (x0,y0) to this line is measured along a vertical line segment of length |y0−(−c/b)|=|by0+c|/|b| in accordance with the formula. Similarly, for vertical lines (b=0) the distance between the same point and the line is |ax0+c|/|a|, as measured along a horizontal line segment.

Line defined by two points If the line passes through two points P1=(x1,y1) and P2=(x2,y2) then the distance of (x0,y0) from the line is:

distance⁡(P1,P2,(x0,y0))=|(y2−y1)x0−(x2−x1)y0+x2y1−y2x1|(y2−y1)2+(x2−x1)2. The denominator of this expression is the distance between P1 and P2. The numerator is twice the area of the triangle with its vertices at the three points, (x0,y0), P1 and P2. See: Area of a triangle § Using coordinates. The expression is equivalent to h=2Ab, which can be obtained by rearranging the standard formula for the area of a triangle: A=12bh, where b is the length of a side, and h is the perpendicular height from the opposite vertex.

Line defined by point and angle If the line passes through the point P=(Px,Py) with angle θ, then the distance of some point (x0,y0) to the line is

distance⁡(P,θ,(x0,y0))=|cos⁡(θ)(Py−y0)−sin⁡(θ)(Px−x0)|

Proofs

An algebraic proof This proof is valid only if the line is neither vertical nor horizontal, that is, we assume that neither a nor b in the equation of the line is zero. The line with equation ax+by+c=0 has slope −a/b, so any line perpendicular to it will have slope b/a (the negative reciprocal). Let (m,n) be the point of intersection of the line ax+by+c=0 and the line perpendicular to it which passes through the point (x0,y0). The line through these two points is perpendicular to the original line, so

y0−nx0−m=ba. Thus, a(y0−n)−b(x0−m)=0, and by squaring this equation we obtain:

a2(y0−n)2+b2(x0−m)2=2ab(y0−n)(x0−m). Now consider,

(a(x0−m)+b(y0−n))2=a2(x0−m)2+2ab(y0−n)(x0−m)+b2(y0−n)2=(a2+b2)((x0−m)2+(y0−n)2) using the above squared equation. But we also have,

(a(x0−m)+b(y0−n))2=(ax0+by0−am−bn)2=(ax0+by0+c)2 since (m, n) is on ax + by + c = 0. Thus,

(a2+b2)((x0−m)2+(y0−n)2)=(ax0+by0+c)2 and we obtain the length of the line segment determined by these two points,

d=(x0−m)2+(y0−n)2=|ax0+by0+c|a2+b2.

A geometric proof

This proof is valid only if the line is not horizontal or vertical. Drop a perpendicular from the point P with coordinates (x0,y0) to the line with equation Ax+By+C=0. Label the foot of the perpendicular R. Draw the vertical line through P and label its intersection with the given line S. At any point T on the line, draw a right triangle TVU whose sides are horizontal and vertical line segments with hypotenuse TU on the given line and horizontal side of length |B| (see diagram). The vertical side of △TVU will have length |A| since the line has slope −A/B. △PRS and △TVU are similar triangles, since they are both right triangles and ∠PSR≅∠TUV since they are corresponding angles of a transversal to the parallel lines PS and UV (both are vertical lines). Corresponding sides of these triangles are in the same ratio, so:

|PR‾||PS‾|=|TV‾||TU‾|. If point S has coordinates (x0,m) then |PS|=|y0−m| and the distance from P to the line is:

|PR‾|=|y0−m||B|A2+B2. Since S is on the line, we can find the value of m,

m=−Ax0−CB, and finally obtain:

|PR‾|=|Ax0+By0+C|A2+B2. A variation of this proof is to place V at P and compute the area of the triangle △UVT two ways to obtain that D|TU‾|=|VU‾||VT‾| where D is the altitude of △UVT drawn to the hypoteneuse of △UVT from P. The distance formula can then used to express |TU‾|, |VU‾|, and |VT‾|in terms of the coordinates of P and the coefficients of the equation of the line to get the indicated formula.

A vector projection proof

Let P be the point with coordinates (x0,y0) and let the given line have equation ax+by+c=0. Also, let Q=(x1,y1) be any point on this line and n the vector (a,b) starting at point Q. The vector n is perpendicular to the line, and the distance d from point P to the line is equal to the length of the orthogonal projection of QP→ on n. The length of this projection is given by:

d=|QP→⋅𝐧|‖𝐧‖. Now,

QP→=(x0−x1,y0−y1), so QP→⋅𝐧=a(x0−x1)+b(y0−y1) and ‖𝐧‖=a2+b2, thus

d=|a(x0−x1)+b(y0−y1)|a2+b2. Since Q is a point on the line, c=−ax1−by1, and so,

d=|ax0+by0+c|a2+b2.

Another formula It is possible to produce another expression to find the shortest distance of a point to a line. This derivation also requires that the line is not vertical or horizontal. The point P is given with coordinates (x0,y0). The equation of a line is given by y=mx+k. The equation of the normal of that line which passes through the point P is given y=x0−xm+y0. The point at which these two lines intersect is the closest point on the original line to the point P. Hence:

mx+k=x0−xm+y0. We can solve this equation for x,

x=x0+my0−mkm2+1. The y coordinate of the point of intersection can be found by substituting this value of x into the equation of the original line,

… excerpt ends here. Continue reading the full article.

Illustrations

Distance from a point to a line: Diagram for vector projection proof
Diagram for vector projection proof
Distance from a point to a line: Illustration of the vector formulation.
Illustration of the vector formulation.

Worked examples

Example 1 — a first encounter with Distance from a point to a line

Start with the simplest possible case. Write down what Distance from a point to a line claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Distance from a point to a line before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Distance from a point to a line ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Distance from a point to a line

In research
Distance from a point to a line appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Distance from a point to a line in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Distance from a point to a line is common in secondary-school and first-year university syllabi. It links to neighbouring topics Distance, Euclidean geometry, Vectors (mathematics and physics), so understanding it makes those chapters shorter.
In everyday life
Look for Distance from a point to a line outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Distance from a point to a line” →

How to study Distance from a point to a line in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Distance from a point to a line means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Distance from a point to a line out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Distance from a point to a line in simple terms?

The distance (or perpendicular distance) from a point to a line is the shortest distance from a fixed point to any point on a fixed infinite line in Euclidean geometry. It is the length of the line segment that joins the point to the line and is perpendicular to the line.

Why does Distance from a point to a line matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Distance from a point to a line?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Distance from a point to a line.

Tags

  • Distance
  • Euclidean geometry
  • Vectors (mathematics and physics)

Keep exploring