Distance Formula

Definitionnoun phrase

What is the distance formula in math?

The distance formula finds the straight-line length between two points on the coordinate plane: d = √(x2 − x1)2 + (y2 − y1)2. It is the Pythagorean theorem in disguise: the horizontal and vertical differences are the legs of a right triangle, and the distance is the hypotenuse.

In Spanish
fórmula de la distancia
Also called
distance between two points, Euclidean distance
Grade level
Geometry
Grade 8Algebra 1GeometryCCSS 8.G.B.8CCSS HSG-GPE.B.7SATACTGEDASVABACCUPLACERPSATHiSET

Distance Formula in a picture

The distance formula is the Pythagorean theorem on a gridPoints (1, 2) and (7, 7) on a coordinate grid are joined by a green segment d. A right triangle under it has a blue horizontal leg of 6 (x2 minus x1) and an orange vertical leg of 5 (y2 minus y1). The distance is the square root of 6 squared plus 5 squared, the square root of 61, about 7.81.(1, 2)(7, 7)x₂ − x₁ = 6y₂ − y₁ = 5dd = √(6² + 5²) = √61 ≈ 7.81
Draw the right triangle under any two points. The legs are the changes in x and y, and the distance is the hypotenuse.

Formal definition and notation

For points P1(x1, y1) and P2(x2, y2) in the coordinate plane, the distance between them is d = √(x2 − x1)2 + (y2 − y1)2. The result is never negative and does not depend on which point is called first, because squaring removes the sign of each difference.

Symbol Read it as Meaning
d(P, Q) or PQ the distance from P to Q the length of the segment joining the two points
(x1, y1) x sub 1, y sub 1 the first point; the subscripts only number the points

Key facts

  • Points on the same horizontal line: d = |x2 − x1|. Same vertical line: d = |y2 − y1|.
  • Order does not matter: (x1 − x2)2 = (x2 − x1)2.
  • Distance from the origin to (x, y) is √x2 + y2.
  • Pythagorean triples give whole-number distances: legs 3 and 4 give 5; legs 5 and 12 give 13.
  • The equation of a circle, (x − h)2 + (y − k)2 = r2, says every point is distance r from the center.

Distance formula

Distance formula
d = √(x2 − x1)2 + (y2 − y1)2
x2 − x1
horizontal change: one leg of the right triangle
y2 − y1
vertical change: the other leg
d
the distance: the hypotenuse

Square each difference before adding. √a2 + b2 is not a + b.

Try it: legs and hypotenuse

Interactive

Set the legs to the horizontal and vertical changes between two points. The hypotenuse is the distance between them.

This interactive needs JavaScript. The worked examples below show the same ideas step by step.

Distance Formula examples, step by step

Example 1: Whole-number distance

Warm-up

Find the distance between (2, 1) and (5, 5).

  1. x2 − x1 = 5 − 2 = 3; y2 − y1 = 5 − 1 = 4.
  2. d = √32 + 42 = √9 + 16 = √25.
  3. d = 5.

Answer: The distance is 5 units.

Example 2: Negative coordinates

Core

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

  1. x2 − x1 = 2 − (−4) = 6.
  2. y2 − y1 = −5 − 3 = −8.
  3. d = √62 + (−8)2 = √36 + 64 = √100.
  4. d = 10.

Answer: The distance is 10 units.

Example 3: Perimeter of a triangle

Test-style

A triangle has vertices A(0, 0), B(6, 0) and C(6, 8). What is its perimeter?

  1. AB = |6 − 0| = 6 (same horizontal line).
  2. BC = |8 − 0| = 8 (same vertical line).
  3. AC = √62 + 82 = √100 = 10.
  4. Perimeter: 6 + 8 + 10 = 24.

Answer: The perimeter is 24 units.

Common mistakes

✗ Mistaked = √32 + 42 = 3 + 4 = 7.
✓ Instead√9 + 16 = √25 = 5.

A square root does not split over addition. Add the squares first, then take one square root.

✗ MistakeFor (−1, 2) and (3, 2): x2 − x1 = 3 − 1 = 2.
✓ Instead3 − (−1) = 4, so the distance is 4.

Subtracting a negative adds. Write the parentheses: x2 minus (x1).

✗ MistakeMixing coordinates: (x2 − y1)2 + (y2 − x1)2.
✓ InsteadSubtract x from x and y from y: (x2 − x1)2 + (y2 − y1)2.

Each difference measures one direction. Crossing x and y values gives a meaningless number.

Not to be confused with

Distance Formulavs.Midpoint formula

The midpoint formula averages the coordinates and gives a point, such as (4, 4.5). The distance formula gives a length, a single number.

Distance Formulavs.Slope

Slope divides the changes: y2 − y1x2 − x1. Distance squares and adds them, then takes the square root.

Quick check: 3 questions

Question 1 of 3

What is the distance between (1, 1) and (4, 5)?

Show answer and explanation

Answer: B. √32 + 42 = √25 = 5. 7 adds the legs, 25 forgets the square root, and √7 adds the differences before squaring.

Question 2 of 3

How far is (−5, −12) from the origin?

Show answer and explanation

Answer: C. √(−5)2 + (−12)2 = √169 = 13. 17 adds the absolute values, 7 subtracts them, and 169 forgets the square root.

Question 3 of 3

The distance from (2, k) to (5, 1) is 5, and k > 1. What is k?

Show answer and explanation

Answer: A. 32 + (k − 1)2 = 25 gives (k − 1)2 = 16, so k − 1 = 4 and k = 5. −3 is the other solution, ruled out by k > 1; 4 is k − 1; 6 adds 5 to 1.

Distance Formula: frequently asked questions

How is the distance formula related to the Pythagorean theorem?

It is the same idea. Any two points form the ends of the hypotenuse of a right triangle whose legs are horizontal and vertical. The leg lengths are x2 − x1 and y2 − y1. The theorem a2 + b2 = c2 becomes d2 = (x2 − x1)2 + (y2 − y1)2, and taking the square root gives the formula.

Does it matter which point is first?

No. Swapping the points changes the sign of each difference, for example from 6 to −6, but squaring makes both 36. So d comes out the same. Choose the order that makes the subtraction easiest, and keep the same point first in both the x part and the y part.

What is the distance formula in 3D?

Add a third squared difference for the z-coordinates: d = √(x2 − x1)2 + (y2 − y1)2 + (z2 − z1)2. For (0, 0, 0) and (2, 3, 6), d = √4 + 9 + 36 = √49 = 7. The idea extends to any number of dimensions.

Practice and tools

Sources

  1. Common Core State Standards, Grade 8 Geometry
  2. Common Core State Standards, High School Geometry: Expressing Geometric Properties with Equations
  3. OpenStax, Intermediate Algebra 2e, 11.1 Distance and Midpoint Formulas; Circles

Updated November 2026·Reviewed by the Effortless Math team·Standards: CCSS 8.G.B.8, CCSS HSG-GPE.B.7

Cite this entry

Effortless Math Team. “Distance Formula.” Effortless Math Dictionary. Updated November 2026. https://www.effortlessmath.com/math-dictionary/distance-formula/

Flashcard

TermDistance Formulalength between two points
Definitiond = √(x2 − x1)2 + (y2 − y1)2. From (0, 0) to (3, 4): √25 = 5.
Study the full deck

Browse all terms in the Math Dictionary · More geometry terms · Random term