Distance Calculator

The distance between two points is the Pythagorean theorem applied to the differences in their coordinates.

Also called: Distance formula calculator · Two-point distance calculator

  • Last updated
  • Formula tested against reference values

Your numbers

Space

Result

Distance
—

Calculating…

Midpoint
—
Slope (2D)
—
Δx
—
Δy
—
Δz
—
Distance squared
—

How to use this calculator

  1. Enter or choose space.
  2. Enter or choose point 1: x₁.
  3. Enter or choose point 1: y₁.
  4. Enter or choose point 2: x₂.
  5. Enter or choose point 2: y₂.
  6. The distance updates as you type. Use Copy result or Share to keep it.

Method

d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²); midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2, …); slope = Δy ÷ Δx

(x₁, y₁, z₁)
the first point
(x₂, y₂, z₂)
the second point (z is 0 in 2D)

Worked example

  1. Δx = 4 − 1 = 3 and Δy = 6 − 2 = 4.
  2. d = √(3² + 4²) = √25 = 5.
  3. Midpoint = ((1 + 4)/2, (2 + 6)/2) = (2.5, 4).

The points (1, 2) and (4, 6) are 5 units apart, with midpoint (2.5, 4).

What the result means

The answer is in the same units as the coordinates. For points given as latitude and longitude, this flat-plane formula is wrong over any real distance; use a great-circle (haversine) method instead.

Assumptions and limits

  • Coordinates are Cartesian and use the same unit on every axis.
  • Not for latitude and longitude: the Earth is curved.

Questions

Is the distance formula the same as Pythagoras?

Yes. Δx and Δy are the legs of a right triangle and the distance is its hypotenuse; in 3D the theorem is applied twice.

Why is the slope undefined?

When both points have the same x, the line is vertical and Δy ÷ Δx would divide by zero.