Distance & Midpoint Calculator

Distance, midpoint and slope between two points in 2D or 3D, with the horizontal and vertical changes.

Results

Distance
5
Midpoint
(2.5, 4)
Slope (Δy ÷ Δx)
1.3333
Δx (x₂ − x₁)
3
Δy (y₂ − y₁)
4

How it’s calculated

The distance between two points is the length of the straight line joining them. It comes from the Pythagorean theorem applied to the horizontal change Δx and the vertical change Δy. The midpoint is the point exactly halfway between them: the average of each pair of coordinates. The slope is the rise over the run.

distance = √( (x₂ − x₁)² + (y₂ − y₁)² ) (3D: add + (z₂ − z₁)²) midpoint = ( (x₁ + x₂) ÷ 2 , (y₁ + y₂) ÷ 2 ) (3D: add (z₁ + z₂) ÷ 2) slope = (y₂ − y₁) ÷ (x₂ − x₁) (undefined when x₁ = x₂, a vertical line)

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

Frequently asked questions

Does the order of the points matter?

Not for the distance or the midpoint. Swapping the points flips the signs of Δx and Δy, but the slope stays the same.

Why is the slope “undefined”?

When both points have the same x value the line is vertical and the run is 0, so rise ÷ run would divide by zero. A vertical line has no slope value.

How do I find the distance in 3D?

Choose 3D and enter z for both points. The formula simply adds (z₂ − z₁)² under the square root.

What units is the distance in?

The same unit as your coordinates. If the coordinates are meters, the distance is in meters.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator