Distance Formula Calculator

Enter the coordinates of two points to get the distance, midpoint and slope.

Results

Distance (d)
5
Exact form
√25
Δx (horizontal change)
3
Δy (vertical change)
4
Midpoint
(2.5, 4)
Slope (m)
1.3333333

The distance between two points on a coordinate plane is Pythagoras’ theorem in action: the horizontal and vertical differences are the legs of a right triangle, and the distance is the hypotenuse.

The calculator gives the distance as a decimal and in exact (root) form, plus the midpoint and the slope of the line through the points. Enter z values as well and it returns the 3D distance.

How to calculate Distance formula

  1. Enter x₁ and y₁ for the first point.
  2. Enter x₂ and y₂ for the second point.
  3. Read the distance, midpoint and slope; add z values for three dimensions.

Distance formula formula

  • d = √((x₂ − x₁)² + (y₂ − y₁)²)
  • In 3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
  • Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
  • Slope m = (y₂ − y₁) ÷ (x₂ − x₁)

Distance formula example

Between (1, 2) and (4, 6): Δx = 3, Δy = 4, so d = √(9 + 16) = √25 = 5 units. The midpoint is (2.5, 4) and the slope 4 ÷ 3 = 1.33.

Distance formula: common questions

Can the distance be negative?

No. The differences are squared, so the result is always zero or positive, and the order of the points does not matter.

Why is the slope undefined?

If both points share the same x value the line is vertical; the denominator is zero, so the slope is undefined.

Can I use it for two cities on a map?

No. This formula is for a flat plane. For two places on Earth you need a great-circle (haversine) calculation from latitude and longitude.