Skip to content
MasterMath

Distance Between Two Points

The straight-line distance between two points, which is Pythagoras applied to the horizontal and vertical gaps.

Distance

—

Distance—
Horizontal difference—
Vertical difference—
Midpoint—
Angle of the segment—

How it was solved

    The formula

    d = √((x₂ − x₁)² + (y₂ − y₁)²)

    Why it works

    Draw the horizontal and vertical differences between two points and you have made a right triangle whose hypotenuse is the distance. The formula is Pythagoras and nothing more; the squares are what make the signs of the differences irrelevant.

    How to solve it by hand

    1. Subtract the x values and square the result
    2. Subtract the y values and square that too
    3. Add the two squares
    4. Take the square root

    What is worth knowing

    The squaring is doing quiet work: it makes the order of the points irrelevant, since (−3)² and 3² are the same. That is why you never need to worry about which point you call first. The formula extends to three dimensions by adding a (z₂ − z₁)² term, and to any number of dimensions the same way — which is how distance works in machine learning, where 'points' routinely have hundreds of coordinates. It is worth knowing that other distances exist: Manhattan distance adds the absolute differences instead of squaring, and it is the right one when you can only travel along a grid.

    Frequently asked questions

    Why does the order of the points not matter?

    Because the differences are squared, and squaring removes the sign. Either order gives the same distance.

    Does this work in three dimensions?

    Yes, by adding a (z₂ − z₁)² term inside the root. The same pattern extends to any number of dimensions.

    What is Manhattan distance?

    The sum of the absolute differences rather than the root of their squares. It is the right measure when you can only move along a grid.

    Is this the same as Pythagoras?

    Exactly the same. The distance is the hypotenuse of the right triangle formed by the horizontal and vertical gaps.