The Distance Formula
Learning objectives
- Derive and apply the distance formula between two points
- Compute the midpoint of a segment given its endpoints
- Use the distance formula to verify geometric properties
Now that points have coordinates, distance becomes algebra. The previous section gave us Pythagoras' theorem as a geometric statement about right triangles; this section turns it into an algebraic formula for the distance between any two points in the plane. Once we have the formula, we can compute the length of a fence, the radius of a circle, the side of a quadrilateral, all from coordinate data, without ever drawing the figure.
From Pythagoras to coordinates
Take two points and . The horizontal gap between them has length and the vertical gap has length . These two gaps are the legs of a right triangle whose hypotenuse is the straight-line distance . Pythagoras gives:
Squaring eliminates the need for the absolute values: , so the order of the points is irrelevant. The distance is always non-negative, and is zero only when the two points coincide.
- GPS: GPS computes your position by solving distance equations: each satellite gives a sphere , and your location is the intersection of four such spheres.
- Machine Learning: The simplest classifier picks the training points with smallest Euclidean distance to a query, exactly the distance formula , repeated for every dimension.
- Sports Analytics: "Shot distance" in basketball, the metric the NBA uses to evaluate scoring efficiency, is literally measured in feet.
Drag and in the widget. The widget shows , , and the live distance . Try the 3-4-5 triple: , .
The midpoint formula
The midpoint of the segment from to is simply the average of the two coordinates:
The midpoint is equidistant from both endpoints and lies exactly halfway along the segment. Geometrically this is the centre of mass of the two endpoints (treating each as a unit mass).
What the formula buys you
Once you have the distance and midpoint formulas, a remarkable number of geometric verifications become arithmetic:
- Is a triangle right-angled? Compute the three side lengths; check whether for the largest side .
- Is a quadrilateral a parallelogram? Check that opposite sides have equal length.
- Is a point on a circle? Check that its distance from the centre equals the radius.
- Where is the midpoint of a segment? Average the coordinates, bisection is a one-line calculation.
Try it
- Place , and , . Predict first: with and , what are the distance and midpoint? Place the points and verify the widget shows distance and midpoint .
- Set , and , . Before placing: with and , what is , , and the distance? Set the points and verify the answer is .
- Set on the -axis and on the -axis. The distance reduces to , the hypotenuse of a right triangle whose right angle sits at the origin.
Try it in code
A trap to watch for
Beginners sometimes confuse the distance formula with (forgetting to square) or with (no squares or root, just adding the legs). Both are wrong. The signature of the right formula is the two squares inside the radical: it is Pythagoras rearranged. The cleanest sanity check is to verify against the 3-4-5 triangle: distance from to should be exactly , not , not .
What you now know
You can compute the distance between any two points in the plane, find their midpoint, and use these tools to test geometric claims with arithmetic alone. The next section uses the distance formula to write down the most famous equation in coordinate geometry: the equation of a circle.
Quick check
Mark section complete →
References
- Lang, S. (1971). Basic Mathematics. Springer. Chapter 8, §2, the distance and midpoint formulas in coordinates.
- Stewart, J. (2015). Calculus, 8th ed. Cengage. Appendix B reviews these formulas before calculus proper.
- Coxeter, H. S. M. (1969). Introduction to Geometry, 2nd ed. Wiley. §1.2 develops the Euclidean metric axiomatically.
- Hartshorne, R. (2000). Geometry: Euclid and Beyond. Springer. Chapter 1 reconstructs distance from Euclid's axioms.