Distance & midpoint
Distance and midpoint calculator.
Find the length of the segment between two points and the point halfway along it — with the Pythagorean working written out and the segment drawn.
Paste a whole pair like (−2, 1) (1, 5) into any box to fill all four at once.
Distance
5
Midpoint
(−0.5, 3)
Horizontal Gap (Δx)
3
Vertical Gap (Δy)
4
Slope of Segment
4/3
= 1.333333
Angle
53.1301°
Interactive graph. Drag to pan, or scroll to zoom. With the graph focused, use the arrow keys to pan, plus and minus to zoom, and 0 to reset the view.
Step-by-Step Solution
Distance Is Pythagoras in Disguise
Plot two points and draw a right triangle with the segment between them as its hypotenuse. The bottom side is the horizontal gap, x₂ − x₁. The upright side is the vertical gap, y₂ − y₁. Pythagoras says the hypotenuse squared equals the sum of the other two squared, and rearranging gives the distance formula:
d = √((x₂ − x₁)² + (y₂ − y₁)²)
For (−2, 1) and (1, 5) the horizontal gap is 3 and the vertical gap is 4. That is the familiar 3-4-5 triangle, so the distance is exactly 5. Most pairs of points do not work out so neatly and leave you with an irrational number such as √13 — which is a complete, exact answer, not something that has to be turned into a decimal.
The Midpoint Is Just an Average
To find the point halfway along the segment, average the two x-coordinates and average the two y-coordinates:
M = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
For the same pair: x is (−2 + 1) ÷ 2 = −0.5 and y is (1 + 5) ÷ 2 = 3, so the midpoint is (−0.5, 3). A quick sanity check is that each coordinate of the midpoint must fall between the matching coordinates of the two endpoints. If it does not, a sign went astray.
Two Mistakes Worth Avoiding
- Subtracting in the midpoint formula. Distance uses subtraction, midpoint uses addition. Mixing them up is the most common slip, and it produces an answer that is nowhere near the segment.
- Forgetting to square before adding. √(3² + 4²) is 5, but √3² + √4² would be 7. The squaring happens first, then the addition, then the root.
Both formulas are closely tied to slope itself, and to the slope calculator: the same two differences that give you the distance also give you the rise and the run.
Common Questions
What is the distance formula?
The distance between two points is d = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem in disguise: the horizontal and vertical gaps are the two short sides of a right triangle, and the distance is the hypotenuse.
What is the midpoint formula?
The midpoint is ((x₁ + x₂)/2, (y₁ + y₂)/2) — the average of the two x-values and the average of the two y-values. Averaging each coordinate separately lands you exactly halfway along the segment.
Can the distance ever be negative?
No. Both differences are squared before they are added, which removes any negative signs, and the square root of a positive number is taken as positive. Distance is always zero or greater, and it is zero only when the two points are the same.
Does the order of the points change the answer?
Not for either formula. Swapping the points flips the sign of each difference, but squaring removes the sign, so the distance is unchanged. The midpoint uses addition, which does not care about order at all.
How do I find the distance in three dimensions?
Add the third term under the square root: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). The pattern extends to any number of dimensions — square each difference, add them, take the root. This calculator covers the two-dimensional case.