How this distance formula calculator works
The distance formula gives the straight-line distance between two points in the coordinate plane. Given points (x₁, y₁) and (x₂, y₂), the distance is d = √((x₂ − x₁)² + (y₂ − y₁)²). The horizontal gap and the vertical gap are squared, added, and the square root of the sum is the distance — which is why a distance is never negative.
The formula comes straight from the Pythagorean theorem: the horizontal difference (x₂ − x₁) and the vertical difference (y₂ − y₁) are the two legs of a right triangle, and the distance is the hypotenuse, so a² + b² = c² becomes the distance formula. This calculator also reports the midpoint ((x₁ + x₂) / 2, (y₁ + y₂) / 2) and the slope of the line through the points for extra context. Turn on 3D mode to add a z-coordinate and use d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²).
Reference note: the exact value shows the simplified radical where possible (for example √8 = 2√2) and the decimal is rounded for display. In 3D mode the z-term is added under the same square root. The slope is reported in 2D only and is undefined when both x-values are equal.
Distance formula reference
| Points | Computation | Distance |
|---|---|---|
| (0, 0) and (3, 4) | √(3² + 4²) = √25 | 5 |
| (1, 2) and (4, 6) | √(3² + 4²) = √25 | 5 |
| (−2, −3) and (1, 1) | √(3² + 4²) = √25 | 5 |
| (0, 0) and (1, 1) | √(1² + 1²) = √2 | ≈ 1.414 |
| (0, 0, 0) and (1, 2, 2) | √(1² + 2² + 2²) = √9 | 3 |
Frequently asked questions
- What is the distance formula?
- The distance formula gives the straight-line distance between two points (x₁, y₁) and (x₂, y₂): d = √((x₂ − x₁)² + (y₂ − y₁)²). It returns the length of the segment joining the points in the coordinate plane.
- How is the distance formula derived from the Pythagorean theorem?
- The horizontal gap (x₂ − x₁) and the vertical gap (y₂ − y₁) form the two legs of a right triangle, and the distance is the hypotenuse. The Pythagorean theorem a² + b² = c² gives c = √((x₂ − x₁)² + (y₂ − y₁)²), which is the distance formula.
- How do I find the distance between two points?
- Subtract the x-values and square the result, subtract the y-values and square that result, add the two squares, then take the square root. For example (1, 2) and (4, 6) give √(3² + 4²) = √(9 + 16) = √25 = 5.
- What is the midpoint between two points?
- The midpoint is the point exactly halfway between the two points. You average each coordinate: M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2). For (1, 2) and (4, 6) the midpoint is (2.5, 4).
- Does the distance formula work in 3D?
- Yes. In three dimensions you add the squared difference of the z-values: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). This calculator includes an optional 3D mode that uses this extended formula.
- Can a distance be negative?
- No. Distance is always zero or positive because the differences are squared before the square root is taken, so any negative signs cancel. A distance of zero means the two points are the same point.