StringMash.com

Distance formula calculator

Two points in, the distance between them out, exact and as a decimal.

17 characters
Updates as you type
Distance3√5 ≈ 6.7082
Decimal6.708204
d²45
Change in x3
Change in y6
Midpoint(5/2, 5) = (2.5, 5)
Slope2
Equation of the liney = 2x
The working and the triangle are below

Show the steps
xy112233445566778899036AB
  1. The distance formula is d = √((x₂ − x₁)² + (y₂ − y₁)²). It's Pythagoras: the line from A to B is the long side of a right triangle whose other sides run across and up.
  2. x₂ − x₁ = 4 − 1 = 3. y₂ − y₁ = 8 − 2 = 6.
  3. d = √(3² + 6²) = √(9 + 36) = √45.
  4. The biggest square that divides 45 is 9 = 3², so √45 = √(9 × 5) = 3√5.
  5. As a decimal, d ≈ 6.708204.

Using the calculator

Type two points, such as (1, 2) and (4, 8). Brackets and names are optional, and coordinates can be whole numbers, decimals, fractions like 3/4 or mixed numbers like 1 1/2. The distance appears as you type.

The answer is exact where it can be, in simplest radical form such as 3√5, with the decimal beside it. Below are the steps, the squared distance, the change in x and y, the midpoint, the slope and the equation of the line through both points.

The graph draws the segment from A to B with the right triangle under it: one leg across, one leg up, each labelled with its length. It scales to fit, so points like (−120, 40) and (300, 75) fit on it too. Type six numbers for two points in 3D; those get the working but no graph.

The distance formula

The distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). Find how far apart the points are across and up, square both, add, and take the square root.

For (1, 2) and (4, 8): across is 4 − 1 = 3 and up is 8 − 2 = 6. Then d = √(3² + 6²) = √(9 + 36) = √45. The biggest square that divides 45 is 9, so √45 = √(9 × 5) = 3√5, about 6.708.

It doesn't matter which point comes first. Swapping them flips the signs of the differences, and squaring removes the signs again.

Why it's Pythagoras

Draw a line across from A and a line up from B and they meet at a right angle. The segment AB is the long side of that right triangle, the hypotenuse. Its legs are the change in x and the change in y, so a² + b² = c² gives the distance. That's the triangle on the graph.

The US Common Core puts this in grade 8, as standard 8.G.B.8: apply the Pythagorean theorem to find the distance between two points in a coordinate system. In high school geometry, standard G-GPE.B.7 uses it to find the perimeters of shapes drawn on a grid.

For that reason the formula is sometimes called Pythagorean distance. Its proper name is Euclidean distance. Alexis Clairaut published the formula in 1731, almost a century after Descartes brought in coordinates in 1637.

Distance in 3D

In three dimensions the formula gains a z term: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). It's Pythagoras twice, once across the floor and once up to the point. From (1, 2, 3) to (3, 5, 9) the differences are 2, 3 and 6, and √(4 + 9 + 36) = √49 = 7.

Questions

What is simplest radical form?

A square root with every square factor taken out, so √45 becomes 3√5 and √50 becomes 5√2. The number left under the root has no square factors other than 1.

Why are the differences squared?

They're the legs of a right triangle, and Pythagoras adds their squares. Squaring also makes a negative difference positive, so the order of the points doesn't matter.

When is the answer a whole number?

When the squares add to a perfect square. The legs then form a Pythagorean triple, like 3, 4, 5 or 5, 12, 13: from (0, 0) to (3, 4) is 5.

Can it find the distance between two places?

No. This is straight-line distance on a flat grid. Distance between towns needs the Earth's curve and map data, and nothing you type here is sent anywhere.

Sources

Added . Last updated and reviewed . What's new