Say you have point A(1, 1) and point B(5, 4) on a coordinate plane. What's the distance between them? Instead of measuring the diagonal with a ruler, there's a way to work it out exactly by calculation — and remarkably, it runs on the exact same principle as the Pythagorean theorem you already learned.
The trick is to draw a horizontal line and a vertical line instead of the diagonal that joins the two points. Starting from A(1,1), move straight right to the point that shares B's x-coordinate, (5,1), then move straight up from there to B(5,4) — and you've just built a right triangle. The horizontal distance covered is 5−1=4, and the vertical distance is 4−1=3. And the diagonal distance between A and B that we originally wanted turns out to be exactly the hypotenuse of this right triangle!
The Pythagorean theorem says that in a right triangle, (leg)² + (leg)² = (hypotenuse)². Plug our numbers in and you get 4² + 3² = 16 + 9 = 25, so the hypotenuse (the distance) is √25 = 5. In fact, 3-4-5 is the most famous right-triangle combination the Pythagorean theorem produces.
Written as a general formula, this becomes: the distance between point A(x₁, y₁) and point B(x₂, y₂) is the square root of the sum of the squared horizontal difference (x₂−x₁) and the squared vertical difference (y₂−y₁): distance = √{(x₂−x₁)² + (y₂−y₁)²}. It looks complicated, but it's really nothing more than treating "how far apart horizontally" and "how far apart vertically" as the two legs of a right triangle, then using the Pythagorean theorem to find the hypotenuse.
What about the special cases? If the two points are separated only vertically (same x-coordinate), the horizontal difference becomes 0, and the formula just reduces to the absolute value of the vertical difference. Conversely, if they're separated only horizontally, the vertical difference becomes 0 and only the horizontal difference remains. Either way, you can see the formula naturally shrinking down to fit the simpler situation.
This formula is a fundamental tool that keeps showing up later — in area calculations for shapes, in the equation of a circle (expressing the fact that every point on a circle is the same distance from the center), and in calculating the magnitude of a vector. On our activity page, you can freely change the coordinates of points A and B with sliders and watch, step by step, how the right triangle forms and how the distance formula gets applied.