Distance Formula Calculator
Enter two points to get the straight-line distance between them, the exact answer as a simplified square root, and the midpoint, in 2D or 3D.
How to use the distance calculator
Enter the coordinates of both points. Switch to 3D to add z-coordinates. The answer is shown as a decimal and as an exact simplified radical (such as 5√2), with every step of the formula.
This finds the straight-line distance between coordinates. For driving distance between places, use a map app.
The distance formula
d = √((x₂ − x₁)² + (y₂ − y₁)²)
It's the Pythagorean theorem: the horizontal and vertical gaps are the two legs of a right triangle, and the distance is the hypotenuse.
Example: (1, 2) to (6, 7). Δx = 5, Δy = 5. d = √(25 + 25) = √50 = 5√2 ≈ 7.071.
In three dimensions, add the z term: d = √(Δx² + Δy² + Δz²). From (0, 0, 0) to (1, 2, 2): √(1 + 4 + 4) = 3.
Worked examples
| Points | Squared gaps | Distance |
|---|---|---|
| (0, 0) and (3, 4) | 9 + 16 = 25 | 5 |
| (1, 2) and (6, 7) | 25 + 25 = 50 | 5√2 ≈ 7.071 |
| (−2, 3) and (4, −5) | 36 + 64 = 100 | 10 |
| (2, −1) and (−3, 5) | 25 + 36 = 61 | √61 ≈ 7.810 |
| (1, 1, 1) and (4, 5, 13) | 9 + 16 + 144 = 169 | 13 |
Midpoint formula
The midpoint is the average of the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). For (1, 2) and (6, 7) it's (3.5, 4.5).
Simplifying the radical
Pull out the largest perfect-square factor: √50 = √(25 × 2) = 5√2; √72 = √(36 × 2) = 6√2; √48 = √(16 × 3) = 4√3. If no square factor exists (√61), it's already simplest.
For triangle sides and angles, use the right triangle calculator; for the slope and equation of the line through two points, the slope calculator.
Frequently asked questions
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²): the square root of the sum of the squared differences in x and y.
Does the order of the points matter?
No. Squaring removes the sign, so (1, 2) to (6, 7) gives the same distance as (6, 7) to (1, 2).
How is the distance formula related to the Pythagorean theorem?
The differences in x and y are the legs of a right triangle and the distance is its hypotenuse: a² + b² = c².
Can distance be negative?
No. It's a square root of a sum of squares, so it's always zero or positive.