The Distance Formula: How to Find the Distance Between Two Points
The distance between two points is d = √((x₂−x₁)² + (y₂−y₁)²). It comes straight from the Pythagorean theorem: the horizontal and vertical gaps between the points are the two legs of a right triangle, and the distance is the hypotenuse.

The distance between two points is
d = sqrt((x2-x1)^2 + (y2-y1)^2). Subtract the x-coordinates, subtract the y-coordinates, square both differences, add them, and take the square root. The two points can be labeled in either order, so pick whichever is convenient.
Try it with your own numbers in the Distance Formula Calculator.
What the formula is doing
The horizontal difference is the gap between the x-coordinates, and the vertical difference is the gap between the y-coordinates. Squaring both differences removes any negative signs, which is why it never matters which point you subtract from which.
The subscripts are just bookkeeping. Label one point and stay consistent. Call one point (x₁, y₁) and the other (x₂, y₂) so you keep each point's coordinates together.
Why it works
The formula is the Pythagorean theorem wearing coordinates. Plot two points on a grid and draw the straight segment between them. Draw a horizontal line from the first point and a vertical line from the second until they meet, and you have built a right triangle.
The horizontal leg is the difference in x, the vertical leg is the difference in y, and the segment connecting your two points is the hypotenuse. Pythagoras says the legs squared sum to the hypotenuse squared.
Take the square root of both sides and you have the distance formula exactly. Nothing new is being claimed. It is the Pythagorean theorem applied to the gaps between two points.
A worked example
Take two points and label one as the first and the other as the second, then substitute the coordinates into the formula and simplify down to a single length. With a horizontal gap and a vertical gap that form the classic right triangle, the distance comes out whole.
This is the classic three-four-five right triangle: a horizontal gap, a vertical gap, and a hypotenuse that lands on a whole number.
When the answer is not whole
Most point pairs do not land on a perfect square. When the sum under the root has no whole-number square root, the exact answer stays as a radical, and you evaluate it to get a usable decimal.
d = sqrt((3 - (-2))^2 + (4 - 1)^2) d = sqrt(5^2 + 3^2) d = sqrt(25 + 9) d = sqrt(34) d ≈ 5.83
Leave the answer as a radical when you need an exact value, and give the decimal when you need to measure or compare. Here is how the two examples line up.
The 3D distance formula
In three dimensions every point picks up a third coordinate, z, and the formula gains one more squared term. The logic is identical, since it is Pythagoras applied twice.
Substitute the three coordinate differences the same way you did in two dimensions, then square, add, and root.
The distance formula is the Pythagorean theorem applied to the horizontal and vertical gaps between two points. Order never matters because the differences are squared, and in three dimensions you simply add a z term under the root.
Common questions
No. Because each difference is squared, subtracting in either order gives the same result. A positive difference and its negative counterpart square to the same value, so you can pick whichever order is convenient.
Distance tells you how far apart two points are, which is a single length. The midpoint tells you the point exactly halfway between them, found by averaging the coordinates as ((x1+x2)/2, (y1+y2)/2). One returns a length and the other returns a point.
Slope measures the steepness of the line through two points, the ratio (y2-y1)/(x2-x1). Distance measures the length of the segment between them. Both use the same two differences, but slope divides them while distance squares, adds, and roots them.


