Math Formulas

Distance Formula in Maths: Derivation and Worked Examples

Calculate the distance between two points with the coordinate formula, a Pythagorean derivation and five worked examples.

TL;DR

The distance formula is d = √[(x₂ − x₁)² + (y₂ − y₁)²]. It gives the straight-line distance between two points in a coordinate plane.

Key Points

  • Coordinate differences are the horizontal and vertical legs of a right triangle.
  • Squaring each difference makes the result independent of which point is named first.
  • Use the square root at the end to express distance in the original units.

Why does the distance formula work?

From (x₁, y₁), move horizontally to (x₂, y₁), then vertically to (x₂, y₂). The leg lengths are |x₂ − x₁| and |y₂ − y₁|. The distance is the hypotenuse. The Pythagorean theorem gives the sum of the squares before you take the nonnegative square root. This assumes both axes use the same units and the usual perpendicular coordinate grid. OpenStax — College Algebra 2e: Key Equations for Functions

Worked examples

A basic pair

A(1, 2) and B(4, 6) differ by 3 and 4. The distance is √(9 + 16) = 5 units.

Crossing both axes

From (−2, −1) to (1, 3), the differences are 3 and 4. Crossing an axis changes the subtraction step, while the distance is still 5.

A wrong turn with negative coordinates

Between (−3, 2) and (1, −1), a learner may write 1 − 3. Subtract the entire negative coordinate: 1 − (−3) = 4 and −1 − 2 = −3. The distance is 5.

A vertical segment

From (5, 2) to (5, −4), horizontal change is zero. The distance is √36 = 6.

Exact and approximate distance

Between (0, 0) and (2, 3), the distance is √13, about 3.61. Keep the radical if no rounding is requested.

How can you use the distance formula to find a missing coordinate?

Suppose A is (1, 2) and B is (x, 6), and the distance is 5 units. The vertical change is 4. Square both sides to get (x − 1)² + 16 = 25, so (x − 1)² = 9. The horizontal difference can be 3 or −3. Both x = 4 and x = −2 are possible. Draw a horizontal line at y = 6 to see why there can be two endpoints. They sit at the same distance on either side of x = 1.

If the target distance were 3 units, there would be no real x because the vertical change alone is 4. That check can save you from solving an impossible equation. Use the same argument to see why the straight-line distance can never be smaller than either absolute coordinate difference.

Straight-line distance versus distance along a route

A route that goes three blocks east and four blocks north is seven blocks long when you can only travel along the grid. The straight segment is five units long when blocks in both directions are the same size. Choose the distance formula if the question asks how far apart two points are in a straight line. Use the distances of the actual segments if it asks how far a vehicle, runner, or robot travelled. Pythagoras theorem and the right-triangle check

Practice problem

Two points are (−4, 1) and (2, 9). How far apart are they, and why can the result not be smaller than 8?

Solution. The differences are 6 and 8. Compute √(36 + 64) = 10. The vertical distance alone is 8, and adding a nonzero horizontal change makes the straight-line distance larger.

Frequently Asked Questions

When is distance zero?

Only when both coordinate differences are zero, so the two points coincide.

Conclusion

  • Subtract matching coordinates.
  • Square and add the two differences.
  • Take the square root and label the units.

Read More

Research Behind This Article

  1. OpenStax, College Algebra 2e: Key Equations for Functions. openstax.org
  2. OpenStax, Prealgebra 2e: Angles, Triangles and the Pythagorean Theorem. openstax.org