Distance Formula Calculator
Find the distance between two points in 2D or 3D, with the working, the exact radical form for whole-number points, and the midpoint.
The distance formula is d = the square root of (x2 - x1) squared plus (y2 - y1) squared. From (1, 2) to (4, 8) the differences are 3 and 6, the squares 9 and 36, so d is the square root of 45, exactly 3 times the square root of 5, about 6.7082. In 3D, add the squared z difference.
This is straight-line (Euclidean) distance between points on a flat grid, not driving distance or distance over the curved Earth. The decimal is rounded to four places; the exact radical form is shown only for whole-number coordinates.
Distance from A to B
6.7082
Exactly 3√5
- Differences (B minus A)
- 3, 6
- Squares
- 9 + 36
- Sum of squares
- 45
- Midpoint
- (2.5, 5)
Embed this calculator on your site →
About the Distance Formula Calculator
The distance formula is the Pythagorean theorem in coordinates. The horizontal and vertical gaps between two points are the legs of a right triangle, and the straight line between the points is its hypotenuse. From (0, 0) to (3, 4) the legs are 3 and 4, so the distance is the square root of 9 + 16, which is 5. Order does not matter, because each difference is squared: from (-2, 5) to (4, -3) the differences are 6 and -8, the squares 36 and 64, and the distance is 10. In 3D a third squared difference joins the sum: from (1, 2, 3) to (4, 6, 15) it is the square root of 169, or 13. When the coordinates are whole and the root is not, the calculator also gives the exact form, pulling square factors out of the root: from (1, 2) to (3, 8) the sum of squares is 40, and its square root becomes 2 times the square root of 10, about 6.3246. With decimal coordinates, or a sum of squares above one trillion, you get the decimal and the exact sum of squares instead. The midpoint is the average of each coordinate, (1, 1) for (-2, 5) and (4, -3).
Frequently asked questions
What is the distance formula?+
d = the square root of (x2 - x1) squared plus (y2 - y1) squared. From (0, 0) to (3, 4) that is the square root of 9 + 16, which is 5. It is the Pythagorean theorem with the coordinate differences as the two legs.
How do I find the distance between two points in 3D?+
Add the squared z difference under the root: d = the square root of (x2 - x1) squared + (y2 - y1) squared + (z2 - z1) squared. From (1, 2, 3) to (4, 6, 15) it is the square root of 169, which is 13.
How do I write the distance in simplest radical form?+
Take the largest perfect square out of the number under the root. 45 is 9 x 5, so the square root of 45 is 3 times the square root of 5. The calculator does this for whole-number coordinates and shows the decimal alongside it.
How do I find the midpoint of two points?+
Average each coordinate: add the two x values and halve them, then do the same for y (and z). The midpoint of (1, 2) and (4, 8) is (2.5, 5).
Distance and midpoint: Weisstein EW, "Distance," MathWorld and "Midpoint," MathWorld. The Pythagorean theorem: Euclid, Elements I.47.
Embed this calculator
Free to use on your own site. Paste this snippet where you want the distance formula calculator to appear — it resizes itself automatically.
<iframe
src="https://manytools.co/embed/distance-formula-calculator"
title="Distance Formula Calculator by ManyTools"
data-manytools="distance-formula-calculator"
width="100%"
height="640"
loading="lazy"
style="border:0;width:100%;max-width:720px"></iframe>
<script>
(function () {
window.addEventListener("message", function (e) {
if (e.origin !== "https://manytools.co") return;
var d = e.data || {};
if (d.type !== "manytools:embed:height" || d.slug !== "distance-formula-calculator") return;
var f = document.querySelector('iframe[data-manytools="distance-formula-calculator"]');
if (f && d.height) f.style.height = d.height + "px";
});
})();
</script><a href="https://manytools.co/math/distance-formula-calculator">Distance Formula Calculator by ManyTools</a>