Distance Formula Calculator with Steps

Find the distance between two points in 2D or 3D. See every step, the graph, the midpoint and the slope. Then practise with a free 3-level PDF.

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

Enter two points

Point A

Point B

Try:

Step-by-step solution

  1. 1Write the formula: d = √[(x₂ − x₁)² + (y₂ − y₁)²]
  2. 2Substitute: d = √[(4 − 1)² + (6 − 2)²]
  3. 3Subtract: d = √[3² + 4²]
  4. 4Square: d = √[9 + 16]
  5. 5Add: d = √25
  6. 6Take the root: d = 5

Midpoint of AB

M = (2.5, 4)

Slope of AB

m = 1.333333

-112345123456A (1, 2)B (4, 6)

Orange: the distance AB. Dashed teal: the horizontal and vertical legs of the right triangle. Their lengths are |x₂ − x₁| and |y₂ − y₁|.

Distance Formula Practice Pack: free 3-level PDF with answers

Free Distance Formula Practice Pack (PDF)

Six pages, from simple to complex. Level 1 covers the basics (Classes 8 and 9). Level 2 uses distances to prove things, such as right triangles, collinear points and squares (Classes 9 and 10). Level 3 is the challenge: equidistant points, 3D and more (Classes 10 to 12). It includes worked examples, a full answer key and a one-page poster.

Print the poster and pin it on your classroom noticeboard. Students can scan its QR code to check any answer with this calculator.

Download the PDF Poster only (1 page)

What is the distance formula?

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

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

It is the Pythagorean theorem in disguise. The horizontal gap is x₂ − x₁, the vertical gap is y₂ − y₁, and the distance is the hypotenuse of the right triangle they form.

Distance formula diagram: d = √((x₂ − x₁)² + (y₂ − y₁)²) shown on a coordinate grid with a worked example

How to use it: 3 steps

1

Subtract

Find x₂ − x₁ and y₂ − y₁.

2

Square and add

Square each difference, then add the two results.

3

Take the square root

The root of the sum is the distance.

Worked examples, from simple to complex

Try each one in the calculator above to check the steps.

Level 1 · Basic

Distance between (1, 2) and (4, 6)

x₂ − x₁ = 3 and y₂ − y₁ = 4

d = √(3² + 4²) = √(9 + 16) = √25 = 5

Level 1 · Negative coordinates

Distance between (−3, 2) and (2, −1)

x₂ − x₁ = 2 − (−3) = 5 and y₂ − y₁ = −1 − 2 = −3

d = √(25 + 9) = √34, about 5.83 units

Level 1 · Shortcut

Distance between (2, 5) and (9, 5)

The y-values are equal, so the points lie on a horizontal line.

d = |9 − 2| = 7. No square root needed.

Level 2 · Prove it

Is the triangle A(0, 0), B(3, 0), C(0, 4) right-angled?

AB = 3, AC = 4, BC = √(3² + 4²) = 5

3² + 4² = 25 = 5², so yes, the right angle is at A.

Level 2 · Word problem

School at (2, 3), park at (8, 11), 1 unit = 100 m

d = √(6² + 8²) = √100 = 10 units

10 × 100 m = 1000 m (1 km)

Level 2 · Find the unknown

Distance between (x, 2) and (3, −2) is 5. Find x.

(x − 3)² + 4² = 25, so (x − 3)² = 9

x − 3 = 3 or x − 3 = −3, so x = 6 or x = 0

Level 3 · Challenge

Point on the x-axis equidistant from A(2, −5) and B(−2, 9)

Let P = (x, 0). Then PA² = PB²:

(x − 2)² + 25 = (x + 2)² + 81

−8x = 56, so x = −7. The point is (−7, 0).

Level 3 · In 3D

Distance between (1, 2, 3) and (4, 6, 15)

d = √(3² + 4² + 12²) = √(9 + 16 + 144) = √169 = 13

Tick the 3D box in the calculator to check it.

What the distance formula is used for

  • Right triangles. Check whether three points form a right triangle by testing Pythagoras on the three side lengths.
  • Isosceles and equilateral triangles. Compare the three side lengths to classify a triangle.
  • Squares, rhombuses and rectangles. Check the sides and the diagonals of a quadrilateral.
  • Collinear points. Three points are collinear if the two shorter distances add up to the longest one.
  • Circles. A point is on a circle if its distance from the centre equals the radius.
  • Maps and games. Find the straight-line distance between two locations on a grid.

Keep going

Frequently asked questions

What is the distance formula?

The distance between two points (x₁, y₁) and (x₂, y₂) is d = √[(x₂ − x₁)² + (y₂ − y₁)²]. It gives the length of the straight line joining the two points.

Where does the distance formula come from?

It comes from the Pythagorean theorem. Draw a horizontal and a vertical line from the two points to form a right triangle. The legs have lengths |x₂ − x₁| and |y₂ − y₁|, and the distance is the hypotenuse.

Does the order of the points matter?

No. Swapping the points changes the signs of (x₂ − x₁) and (y₂ − y₁), but squaring removes the signs, so the distance is the same.

Can a distance be negative?

No. The square root of a sum of squares is never negative, so the distance is zero or positive. It is zero only when the two points are the same.

How do I find the distance from the origin?

Use (0, 0) as one point. The formula becomes d = √(x² + y²). For example, the distance of (5, 12) from the origin is √(25 + 144) = 13.

What is the shortcut for points on a horizontal or vertical line?

If the y-values are equal, d = |x₂ − x₁|. If the x-values are equal, d = |y₂ − y₁|. No square root is needed.

What is the distance formula in 3D?

Add the difference in z: d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. Tick the 3D box in the calculator above to try it.

What is the difference between the distance formula and the midpoint formula?

The distance formula gives the length of the segment between two points. The midpoint formula gives the point exactly halfway: M = ((x₁ + x₂)/2, (y₁ + y₂)/2).

Which classes study the distance formula?

It is part of coordinate geometry in the school syllabus, usually studied around Classes 9 and 10 and used again in Classes 11 and 12. Check your own textbook or board for the exact chapter.