Geometry · Eqora guide

Point-to-line distance: a free worked guide

Practice point-to-line distance for free. Derive the formula, find the perpendicular foot, check signs and distinguish an infinite line from a segment.

Woman in green overalls aligning a brass square against a wooden rail in a mint courtyard

Point-to-line distance is easy to confuse with a vertical gap on a graph. A point may sit several units above a sloping line, yet its shortest route to that line runs diagonally. The required distance follows a perpendicular, not whichever direction looks easiest to measure. You can calculate it without an app, a subscription or a drawing made perfectly to scale.

This free worked guide develops the formula in two dimensions, finds the perpendicular foot and checks the result in different ways. All coordinates and situations below are invented exercises. The photographs use rails, a square and simple objects as conceptual analogies; they are not measured diagrams and do not supply numerical information for the examples. Use the stated coordinates and equations throughout.

What point-to-line distance actually measures

Imagine a point P outside an infinite straight line. Among all the points on that line, one is closest to P. Call it H. The segment from P to H meets the line at a right angle, and its length is the distance we want. H is called the perpendicular foot or orthogonal projection of P onto the line. If P already lies on the line, the distance is zero and H equals P.

Why is perpendicular the shortest choice? Take any other point Q on the line. Triangle PHQ has a right angle at H, so PQ² = PH² + HQ². The second term cannot be negative. Consequently PQ cannot be shorter than PH; it is longer whenever Q differs from H. This argument explains the minimum rather than relying on a diagram that merely looks convincing.

The calculation assumes an ordinary Cartesian plane with perpendicular axes and a common length scale. If one axis records time and the other records money, raw coordinate distance has no automatic physical meaning. A graph stretched differently in the two directions can also make a perpendicular look misleading. Our guide to geometry diagrams explains why visual appearance must be separated from stated mathematical information.

Read the coefficients from a zero-right-side equation

Write the line as Ax + By + C = 0, where A and B are not both zero. For P = (x₀, y₀), the distance is d = |Ax₀ + By₀ + C|/√(A² + B²). Substitute the point in the numerator, take the absolute value of the whole expression, and divide by the positive length of the coefficient vector. The denominator is not A + B and does not include C.

The vector n = (A, B) is perpendicular to the line. To see this, let U and V be points on it. Their two line equations subtract to give A(Vx − Ux) + B(Vy − Uy) = 0. That is a zero dot product between n and a direction along the line. Dividing a normal displacement by the normal vector's length produces the actual length rather than a coefficient-dependent number.

Move every term to the same side before reading coefficients. For y = mx + b, one valid form is mx − y + b = 0, so A = m, B = −1 and C = b. Changing only one sign during this conversion changes the line. Keep parentheses when coordinates are negative and preserve the square root around the entire denominator. A tidy line equation is part of the solution, not an optional presentation step.

Brass square beside a straight wooden rail and an ivory ball on a mint slab

Work through one example with exact arithmetic

Find the distance from P = (4, 1) to 3x + 4y − 2 = 0. Here A = 3, B = 4 and C = −2. Substitution gives 3 × 4 + 4 × 1 − 2 = 14. The denominator is √(3² + 4²) = √25 = 5. Therefore d = |14|/5 = 14/5 = 2.8 coordinate units. There is no need to approximate a square root in this example.

Compare this with the vertical separation at x = 4. On the line, 12 + 4y − 2 = 0, so y = −2.5. The given point has y = 1, making that vertical gap 3.5. This is a valid length, but it is not the shortest length. The perpendicular distance 2.8 is smaller, exactly as the right-triangle argument predicts. A correct substitution into the wrong geometric question still gives the wrong answer to the assignment.

Keep the answer attached to its interpretation: 2.8 is the shortest separation from this point to this infinite line. It is not a coordinate of the foot and not the distance to an intercept. If the coordinates represent meters on both axes, the result represents meters. Without a supplied physical unit, report coordinate units. Do not invent centimeters merely because the sketch was printed on paper.

Find the foot and perform two different checks

The distance formula gives a length, but you can independently locate H. Let s = Ax₀ + By₀ + C. Subtract s/(A² + B²) times the normal vector from P: H = (x₀ − As/(A² + B²), y₀ − Bs/(A² + B²)). The denominator here is the squared normal length. Confusing it with the square-root denominator in the distance formula produces an incorrect foot.

For our example, s = 14 and A² + B² = 25. Thus H = (4 − 42/25, 1 − 56/25) = (58/25, −31/25), or (2.32, −1.24). First substitute H into the original line: 3 × 58/25 + 4 × (−31/25) − 2 = 0. This confirms membership. Finding a point that happens to be near the line on a sketch is not enough.

Second, check perpendicularity. A direction vector for the line is v = (4, −3). The displacement P − H is (42/25, 56/25), whose dot product with v is 168/25 − 168/25 = 0. Its length is √(42² + 56²)/25 = 70/25 = 2.8. Membership and perpendicularity together establish the correct foot; the length then confirms the earlier distance. Our answer-checking guide develops this habit of using a different representation to test a result.

Hands holding an ivory ball beside a cord leading to a wooden rail

Explain the absolute value and scaling check

You can derive the foot formula directly. Any move from P along the normal has the form H = P − rn for a real number r. Substituting this expression into the line equation gives s − r(A² + B²) = 0. Since the normal is nonzero, solve uniquely for r = s/(A² + B²). The move is normal to the line and ends on it, establishing both required conditions. This also explains why the squared length appears when calculating coordinates, while the ordinary length appears when calculating distance.

Multiply every coefficient of the line by −2. Its equation becomes −6x − 8y + 4 = 0, which describes the same points. At P, the new numerator before absolute value is −28 and the denominator is ten. The result remains 28/10 = 2.8. A formula that gives a different distance after this harmless rewriting cannot be measuring the geometry consistently.

In general, multiplying A, B and C by a nonzero number k multiplies the absolute numerator and the denominator by |k|. The factor cancels. This is why taking the absolute value around the complete substituted expression matters. Taking absolute values of the three terms separately would destroy cancellation and could even report a positive distance for a point lying on the line. Treat the expression as one quantity before converting it to a nonnegative length.

Without the absolute value, s/√(A² + B²) is an oriented signed distance relative to the chosen normal. Positive and negative identify opposite sides. Reversing the normal reverses that sign, while the ordinary distance stays unchanged. Unless the task explicitly asks for an oriented quantity, report a nonnegative length. A minus sign in an intermediate step can be useful information; a negative final ordinary distance is a signal to inspect the setup.

Handle axis-parallel and parallel-line cases

The coefficient formula also handles vertical lines, for which a slope is undefined. The line x = −3 becomes x + 3 = 0. From P = (2, 5), d = |2 + 3|/√1 = 5. The foot is (−3, 5), a horizontal move. For y = 4 and P = (−2, −1), the distance is |−1 − 4| = 5, with foot (−2, 4). No special infinite-slope arithmetic is necessary.

Two parallel lines with exactly matching A and B, written Ax + By + C₁ = 0 and Ax + By + C₂ = 0, have separation |C₂ − C₁|/√(A² + B²). For 3x + 4y − 2 = 0 and 3x + 4y − 12 = 0, that is ten divided by five, or two. The point (4, 0) lies on the second line; substituting it into the first distance formula gives the same separation.

Match the coefficient scale before comparing constants. Equations with proportional normals must first be rewritten to share the same A and B; otherwise subtracting their C terms is meaningless. Also reject the degenerate case A = B = 0. If C is zero, the equation describes the entire plane; if C is nonzero, it describes no points. Neither is a line, and dividing by a zero denominator does not fix that missing condition.

Two parallel wooden rails with an ivory ball between them and a brass square beside them

Decide whether the target is a line or a segment

An infinite line continues in both directions. A segment stops at its endpoints, so the perpendicular foot may lie outside the allowed target. Consider the segment from U = (0, 0) to V = (2, 0) and the point P = (3, 1). The supporting line is y = 0, whose perpendicular foot is (3, 0). Its distance from P is one, but the foot is beyond V and is not part of the segment.

The nearest point of this segment is V = (2, 0), giving distance √((3 − 2)² + (1 − 0)²) = √2. That is larger than one, as expected when the set of allowed target points becomes smaller. This example is a useful safeguard when a problem mentions a fence, a route section or a finite edge: the everyday object may be a segment even when its supporting equation describes an entire line.

With a parameterization U + t(V − U), the unconstrained perpendicular foot has t = ((P − U) · (V − U))/||V − U||². Here t = 6/4 = 1.5. An infinite line permits it; the segment permits only 0 ≤ t ≤ 1. For a segment, restrict t to that interval before measuring the final length. Distinct endpoints are required for this formula. A collapsed segment is just one point, so use point-to-point distance instead.

Practice a new point and check the interpretation

When you round a foot's coordinates, substituting those rounded coordinates may leave a small residual instead of exact zero. Check the exact fractions first. A tiny rounding discrepancy is different from a wrong equation or a missing sign, and the requested precision belongs to the final length rather than every intermediate coordinate.

Try P = (−1, 5) and the line 2x − y + 1 = 0 without looking back at the worked substitution. Write the coefficients, calculate the signed residual, then obtain the ordinary distance. Your residual should be −6 and the normal length √5, giving d = 6/√5 = 6√5/5 ≈ 2.6833. The negative residual identifies a side; it does not make the length negative.

For an independent check, the foot is H = (7/5, 19/5). It satisfies 2 × 7/5 − 19/5 + 1 = 0. The displacement H − P = (12/5, −6/5) is perpendicular to direction (1, 2), since their dot product is zero. Its squared length is 180/25 = 36/5, consistent with the square of 6/√5. Keep exact fractions until the final rounding so that a rounded foot does not obscure these checks.

This method gives a complete paper-and-calculator solution. If you later use Eqora or another source of assistance, compare the original equation, signs, geometric target and foot conditions with your own work. Assistance does not guarantee correctness or grades and must respect your course's assessment rules. A reliable final answer includes the distance, its units and the statement that it measures the shortest perpendicular separation to the specified target.

Man in a sage shirt writing on a clipboard in a pale mint courtyard

Your next problem, with a clearer path

Ready to understand the math?

Scan a problem, ask follow-up questions, and turn one difficult step into a method you can use again.

Good to know

Questions about this guide