Distance Formula in Math: Between Two Points & Examples

BT
Bhanzu TeamLast updated on April 20, 202613 min read

The distance formula gives the straight-line distance between two points on a coordinate plane. For points (x₁, y₁) and (x₂, y₂), the formula is:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

It works because any two points on a flat plane form the hypotenuse of a right triangle, and Pythagoras already solved that one.

This matters because everything from GPS to video game physics to the equation of a circle depends on being able to calculate how far apart two points are. Before coordinates existed, the only way to measure distance was with a ruler and a map. After coordinates, it became arithmetic.

Say you're a navigator in 1750. Two ships are at sea. Your map gives their positions as (3, 4) and (6, 8) in whatever grid your captain drew on it. You need to know how many units apart they are, quickly, because one of them might be a threat. No GPS. No radar. Just two pairs of numbers and a formula. Plug them in: d = √[(6−3)² + (8−4)²] = √[9 + 16] = √25 = 5 units apart.

That is the entire tool. Everything below is how to use it without making mistakes.

What Is the Distance Formula?

The distance formula is used in coordinate geometry to find the straight-line distance between any two points on an XY plane. Given two points (x₁, y₁) and (x₂, y₂):

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

Three things to know before going further.

📘 Key terms

  • Coordinate: A pair of numbers (x, y) that pins a point to a specific spot on the plane. The x tells you how far across. The y tells you how far up.

  • The subscripts (the tiny 1s and 2s): Not doing math. Just labels. "Point 1" and "Point 2." You can pick which point is which in any order you like — the answer comes out the same.

  • Hypotenuse: The longest side of a right triangle, the slanted one opposite the right angle. In the distance formula, the distance d is the hypotenuse of a right triangle formed by the two points.

One quick thing to clear up. If you searched "distance formula" looking for speed × time (distance = speed × time), that is a different topic entirely. This article is about the distance formula in coordinate geometry — the one you use when you have two points and need the straight-line distance between them.

Why the Distance Formula Exists — The Descartes Story

🕰️ A quick bit of history

The distance formula didn't always exist. In the 1630s, a French philosopher named René Descartes did something radical: he laid a grid of numbers on top of geometric shapes, and suddenly lines, angles, and distances could all be calculated with algebra. Before Descartes, measuring the distance between two points meant drawing them on paper and measuring with a ruler. After Descartes, you could do it with arithmetic alone. Which is exactly what the distance formula is — arithmetic for a task that used to require a ruler.


How to Derive the Distance Formula from Pythagoras

Start with two specific points: A(2, 1) and B(5, 5). To find the distance between them, meaning the length of the straight line joining them, do this.

Plot both points. Then drop a horizontal line from A and a vertical line from B so the two lines meet at a right angle. You now have a right triangle. A and B sit at the two non-right corners, and the line joining them (AB) is the hypotenuse.

The horizontal leg runs from x = 2 to x = 5. Length 3. The vertical leg runs from y = 1 to y = 5. Length 4.

Now Pythagoras. In any right triangle, the hypotenuse squared equals the sum of the other two sides squared:

hypotenuse² = 3² + 4² = 9 + 16 = 25

So the hypotenuse (the distance AB) is √25 = 5.

That is the distance formula with specific numbers. To write the general version, replace the 3 with (x₂ − x₁) and the 4 with (y₂ − y₁):

d² = (x₂ − x₁)² + (y₂ − y₁)²

Take the square root of both sides:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

The distance formula is Pythagoras wearing coordinate clothes. Nothing more.

How to Use the Distance Formula — Step by Step

Three steps. Label the points. Plug into the formula. Simplify.

Work through it with (x₁, y₁) = (−2, 3) and (x₂, y₂) = (4, 11).

  1. Label the points. It doesn't matter which one you call "point 1" and which you call "point 2." Pick an order and stick with it for this calculation.

  2. Plug into the formula. d = √[(4 − (−2))² + (11 − 3)²]

  3. Simplify. Inside the first bracket: 4 − (−2) = 6. Inside the second: 11 − 3 = 8. So d = √[6² + 8²] = √[36 + 64] = √100 = 10.

A quick note on the subtraction step. Actually, two notes, because this is where most slip-ups happen. First: when a coordinate is negative, the minus signs get confusing fast (subtracting a negative becomes adding a positive). Second: the squaring erases any direction error. (x₂ − x₁)² and (x₁ − x₂)² give the same answer. That is why the "pick any order" freedom actually works.

Distance Formula Examples (5 Worked Problems)

Example 1 — Two Points in the First Quadrant

Find the distance between A(3, 4) and B(6, 8).

d = √[(6 − 3)² + (8 − 4)²] d = √[3² + 4²] d = √[9 + 16] d = √25 d = 5

The 3-4-5 right triangle shows up everywhere. Anytime you see those legs, the hypotenuse is 5.

Example 2 — One Negative Coordinate

Find the distance between P(−1, 2) and Q(3, 5).

d = √[(3 − (−1))² + (5 − 2)²] d = √[4² + 3²] d = √[16 + 9] d = √25 d = 5

Two different pairs of points. Same distance. That is because what matters is the difference between coordinates, not the coordinates themselves.

Example 3 — Distance from the Origin

Find the distance between O(0, 0) and P(6, 8).

When one point is the origin (0, 0), the formula simplifies. Everything subtracted from zero is itself.

d = √[6² + 8²] d = √[36 + 64] d = √100 d = 10

That simplified form, d = √(x² + y²), is worth remembering on its own. You will see it again in Grade 11 as the magnitude of a vector, and in complex numbers as the modulus |z| = √(a² + b²). It is the same calculation with different clothes on.

Example 4 — Points on the Same Vertical Line

Find the distance between A(4, 2) and B(4, 9).

Both points have x = 4. They are stacked vertically. The horizontal distance between them is zero.

d = √[(4 − 4)² + (9 − 2)²] d = √[0 + 49] d = √49 d = 7

Which is the same as just subtracting the y-coordinates: 9 − 2 = 7. For points on the same vertical line, the distance is the difference in y. For points on the same horizontal line, the distance is the difference in x. The formula still works. It just collapses into something simpler.

Example 5 — Try the Wrong Method First

Find the distance between A(1, 2) and B(4, 6).

Before using the formula, a student's first instinct might be: "The horizontal gap is 3 and the vertical gap is 4, so the distance is 3 + 4 = 7."

Let that answer sit for a second.

Now actually draw it. You have a right triangle with legs of 3 and 4. The path of length 7 is what you would walk if you had to go strictly along the grid, three units right and then four units up. The distance formula is not measuring that path. It is measuring the diagonal. The straight line. The shortcut.

By Pythagoras, the diagonal is √[3² + 4²] = √25 = 5. Not 7.

So the correct method:

d = √[(4 − 1)² + (6 − 2)²] d = √[3² + 4²] d = √[9 + 16] d = √25 d = 5

Adding the legs gives you the walking distance. The distance formula gives you the flying distance. These are different numbers, and in coordinate geometry, "distance between two points" always means the flying distance.

Distance Formula in 3D Space

The formula extends naturally into three dimensions. Just add a z-term. For points (x₁, y₁, z₁) and (x₂, y₂, z₂):

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

Worked example. Find the distance between (1, 2, 3) and (4, 6, 3).

d = √[(4 − 1)² + (6 − 2)² + (3 − 3)²] d = √[9 + 16 + 0] d = √25 d = 5

This is the same calculation a video game is running when it checks how far apart two characters are in a 3D world, and what a drone's autopilot is computing when deciding whether another drone is too close to be safe. The logic is identical to 2D. You carry one more squared difference under the root.

Common Mistakes Students Make With the Distance Formula

Four mistakes come up over and over. The first is by far the most common.

Students forget the square root at the end. They get to √25 and write d = 25. The expression under the root was right. The answer is wrong. In a recent Bhanzu live class of 32 students seeing the formula for the first time, close to half computed the sum of squared differences correctly and then stopped there. That one missing step costs more marks on this topic than anything else. [Data point: Bhanzu to confirm exact figure from internal class data.]

The second mistake is pairing coordinates wrong, writing (x₂ − y₁) instead of (x₂ − x₁). This is what the memorizer does. The student who can recite the steps but blanks on the structure when the problem looks slightly unfamiliar. The fix is mechanical. Write the formula out first with blanks. Fill the blanks one at a time. Then compute.

The third is squaring each term separately. Writing x₂² − x₁² instead of (x₂ − x₁)². These are not the same expression. Expanding (x₂ − x₁)² correctly gives x₂² − 2x₁x₂ + x₁². The shortcut erases that middle term, and the answer drifts.

The last one shows up with the second-guesser. The student who gets it right, doesn't trust themselves, and redoes the calculation with the points swapped. They get a different-looking expression, panic, and assume they've made an error. They haven't. Squaring makes the order irrelevant. (4 − 1)² and (1 − 4)² both give 9.

Bhanzu trainers catch these four patterns in Session 1, before they become habits that cost marks in Session 10. [LINK → Bhanzu live class program]

Distance Formula vs Midpoint Formula — What's the Difference?

These two formulas look alike on the page, which is part of the problem. Students swap them more often than any other pair of coordinate geometry formulas. When they are first introduced in the same week, keeping them apart genuinely takes some practice. (Worth admitting: I mixed them up myself the first time I learned both.)

Distance Formula

Midpoint Formula

What it tells you

How far apart two points are

The exact centre of the line segment between two points

Formula

d = √[(x₂−x₁)² + (y₂−y₁)²]

M = ((x₁+x₂)/2, (y₁+y₂)/2)

The answer is

A single number (a length)

A pair of coordinates (a point)

When to use it

Asked "how far" or "how long"

Asked "where is the middle"

The fastest way to tell them apart: the distance formula subtracts, squares, adds, and roots. Its answer is one number. The midpoint formula adds and divides by two. Its answer is a pair of coordinates. Different operations. Different outputs. Different questions.

Where the Distance Formula Shows Up Later in Math

The distance formula is not a standalone Grade 10 topic that you learn and then forget. It reappears in a handful of places worth knowing now, even if the later topics are still a year or two away.

The magnitude of a vector, introduced in Grade 11, is the distance formula with the first point fixed at the origin.

The modulus of a complex number, written |z|, is the same "square root of sum of squares" applied to the real and imaginary parts.

The equation of a circle, (x − h)² + (y − k)² = r², is literally the distance formula squared. It says "every point on this circle is a fixed distance r from the centre (h, k)."

Outside math class, the same calculation powers GPS navigation, the nearest-neighbour algorithms behind product recommendations, and distance thresholds in epidemic contact tracing. It is one of the most-used formulas in applied math, and you have just learned it. (There are a few other reappearances in higher math, but those four are the ones most worth knowing while you are still in school.)

What to Try Next

Pick five pairs of points yourself. Mix them up: some positive, some negative, one pair on the same axis, one pair with fractions if you want a challenge. Compute the distance for each. If any example trips you up, go back to the matching worked example above and retrace the steps.

To build a full foundation in coordinate geometry — distance formula, midpoint formula, section formula, equation of a line — a Bhanzu trainer walks your child through each topic live, starting from Level 0 and building up one step at a time. [LINK → Book a free Bhanzu trial class]

One last thing. Now that you can find the distance between two points, the next natural question is this: can you find the exact point halfway between them? That is the midpoint formula. Same two points. Different math. Completely different answer.

FAQs

Does the order of the two points matter?

No. Squaring makes any sign difference vanish, so (x₂ − x₁)² and (x₁ − x₂)² give the same value.

Can the distance between two points be negative?

Never. The formula takes a square root of a sum of squares, so the result is always positive. It can only equal zero if the two points are identical.

What's the difference between the distance formula and the midpoint formula?

The distance formula gives you a number — how far apart two points are. The midpoint formula gives you a coordinate — the exact point halfway between them. We walked through the full comparison in the section above.

It is the Pythagorean theorem applied to coordinates. If you plot two points and draw a right triangle using the horizontal and vertical grid lines between them, the horizontal leg has length |x₂ − x₁|, the vertical leg has length |y₂ − y₁|, and the hypotenuse is the distance between the two points. The distance formula is Pythagoras with x and y labels instead of a and b.

Does the distance formula work in three dimensions?

Yes. Add a third squared difference under the root: d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. The logic is the same. Pythagoras, extended one dimension up.

Why is it called the Euclidean distance formula?

Euclid was the Greek mathematician whose flat-plane geometry is still the geometry we learn in school. "Euclidean distance" means straight-line distance in flat space, as opposed to distances measured along curved surfaces (like the shortest flight path across the Earth, which uses a different formula entirely). Most of the time when you hear "distance formula," Euclidean distance is what is meant.

Was this article helpful?

Your feedback helps us write better content