letx=

Coordinate geometry

Distance formula

The straight-line distance between two points (x1,y1) and (x2,y2): Pythagoras on a grid.

d=(x2−x1)2+(y2−y1)2

Calculator

The live calculator needs JavaScript. The worked example below shows the same steps it would.

See it move

−12−10−8−6−4−224681012−6−4−2246Δx = 6Δy = −8ABM
  • Distance AB = √(36 + 64) ≈ 10
  • Midpoint M = (2, −2)
  • Slope = Δy/Δx = −1.3333

What the symbols mean

d
the distance between the two points (never negative)
x1
the x-coordinate of the first point
y1
the y-coordinate of the first point
x2
the x-coordinate of the second point
y2
the y-coordinate of the second point

When to use it

Use it whenever you need the length of a segment from its endpoints' coordinates: the side of a shape drawn on a grid, the radius of a circle from its centre and a point on it, or checking whether a triangle is isosceles or right-angled. Solved the other way, it finds the points at a given distance, which usually gives two answers (one each side).

Worked example

Find the distance between A(−1, 2) and B(5, −6).

  1. Start from the formula.

    d=(x2−x1)2+(y2−y1)2
  2. Substitute x1 = −1, y1 = 2, x2 = 5, y2 = −6 and work it out.

    d=(5−(−1))2+(−6−2)2
    =62+(−8)2
    =36+64
    =100
    =10
  3. The horizontal gap is 6 and the vertical gap is 8; the distance is the hypotenuse of the right triangle they make.

Answer d = 10

Why it works

Draw the horizontal and vertical legs between the two points: they have lengths |x2−x1| and |y2−y1| and meet at a right angle, so the segment is the hypotenuse. Squaring removes the absolute values, which is why the order of the points does not matter.

Common mistakes

  • Mixing coordinates: subtract x from x and y from y, never an x from a y.
  • Squaring a negative difference wrongly: (2−(−6))2=82=64, and (−8)2 is also 64, not −64.
  • Forgetting the square root at the end and reporting d2.
  • Adding the differences before squaring: (6+8)2 is 14, not the distance.