On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

Math · Geometry Fundamentals · Grade 9-12

Distance Formula

The distance formula finds the straight-line distance between two points by squaring the differences in x and y, adding, and taking the root.

d=(x2−x1)2+(y2−y1)2

Quick Answer

The distance formula finds the straight-line distance between two points by squaring the differences in x and y, adding, and taking the root. Use it when you know two points' coordinates and need how far apart they are: two towns on a grid map, a drone's position from its launch pad, the length of a side of a figure drawn on axes. The horizontal and vertical gaps are the legs of a right triangle and the distance is its hypotenuse: d=(x2−x1)2+(y2−y1)2.

Why This Matters

The distance formula measures any slanted segment from coordinates alone, with no ruler: the side lengths of a triangle on a grid, the radius of a circle through a given point, the straight-line distance a map app reports. It is the tool behind coordinate proofs and the equation of a circle. Adding the gaps without squaring gives the walking distance along the grid, which is longer.

Intuitive Explanation

Put two points on graph paper, A(2,1) and B(8,9). Walk from A to B along the grid lines: 6 units right, then 8 units up. Those two moves are the legs of a right triangle, and the straight segment AB is its hypotenuse. The Pythagorean theorem gives AB2=62+82=100, so AB=10. The distance formula is that triangle written with coordinates: the legs are x2−x1 and y2−y1.

Signs take care of themselves. Going from (8,9) back to (2,1) gives gaps of −6 and −8, but (−6)2=36 and (−8)2=64, the same squares as before, so the distance is still 10. Order does not matter, as long as you subtract x from x and y from y. Two points on the same horizontal line have a y-gap of 0, and the formula reduces to the difference of their x-values.

The walk along the grid, 6+8=14, is a different measure, sometimes called taxicab distance, and it is never shorter than the straight line. The midpoint uses the same two points but averages them to find a location, (5,5), not a length. Slope compares the same gaps by dividing, 86=43, to describe steepness. Decide whether the question wants how far, where, or how steep.

Think of it like this. The distance formula is how a crow flies across a city laid out in square blocks. A taxi must drive 3 blocks east and 4 north, 7 blocks in all; the crow flies the hypotenuse, 5 blocks. Real cities have uneven blocks and hills, but on the coordinate grid the crow's path is exact.

Core idea. The straight-line distance between two points is the hypotenuse of the right triangle made by their coordinate differences.


When to Use

Use the distance formula when you have two points' coordinates and need the length between them: how far apart, the length of a side, the radius from a center to a point. If the points share an x or a y value, just subtract the other coordinates. If the question asks for the point halfway between, use the Midpoint Formula; if it asks how steep the segment is, use slope. If the legs of a right triangle are already given as lengths, use the Pythagorean theorem directly.

Tip. Ask: Do I have two points' coordinates and need the length of the segment joining them?

How to Recognize It

Before reaching for the distance formula, decide what kind of answer you need: one length, a location, a steepness, or a side of a triangle whose legs you already know.

  1. Will your final answer be one non-negative number in length units, not an ordered pair?

    If yes, the distance formula fits. If the answer should be a location such as (3,−1), you want the Midpoint Formula, which averages the coordinates instead of squaring their differences.

  2. Do the two points share an x-coordinate or a y-coordinate?

    If yes, the segment is vertical or horizontal, and its length is the absolute difference of the other coordinates: (2,1) to (2,7) is 6. The formula still works, but one squared term is zero.

  3. Are the two legs already given as lengths, with no coordinates at all?

    If yes, skip coordinates and use the Pythagorean theorem directly: legs 6 and 8 give 10. The distance formula is that same theorem with the legs read off as ∣x2−x1∣ and ∣y2−y1∣.

  4. Does the question care how steep the segment is or which way it tilts?

    If yes, use slope, y2−y1x2−x1, which divides the same two differences instead of squaring and adding them. A slope can be negative; a distance never is.

Distance Formula compared with Midpoint formula, Slope, and Pythagorean theorem

Distance, midpoint and slope all start from the same two coordinate differences, and the Pythagorean theorem sits underneath the distance formula. What separates them is what you do with those differences: square and add for a length, average for a point, divide for steepness.

Distance Formula

Meaning
Use this when you have two coordinate points and need the straight-line length between them.
Key test
Do I have two points' coordinates and need the length of the segment joining them?
Formula
d=(x2−x1)2+(y2−y1)2
Example
Find the distance between (1,2) and (4,6).

Midpoint formula

Meaning
Finds the halfway point by averaging, not the length.
Key test
Use when you need the point in the middle, not the distance.
Formula
M=(x1+x22,y1+y22)
Example
The center of a segment from (0,0) to (4,6)

Slope

Meaning
Gives the steepness (a ratio), not the length between points.
Key test
Use when you need direction or rate, not distance.
Formula
m=y2−y1x2−x1
Example
How steep the line through two points is

Pythagorean theorem

Meaning
The underlying right-triangle relation, used when legs are given directly.
Key test
Use when you already have leg lengths, not coordinates.
Formula
a2+b2=c2
Example
A ladder's reach from base and wall height

Formula & Notation

d=(x2−x1)2+(y2−y1)2
d(P1,P2)=(x2−x1)2+(y2−y1)2 in R2; generalization: d(P,Q)=∑i=1n(qi−pi)2 in Rn; derived from the Pythagorean theorem

How to read it: d for distance; (x1,y1) and (x2,y2) are the two points

Worked Examples

Example 1 — Distance between two points

Easy

Find the distance between (1,2) and (4,6).
Show the steps and the answer
  1. Find the gaps: x2−x1=4−1=3 and y2−y1=6−2=4.

    These are the horizontal and vertical legs of a right triangle whose hypotenuse joins the two points.

  2. Square and add: 32+42=9+16=25.

    The Pythagorean theorem adds the squares of the legs.

  3. Take the square root: d=25=5.

    The root undoes the squaring and returns a length.

Answer: 5

Takeaway: Gaps, squares, sum, root: gaps of 3 and 4 give a distance of 5.

Example 2 — Midpoint instead

Standard

For the same points (1,2) and (4,6), find the MIDPOINT.
Show the steps and the answer
  1. Notice what is asked: a point halfway along the segment, not a length.

    A location has two coordinates, so the answer must be an ordered pair, not a single number like 5.

  2. Average the x-coordinates, 1+42=2.5, and the y-coordinates, 2+62=4.

    Halfway in each direction is the average of the endpoints, so the coordinates are added, not subtracted.

  3. Check with the distance formula: from (1,2) to (2.5,4) the gaps are 1.5 and 2, so the distance is 2.25+4=2.5, half of 5.

    The midpoint is half the full distance from each end.

Answer: (1+42,2+62)=(2.5,4)

Takeaway: The distance formula subtracts and squares to find how far; the midpoint formula adds and halves to find where.

Example 3 — Find the mistake: adding before squaring

Application

Find the distance between P(−2,5) and Q(4,−3). Zoe writes: "d=(4−(−2))+(−3−5)=6+(−8)=−2, so there is no distance." Find the mistake and correct it.
Show the steps and the answer
  1. Spot the warning sign: a distance can never be the square root of a negative number.

    Any two real points are some distance apart, and that distance is never negative.

  2. Find the gaps: 4−(−2)=6 and −3−5=−8.

    Zoe's gaps were right; the error is in what she did with them.

  3. Square each gap before adding: 62+(−8)2=36+64=100.

    Squaring makes both legs positive; the −8 only says that Q is below P.

  4. Take the root: d=100=10.

    Check: legs of 6 and 8 make a 6-8-10 right triangle, double the 3-4-5 one.

Answer: d=10

Takeaway: Square each gap, then add, then take the root; the squares remove the signs, so a distance is never negative.

Where You'll See It

  • How far away is the drone

    A drone launches from (0,0) and hovers at (120,50) on a grid in metres. Its straight-line distance from the pilot is 1202+502=16900=130 m, the number that matters for staying within the controller's range.

  • Blast radius in a video game

    A game checks whether a player at (3,4) is inside an explosion of radius 6 centred at (7,1). The distance is 42+32=5, less than 6, so the player is hit. Games often compare d2=25 with 62=36 to skip the square root.

Common Mistakes

  1. The slip: Forgetting to square the differences before adding

    Instead: you must square each coordinate gap, then add, then root.

  2. The slip: Adding before squaring (taking (x2−x1)+(y2−y1))

    Instead: square first, sum the squares, then take the root.

  3. The slip: Mixing coordinates

    Instead: subtract x from x and y from y; the order within each pair does not matter because the differences are squared.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. Find the distance between (−3,4) and (2,−8).

    Hint: Find the change in x and the change in y, square both, add, then take the root.

  2. Find the exact distance between (1,1) and (4,7).

    Hint: The answer may not be a whole number. Simplify the square root.

  3. Triangle A(0,0), B(6,0), C(3,4). Find all three side lengths. What kind of triangle is it?

    Hint: Use the distance formula for AC and BC; AB lies on the x-axis.

  4. The distance between (1,k) and (4,2) is 5. Find every possible value of k.

    Hint: Write the distance formula, square both sides, and solve.

  5. A drone flies in a straight line from (2,3) to (10,9), in metres. You want to know how far it flies. Distance formula or midpoint formula?

    Hint: Do you need a length or a location?

  6. For (1,2) and (7,10), Tia writes, "d=6+8=14." Correct her work.

    Hint: What must happen to each difference before you add?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

How is the distance formula connected to the equation of a circle?

A circle is every point at the same distance rr from its center (h,k)(h, k). Write the distance formula from the center to a moving point (x,y)(x, y), set it equal to rr, and square both sides: (x−h)2+(y−k)2=r2(x-h)^2 + (y-k)^2 = r^2. That is the standard equation of a circle, so the circle equation is the distance formula written for every point at once.

Does the distance formula work in three dimensions?

Yes, with a third squared difference: d=(x2−x1)2+(y2−y1)2+(z2−z1)2d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}. It comes from using the Pythagorean theorem twice, first across the floor of a box and then up its height. A box 2 by 3 by 6 has a corner-to-corner diagonal of 4+9+36=49=7\sqrt{4 + 9 + 36} = \sqrt{49} = 7. GPS and 3-D games use this version.

What should I do when the answer is a square root that does not come out whole?

Most distances are irrational: from (0,0)(0, 0) to (1,1)(1, 1) is 2≈1.414\sqrt{2} \approx 1.414. Unless the question asks for a decimal, give the exact value in simplest radical form, such as 50=52\sqrt{50} = 5\sqrt{2}, because a rounded decimal is only close. Exact forms also make comparisons easy: two sides of 50\sqrt{50} are exactly equal, which matters in proofs.

Learning Path

You need the Pythagorean Theorem, the Coordinate Plane and Square Roots first. The distance formula adds a way to read the legs of a right triangle straight from coordinates. Next, the Midpoint Formula finds the center of the same segment, Coordinate Proofs use distances to show that sides are equal, and the Equation of a Circle is the distance formula with the distance fixed at the radius.

See Also