Skip to content
Allin

How to Find the Distance Between Two Points

Published 2/23/2026 · 4 min read · Everyday calculators

Lena Hoffmann

Lena HoffmannScience & education writer at Allin

Mathematics · Physics

Checked against 2 sources

View profile
In short

The distance between two points (x₁, y₁) and (x₂, y₂) is d = √((x₂−x₁)² + (y₂−y₁)²). It comes straight from the Pythagorean theorem: the horizontal gap and the vertical gap are the two legs of a right triangle, and the distance is the hypotenuse. For (1, 2) and (4, 6), the gaps are 3 and 4, so d = √(9 + 16) = √25 = 5. The midpoint of the same two points is ((x₁+x₂)/2, (y₁+y₂)/2) = (2.5, 4).

Use the distance formula d = √((x₂−x₁)² + (y₂−y₁)²) to measure the straight-line distance between two points on a plane, with a worked example and the midpoint too.

Why the formula is really Pythagoras

Plot two points and draw a horizontal line from one and a vertical line from the other. They meet at a right angle, forming a right triangle whose legs are the horizontal gap (x₂−x₁) and the vertical gap (y₂−y₁). The straight-line distance between the points is the hypotenuse of that triangle.

Pythagoras says leg² + leg² = hypotenuse², so (x₂−x₁)² + (y₂−y₁)² = d². Taking the square root of both sides gives d = √((x₂−x₁)² + (y₂−y₁)²). That is the whole formula — nothing is memorized that the triangle does not already explain, which is why it also generalizes to three dimensions by adding a (z₂−z₁)² term.

A worked example from start to finish

Take the points A = (1, 2) and B = (4, 6). The horizontal gap is x₂−x₁ = 4−1 = 3 and the vertical gap is y₂−y₁ = 6−2 = 4. Square them: 3² = 9 and 4² = 16. Their sum is 25, and √25 = 5, so A and B are exactly 5 units apart.

The midpoint of A and B — the point exactly halfway along the segment — averages the coordinates: ((1+4)/2, (2+6)/2) = (2.5, 4). Check it: the distance from A to the midpoint is √(1.5² + 2²) = √(2.25 + 4) = √6.25 = 2.5, which is half of 5, exactly as it should be.

Common mistakes and quick checks

The most common slip is squaring before subtracting — writing x₂² − x₁² instead of (x₂−x₁)². Those are not equal, and the second is what the formula needs. Always compute the gap first, then square it. A negative gap is fine: squaring makes it positive, which is why swapping the two points gives the same answer.

For a quick sanity check, the distance can never be smaller than either the horizontal or the vertical gap on its own — the hypotenuse is always the longest side. If your answer comes out less than 3 in the example above, you have made an arithmetic error. And if both points share an x or a y value, the formula collapses to a simple subtraction, which is a handy way to test your setup.

Distance Formula CalculatorFind the distance between two points on an interactive coordinate plane, with the Pythagorean working, the midpoint, the slope and the direction angle.Try the tool

Frequently asked questions

Does it matter which point I call the first one?
No. Because each gap is squared, (x₂−x₁)² equals (x₁−x₂)², so swapping the two points gives exactly the same distance. Pick whichever order is easier to subtract.
How do I find the midpoint between two points?
Average the coordinates: the midpoint is ((x₁+x₂)/2, (y₁+y₂)/2). For (1, 2) and (4, 6) that is (2.5, 4). The midpoint always lies on the straight line joining the two points.
Does the formula work in three dimensions?
Yes. Add a third squared gap for the z-axis: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). The same Pythagorean idea extends to any number of dimensions by adding one squared term per axis.
Can the distance ever be negative?
No. A distance is a length, and the square root in the formula returns the non-negative value. It is zero only when the two points are identical, and positive otherwise.

Articles you may find interesting

All guides

Related tools

Sources

Spotted a mistake in this article?