Distance Formula Calculator

Two Points

P₁ = (1, 2) → P₂ = (4, 6)
Point 1
Point 2

2D distance

Answer

Distance
5
Midpoint
(2.5, 4)
Slope (Δy/Δx)
1.3333
Δx
3
Δy
4
Coordinate grid
P₁P₂

Show your work

Given
  • P₁ = (1, 2), P₂ = (4, 6)mode = 2D
  1. Distance — √(sum of squared deltas)
    d = √((3)² + (4)²)
    = √25 = 5
  2. Midpoint — average each coordinate
    M = ((1 + 4)/2, (2 + 6)/2)
    = (2.5, 4)
  3. Slope — Δy / Δx
    m = 4 / 3
    = 1.3333
Answer
distance = 5
d = 5, M = (2.5, 4), m = 1.3333

The distance and midpoint formulas

For any two points in the plane:

Distance: d = √((x₂ − x₁)² + (y₂ − y₁)²)
Midpoint: M = ((x₁ + x₂)/2, (y₁ + y₂)/2)
Slope: m = (y₂ − y₁) / (x₂ − x₁)

In 3D, add the z-term to distance and midpoint:d = √((Δx)² + (Δy)² + (Δz)²), M = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2). Slope isn't defined in 3D — use direction vectors instead.

Where the distance formula comes from

The 2D distance formula is the Pythagorean theorem applied to a right triangle whose legs are Δx and Δy. Think of a right triangle with one leg horizontal (Δx long) and one vertical (Δy long) — the hypotenuse is the straight line from P₁ to P₂, and by a² + b² = c²: d² = (Δx)² + (Δy)², so d = √((Δx)² + (Δy)²). The 3D formula extends this to three dimensions by including Δz.

When slope is undefined

If x₁ = x₂ (a vertical line), the slope formula divides by zero. Geometrically, a vertical line has infinite slope, and mathematically slope is simply undefined. This calculator reports “undefined (vertical line)” instead of returning an error or NaN — so you can distinguish it from zero-slope (horizontal) lines.

Practical uses

Common mistakes to avoid