Two points in a coordinate plane, (x₁, y₁) and (x₂, y₂). The distance between them is
d = √((x₂ − x₁)² + (y₂ − y₁)²)
It is a formula to recognise rather than memorise, because it is
Pythagoras’ theorem with the legs written out
as differences.
The derivation: a right triangle
Plot the two points, then draw a horizontal line from one and a vertical line from the other. They meet,
and you have a right triangle in which the segment between the points is the hypotenuse.
- The horizontal leg is the difference in x: x₂ − x₁.
- The vertical leg is the difference in y: y₂ − y₁.
- The angle between them is right, because the axes are perpendicular.
Pythagoras gives d² = (x₂ − x₁)² + (y₂ − y₁)², and taking the square root of both sides gives the formula.
The triangle can be drawn for any two points except when one sits directly above or beside the other — and
then the distance is just the one difference, which is what the formula gives too, because the other
square is zero.
The order does not matter
Compute x₁ − x₂ instead of x₂ − x₁ and you get the opposite sign. But the difference is squared, and the
square is the same either way: (−3)² and 3² are both 9. The distance comes out the same.
This differs from the
slope, where the order has to match in
numerator and denominator for the answer to be right. Distance has no direction; slope does.
Worked examples
Forwards. From (1, 2) to (4, 6). The differences are 3 and 4, so d = √(9 + 16) = √25 = 5. That is
the 3-4-5 triangle laid on the plane.
A more typical answer. From (0, 0) to (3, 5): d = √(9 + 25) = √34 ≈ 5.83. Most distances are
irrational — triangles with whole-number answers are the exception, not the rule.
Backwards. A point is 5 away from (1, 2) and has y = 6. The horizontal difference then has to satisfy
(x − 1)² = 25 − 16 = 9, so x − 1 = ±3. The point is (4, 6) or (−2, 6) — two answers, one on each
side.
Common mistakes
- Dropping the squares. |x₂ − x₁| + |y₂ − y₁| is not the distance but the route round the corner. It is
longer, unless the points lie on a horizontal or vertical line.
- Rooting each term separately. √(9 + 16) is 5, not 3 + 4 = 7.
- Getting a difference wrong with negatives. 2 − (−3) is 5, not −1.
- Giving only the positive answer when the formula is reversed. If you are after a coordinate there
are two points, not one.
Common questions
Does it matter which point I call the first?
No. The squares remove the sign, so either choice gives the same distance.
Does the formula work in three dimensions?
Yes, with one more term: d = √(Δx² + Δy² + Δz²). It is the same theorem applied twice, just like the
space diagonal of a cuboid.
Why is the answer almost always a surd?
Because the sum of two squares is rarely a square. The pairs that give whole numbers are the
Pythagorean triples, and they are thinly spread.
How do I find the point halfway between?
Average the coordinates separately: ((x₁ + x₂)/2, (y₁ + y₂)/2). See the
midpoint page.