Distance Between Two Points: Formula Derivation and Examples

#Distance Between Two Points
TL;DR
The distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}. It is Pythagoras: the horizontal and vertical gaps are the legs of a right triangle, and the distance is its hypotenuse.
Ashish Chauhan·reviewed byShikha SharmaLast updated on December 2, 202612 min read

Key Points

  • Formula: d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}, the length of the segment joining the points.
  • Square each gap, add, then take the square root, in that order.
  • In 3D, add a third squared gap: (x2−x1)2+(y2−y1)2+(z2−z1)2\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}.
  • Both axes must measure the same thing in the same unit.

How Does a Map App Know How Far Apart Two Pins Are?

A map app knows how far apart two pins are before it plans a single turn of the route. Behind the pins is a coordinate grid and one calculation, the distance formula, that turns two pairs of numbers into an "as the crow flies" distance.

  • Take A(−3,−3)A(-3, -3) and B(1,0)B(1, 0). Counting squares gives 4 across and 3 up.
  • But the straight path runs diagonally, and diagonals cannot be counted square by square.
  • The 4 and 3 are the short sides of a right triangle; the straight line from AA to BB is the long side.
  • The Pythagorean theorem gives 42+32=5\sqrt{4^2 + 3^2} = 5: the distance between two points is Pythagoras on a grid.
the distance between two points is the hypotenuse of the run-and-rise triangle
A(−3, −3) and B(1, 0) on a grid joined by an orange hypotenuse, with a blue run x₂ − x₁ = 1 − (−3) = 4 and a green rise y₂ − y₁ = 0 − (−3) = 3 forming a right triangle, so d = 5.

What Is the Distance Formula?

The distance between two points is the length of the straight segment joining them, and the distance formula works it out from their coordinates. For A(x1,y1)A(x_1, y_1) and B(x2,y2)B(x_2, y_2):

d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
  • x2−x1x_2 - x_1 is the run (how far across) and y2−y1y_2 - y_1 is the rise (how far up).
  • Subtract, square each gap, add, then take the positive square root; dd is never negative.

For the running pair, d=(1−(−3))2+(0−(−3))2=16+9=5d = \sqrt{(1 - (-3))^2 + (0 - (-3))^2} = \sqrt{16 + 9} = 5, in the same unit as the axes.

How Is the Distance Formula Derived?

The formula falls straight out of a right triangle.

The right triangle

  • From AA, move straight across to the corner K(x2,y1)K(x_2, y_1), then straight up to BB.
  • The moves meet at a right angle, so AKBAKB is a right triangle with hypotenuse ABAB.
  • Its legs are ∣x2−x1∣|x_2 - x_1| and ∣y2−y1∣|y_2 - y_1|. Pythagoras gives:
AB2=(x2−x1)2+(y2−y1)2AB^2 = (x_2 - x_1)^2 + (y_2 - y_1)^2
  • Take the positive root, since a length cannot be negative.

The squares on the sides

  • Pythagoras is about areas. Build a square on each side of the triangle.
  • The run's square is 4×4=164 \times 4 = 16 units, the rise's is 3×3=93 \times 3 = 9, and the tilted square on ABAB covers 2525.
  • So AB=25=5AB = \sqrt{25} = 5. Euclid proved this as Book I, Proposition 47 of the Elements.
the squares on the run and the rise add up to the square on the distance
The right triangle from A(−3, −3) to B(1, 0) with a blue square of 16 on the run, a green square of 9 on the rise, and a tilted orange square of 25 on AB.

Why the order of the points never matters

  • Swapping the points flips each gap's sign, but a number and its negative have the same square.

  • So the distance from AA to BB equals the distance from BB to AA.

  • Drag A(−3,−3)A(-3, -3) and B(1,0)B(1, 0): the run, rise and distance update live.

  • Press "Show me: squares on the sides" to see the 16, 9 and 25 squares.

  • Try "Horizontal" and "Vertical": one gap becomes 0.

Try It Yourself

In the tool above:

How Do You Extend It to Three Dimensions?

A point in 3D has three coordinates, so the formula grows by one squared term. Use Pythagoras twice: across the floor, then up the height.

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}
  • Each axis of the Cartesian coordinate system is at right angles to the others, so each adds its own squared gap.
  • The pattern continues for any number of coordinates, which data scientists call Euclidean distance.

Edge Cases Worth Knowing

The formula works for every pair of points, and a few cases need almost no working.

  • Same yy (horizontal segment): d=∣x2−x1∣d = |x_2 - x_1|. From (−3,5)(-3, 5) to (2,5)(2, 5), d=5d = 5.
  • Same xx (vertical segment): d=∣y2−y1∣d = |y_2 - y_1|.
  • The same point twice: d=0d = 0, the only way to get 0.
  • From the origin: d=x2+y2d = \sqrt{x^2 + y^2}.
  • Axes in different units: on a graph of kilometres against hours, the formula mixes units and means nothing.

Connections: Circles and Collinear Points

The distance formula holds up other topics.

  • A circle is every point at distance rr from a centre (h,k)(h, k). Square the distance formula to get the equation of a circle: (x−h)2+(y−k)2=r2(x - h)^2 + (y - k)^2 = r^2.
  • Every point on x2+y2=25x^2 + y^2 = 25 is 5 from the origin, such as (3,4)(3, 4) and (−4,−3)(-4, -3).
a circle is every point at the same distance from its centre
The circle x² + y² = 25 with the 12 whole-number points on it marked, including (3, 4) and (−4, −3), each joined to the origin by a radius of 5.
  • Three points are collinear exactly when the two shorter distances add up to the longest.
  • For example, A(1,1)A(1, 1), B(3,2)B(3, 2), C(7,4)C(7, 4) give 5+25=35\sqrt{5} + 2\sqrt{5} = 3\sqrt{5}: collinear.
  • Otherwise they form a triangle, and the longest side is shorter than the other two together: the triangle inequality.

Examples of Distance Between Two Points

The examples move from negatives to 3D, shape questions and a word problem.

Example 1

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

  1. A quick attempt, 2−3=−12 - 3 = -1, gives d=1d = 1. But the points sit 3 left and 2 right of the yy-axis, so they are 5 apart.
  2. Done carefully: 2−(−3)=52 - (-3) = 5 and 5−5=05 - 5 = 0.
  3. d=25+0=5d = \sqrt{25 + 0} = 5.

The distance is 5 units, the horizontal gap.

Example 2

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

  1. 3−(−2)=53 - (-2) = 5 and 4−(−1)=54 - (-1) = 5.
  2. d=25+25=50=52d = \sqrt{25 + 25} = \sqrt{50} = 5\sqrt{2}.

The distance is 525\sqrt{2}, about 7.07 units.

subtracting a negative coordinate adds, giving gaps of 5 and 5
From (−2, −1) to (3, 4): a blue run of 3 − (−2) = 5, a green rise of 4 − (−1) = 5, and the orange distance 5√2 ≈ 7.07.

Example 3

A point (x, 0) on the x-axis is 10 units from (6, 8). Find x.

  1. Square both sides: (x−6)2+(0−8)2=100(x - 6)^2 + (0 - 8)^2 = 100.
  2. So (x−6)2=36(x - 6)^2 = 36 and x−6=±6x - 6 = \pm 6.

So x=12x = 12 or x=0x = 0: a circle of radius 10 around (6,8)(6, 8) crosses the xx-axis twice.

two points on the x-axis are each 10 units from (6, 8)
A dashed circle of radius 10 centred at (6, 8) crossing the x-axis at (0, 0) and (12, 0), with both 10-unit radii drawn and the 8-unit height marked.

Example 4

Find the distance between the points (1, 2, 3) and (3, 5, 9) in space.

  1. The gaps are 2, 3 and 6.
  2. d=4+9+36=49=7d = \sqrt{4 + 9 + 36} = \sqrt{49} = 7, the long diagonal of a 2×3×62 \times 3 \times 6 box.

The distance is 7 units.

in 3D the distance is the diagonal of a box, using a third squared gap
A 2 × 3 × 6 box with the orange space diagonal d = 7 from (1, 2, 3) to (3, 5, 9) and the green floor diagonal √13 underneath it.

Example 5

What kind of triangle has corners (1, 1), (4, 5) and (8, 2)?

  1. The sides are 32+42=5\sqrt{3^2 + 4^2} = 5, 42+32=5\sqrt{4^2 + 3^2} = 5 and 72+12=50\sqrt{7^2 + 1^2} = \sqrt{50}.
  2. Two sides are equal, and 52+52=505^2 + 5^2 = 50, so the converse of Pythagoras gives a right angle.

It is a right-angled isosceles triangle.

Example 6

Two drones sit at grid positions (2, 3) and (14, 8), where each grid unit is 100 m. How far apart are they in metres?

  1. In grid units: d=122+52=169=13d = \sqrt{12^2 + 5^2} = \sqrt{169} = 13.
  2. Convert: 13×100=130013 \times 100 = 1300 m.

The drones are 1300 m apart.

What Are the Most Common Mistakes With the Distance Formula?

Nearly every wrong answer traces back to one of three habits.

Mistake 1: Dropping a negative sign

Where it slips in: Any negative coordinate, especially when it is subtracted.

Don't do this: Write 2−(−3)=−12 - (-3) = -1, as in the first attempt in Example 1.

The correct way: Put negatives in brackets: 2−(−3)=2+3=52 - (-3) = 2 + 3 = 5.

Mistake 2: Adding the gaps instead of their squares

Where it slips in: Recalling the formula as "the square root of the differences".

Don't do this: Write 4+3=7\sqrt{4 + 3} = \sqrt{7}, or 4+3=74 + 3 = 7, for the running pair.

The correct way: Square first, then add: 16+9=5\sqrt{16 + 9} = 5. A square root does not split over addition, and adding the gaps gives the longer walk along grid lines.

Mistake 3: Stopping before the square root

Where it slips in: The last line, once the sum looks finished.

Don't do this: Report d=25d = 25 for the running pair.

The correct way: 25 is d2d^2, an area, so d=5d = 5. The distance can never beat the run plus the rise, and 25 is far bigger than 4+34 + 3.

Why Does the Distance Formula Matter?

"Off by a unit, off by a spacecraft."

Wherever positions are stored as numbers, this formula turns them into "how far".

  • Maps. "As the crow flies" distances on a local map use it; over very long distances the Earth's curve needs another formula.
  • Games. Two round objects touch when their centres are at most the sum of their radii apart.
  • Robotics. A robot checks a target is within reach by comparing a distance with its arm's length.
two balls touch only when the distance between their centres is at most the sum of their radii
Two balls of radius 1.5 with centres (2, 2) and (5.6, 4.7): the centre distance is 4.5, more than the 3 they would need to touch, leaving a gap of 1.5.

Units matter at full scale. NASA lost the Mars Climate Orbiter in 1999 because ground software used English units and the spacecraft used metric; the probe passed too close to Mars and burned up.

Conclusion

  • The distance between two points is Pythagoras on the run and the rise: d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
  • Use brackets for negatives, square before adding, and finish with the square root.
  • One extra term gives 3D, and the formula sits inside every circle's equation.
  • Both axes must use the same unit, or the "distance" means nothing.

A Practical Next Step

Work these out, then check them in the tool by dragging AA and BB to the points.

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

Answer to Question 1: the gaps are 3 and 4, so d=5d = 5.

Answer to Question 2: the gaps are 8 and 6, so d=64+36=10d = \sqrt{64 + 36} = 10.

If one comes out wrong, check the subtraction of a negative first (Mistake 1). Next, try the midpoint of the same pairs.

To practise coordinate geometry with a teacher, explore Bhanzu's geometry tutor sessions, a middle school math tutor or structured math tutoring.

Want a live Bhanzu trainer to walk your child through the distance formula? Book a free demo class and see the right-triangle picture drawn live.

Read More

Research Behind This Article

  1. Euclid, Elements, Book I, Proposition 47 (the Pythagorean theorem), with commentary by D. E. Joyce, Clark University. mathcs.clarku.edu
  2. OpenStax, Intermediate Algebra 2e, Section 11.1: Distance and Midpoint Formulas; Circles. openstax.org
  3. OpenStax, Calculus Volume 3, Section 2.2: Vectors in Three Dimensions (the distance between two points in space). openstax.org
  4. NASA Science, Mars Climate Orbiter (mission loss in 1999 from English units not translated to metric). science.nasa.gov

Quick Quiz: Check Yourself

Three levels, questions with figures, instant feedback with the reason.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the formula for the distance between two points?
d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} for the points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2).
Can the distance between two points be negative?
No. The gaps are squared, so the number under the root is never negative, and the positive root is taken. It is 0 only for the same point.
Is the distance formula the shortest distance between two points?
Yes. It measures the straight segment, and every curved or stepped path is longer, as the triangle inequality makes precise.
✍️ Written By
Ashish Chauhan
Ashish Chauhan
Math Curriculum Developer
Ashish Chauhan is a Mathematics and Science educator and curriculum developer with 6+ years of experience teaching students from Grades 3–12. He specializes in simplifying complex concepts through conceptual, student-centered learning and has worked across CBSE, PSEB, and international curricula. Beyond teaching, Ashish develops K–12 educational content, lesson plans, and assessments aligned with US learning standards. He holds a BS in PCM and an MS in Chemistry, bringing a strong STEM foundation to education and curriculum design.
🔬 Reviewed By
Shikha Sharma
Subject Matter Expert
Book a FREE Demo ClassBook Now →