Distance Formula

How Far Apart Are Two Points?

On a number line, the distance between two points is easy: subtract and take the size. But on a plane, points have both an xx and a yy, so a single subtraction is not enough.

We need a way to measure the straight-line distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2).


It Is Just Pythagoras

Here is the trick. The horizontal gap and the vertical gap between the two points form the two legs of a right triangle. The straight-line distance is the hypotenuse.

  • The horizontal leg has length Δx=x2x1\Delta x = x_2 - x_1
  • The vertical leg has length Δy=y2y1\Delta y = y_2 - y_1
  • The distance dd is the hypotenuse

Pythagoras says d2=(Δx)2+(Δy)2d^2 = (\Delta x)^2 + (\Delta y)^2. Take the square root and you have the formula.


The Formula

d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

That is the distance formula, and it is nothing more than the Pythagorean theorem written in coordinates.


Example

Find the distance between (1,2)(1, 2) and (4,6)(4, 6).

d=(41)2+(62)2=32+42=9+16=25=5\begin{aligned} d &= \sqrt{(4 - 1)^2 + (6 - 2)^2} \\[0.5em] &= \sqrt{3^2 + 4^2} \\[0.5em] &= \sqrt{9 + 16} = \sqrt{25} = 5 \end{aligned}

Order Does Not Matter

You might worry about which point comes first. It never matters, because the differences are squared:

(x2x1)2=(x1x2)2(x_2 - x_1)^2 = (x_1 - x_2)^2

A negative gap and a positive gap square to the same thing. Subtract in whichever order you like.


Example With Negatives

Find the distance between (2,3)(-2, 3) and (1,1)(1, -1).

d=(1(2))2+(13)2=32+(4)2=9+16=5\begin{aligned} d &= \sqrt{(1 - (-2))^2 + (-1 - 3)^2} \\[0.5em] &= \sqrt{3^2 + (-4)^2} \\[0.5em] &= \sqrt{9 + 16} = 5 \end{aligned}

The squaring quietly handles every sign for you.