Distance formula calculator
Enter two points, get the distance, midpoint and slope.
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²). From (1, 2) to (4, 6): √(3² + 4²) = √25 = 5. It is the Pythagorean theorem with the two differences as legs.
How do I find the midpoint?
Average the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). The midpoint of (1, 2) and (4, 6) is (2.5, 4).
How do I find the slope between two points?
Rise over run: (y₂ − y₁) ÷ (x₂ − x₁). From (1, 2) to (4, 6) the slope is 4 ÷ 3 ≈ 1.333. A vertical line has no slope.
Does the order of the points matter?
Not for the distance, midpoint or slope — the differences change sign, but squaring and dividing cancel that. Only the direction angle turns around by 180°.
Can I use it for map distances?
Only on a flat grid, like a site plan in feet. For places on Earth over long distances the curvature matters and a great-circle formula is needed.
Should I leave the answer as a square root?
In algebra class the exact answer is a radical, and the decimal is a rounded check. For (10, −4) and (−1, 5), OpenStax gets √202, about 14.2 (Intermediate Algebra 2e, Example 11.3). The calculator shows the radicand in its second line and the decimal as the answer. To simplify a radical such as √72, use the simplify radical calculator.
What is the direction angle in the result?
The angle the line from the first point to the second makes with the positive x-axis, measured counterclockwise in degrees from −180° to 180°: atan2(Δy, Δx). From (1, 2) to (4, 6) it is 53.13°. Swap the points and it becomes −126.87°, which is 180° away.
The formula and what it assumes
Draw a horizontal and a vertical segment from the two points to meet at a right angle. They are the legs of a right triangle whose hypotenuse is the segment you want, so the Pythagorean theorem gives d = √((x₂ − x₁)² + (y₂ − y₁)²) (OpenStax Algebra and Trigonometry 2e, section 2.1). No absolute values are needed because the squares are never negative. The formula assumes a flat plane and the same unit on both axes, so convert inches to feet or the like before you enter the points.
Worked example: as the crow flies
In OpenStax Algebra and Trigonometry 2e, Example 6, one grid unit is 1,000 feet. Tracie drives along city streets from the origin to Franklin Park, with stops at (1, 1), (5, 1), (8, 3) and (8, 7), and covers 15,000 feet in all. The straight line from (0, 0) to (8, 7) has Δx = 8 and Δy = 7, so d = √(8² + 7²) = √113 = 10.63 units, or 10,630 feet (2.01 miles). The straight line is shorter than the streets because it is the hypotenuse of a right triangle.
Common mistakes
The usual slip is a sign error with negative coordinates. For (−3, −1) and (2, 3) the horizontal difference is 2 − (−3) = 5, not −1; reading it wrongly gives √17 = 4.12 instead of √41 = 6.40. Another is adding the differences instead of squaring them: 5 + 4 = 9 is the length of a route along grid lines, not the straight-line distance. For two places on Earth, use the coordinate distance calculator, not this one.
Sources: OpenStax, Algebra and Trigonometry 2e, section 2.1 “The Rectangular Coordinate Systems and Graphs” (distance formula, Examples 5 and 6); OpenStax, Intermediate Algebra 2e, section 11.1 “Distance and Midpoint Formulas; Circles” (Example 11.3). Related tools: midpoint calculator, Pythagorean theorem calculator, line equation calculator and coordinate distance calculator. How we check our calculators.