The idea in one breath

If two points lie on the same horizontal or vertical line, finding the distance between them is easy. You just subtract. For any other pair, there is a neat trick. The segment joining them is the hypotenuse of a right triangle whose legs are horizontal and vertical, and the Baudhāyana–Pythagoras theorem does the rest. In this lesson you will build the formula, see why the signs of the differences never matter, and then use it to test shapes and to find a midpoint.

Horizontal and vertical segments

If two points share a yy-coordinate, the segment between them is horizontal and its length is the difference of the xx-coordinates. From (2,5)(2, 5) to (9,5)(9, 5), for example, the length is 9−2=79 - 2 = 7. It works the same way when the xx-coordinate is shared. From (4,−3)(4, -3) to (4,6)(4, 6) the length is 6−(−3)=96 - (-3) = 9.

Take the larger minus the smaller, or find the difference and drop the sign. Either way, remember that a length is never negative.

A slanted segment

Let us try A(2,3)A(2, 3) and B(8,11)B(8, 11). Walk from AA horizontally to the point C(8,3)C(8, 3) directly below BB, then vertically up to BB. Triangle ACBACB is right-angled at CC, with

AC=8−2=6,CB=11−3=8AC = 8 - 2 = 6, \qquad CB = 11 - 3 = 8

and so, by the Baudhāyana–Pythagoras theorem,

AB=62+82=36+64=100=10AB = \sqrt{6^2 + 8^2} = \sqrt{36 + 64} = \sqrt{100} = 10

Grid with A(2, 3), C(8, 3) and B(8, 11): right triangle ACB with the right angle at C, horizontal leg AC = 6, vertical leg CB = 8 and hypotenuse AB = 10.
The legs 6 and 8 give the distance AB = 10.

The distance formula

For P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2), the horizontal leg is x2−x1x_2 - x_1 and the vertical leg is y2−y1y_2 - y_1, so

PQ=(x2−x1)2+(y2−y1)2PQ = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

Here is why you need not worry about signs. Squaring removes any minus sign, so it does not matter which point you call PP and which you call QQ, or whether the coordinates are negative. If you reflect the whole picture in an axis, the signs change but the distances do not.

Example 1. Find the distance between (−3,4)(-3, 4) and (5,−2)(5, -2).

(5−(−3))2+(−2−4)2=82+(−6)2=64+36=10\sqrt{(5 - (-3))^2 + (-2 - 4)^2} = \sqrt{8^2 + (-6)^2} = \sqrt{64 + 36} = 10

Example 2. Find the distance from the origin to (−7,24)(-7, 24).

(−7)2+242=49+576=625=25\sqrt{(-7)^2 + 24^2} = \sqrt{49 + 576} = \sqrt{625} = 25

This is worth remembering on its own: the distance of (x,y)(x, y) from the origin is always x2+y2\sqrt{x^2 + y^2}.

Example 3. Find the three sides of the triangle with vertices D(1,2)D(1, 2), E(7,2)E(7, 2) and F(4,8)F(4, 8).

DE=6DE = 6 (horizontal). EF=(4−7)2+(8−2)2=9+36=45EF = \sqrt{(4 - 7)^2 + (8 - 2)^2} = \sqrt{9 + 36} = \sqrt{45}. FD=(1−4)2+(2−8)2=9+36=45FD = \sqrt{(1 - 4)^2 + (2 - 8)^2} = \sqrt{9 + 36} = \sqrt{45}.

Two sides come out equal, so the triangle is isosceles.

Triangle with vertices D(1, 2), E(7, 2) and F(4, 8) on a grid; the base DE is 6 and the sides EF and FD are each root 45, marked equal.
Triangle DEF has two equal sides, so it is isosceles.

Testing a shape

Once you can find distances, you can answer quite a few questions about a shape without drawing it.

Isosceles or equilateral: compare the three sides and see how many match.

Right-angled: check whether the squares of two sides add up to the square of the third.

Collinear: three points lie on one line exactly when the two shorter distances add up to the longest one.

Example 4. Are (−2,−1)(-2, -1), (1,1)(1, 1) and (7,5)(7, 5) collinear?

9+4=13\sqrt{9 + 4} = \sqrt{13}; 36+16=52=213\sqrt{36 + 16} = \sqrt{52} = 2\sqrt{13}; 81+36=117=313\sqrt{81 + 36} = \sqrt{117} = 3\sqrt{13}. Since 13+213=313\sqrt{13} + 2\sqrt{13} = 3\sqrt{13}, the answer is yes.

Example 5. Show that (3,0)(3, 0), (6,4)(6, 4) and (−1,3)(-1, 3) form a right triangle.

Work with the squares of the sides: (3)2+(4)2=25(3)^2 + (4)^2 = 25; (7)2+(1)2=50(7)^2 + (1)^2 = 50; (4)2+(3)2=25(4)^2 + (3)^2 = 25. Since 25+25=5025 + 25 = 50, the angle at (3,0)(3, 0) is a right angle. As a bonus, the two legs are equal, so it is a right isosceles triangle.

Example 6. Do (5,12)(5, 12), (−12,5)(-12, 5) and (0,13)(0, 13) all lie on one circle centred at the origin?

Distances from OO: 25+144=13\sqrt{25 + 144} = 13, 144+25=13\sqrt{144 + 25} = 13, 1313. All three points are 1313 from OO, so yes, they lie on the circle of radius 1313 centred at OO.

The midpoint

Finding the point halfway along a segment is even easier. For the segment from (x1,y1)(x_1, y_1) to (x2,y2)(x_2, y_2), the coordinates of the halfway point are just the averages.

M=(x1+x22,y1+y22)\displaystyle M = \left(\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2}\right)

Why does this work? Going from the first point to the second, xx changes by x2−x1x_2 - x_1. At the halfway mark it has changed by half of that, giving x1+x2−x12=x1+x22\displaystyle x_1 + \dfrac{x_2 - x_1}{2} = \dfrac{x_1 + x_2}{2}. The same reasoning works for yy.

Example 7. Midpoint of (−4,9)(-4, 9) and (6,−1)(6, -1): (−4+62,9+(−1)2)=(1,4)\displaystyle \left(\dfrac{-4 + 6}{2}, \dfrac{9 + (-1)}{2}\right) = (1, 4).

Segment from (-4, 9) to (6, -1) with midpoint M(1, 4); dashed steps show x rising 5 and y falling 5 on each half of the segment.
M(1, 4) is halfway from (-4, 9) to (6, -1).

Example 8. M(2,−3)M(2, -3) is the midpoint of A(−5,1)A(-5, 1) and BB. Find BB.

−5+x2=2\displaystyle \dfrac{-5 + x}{2} = 2 gives x=9x = 9; 1+y2=−3\displaystyle \dfrac{1 + y}{2} = -3 gives y=−7y = -7. So B=(9,−7)B = (9, -7).

Practice

  1. Find the distance between (a) (1,1)(1, 1) and (4,5)(4, 5); (b) (−6,2)(-6, 2) and (6,−3)(6, -3); (c) (0,0)(0, 0) and (−9,−12)(-9, -12).
  2. Show that the triangle with vertices (0,3)(0, 3), (4,0)(4, 0) and (4,6)(4, 6) is isosceles.
  3. Are (2,1)(2, 1), (5,3)(5, 3) and (11,7)(11, 7) collinear?
  4. Show that (1,1)(1, 1), (4,1)(4, 1) and (1,5)(1, 5) are the vertices of a right triangle and find its hypotenuse.
  5. Which of (−8,6)(-8, 6), (9,4)(9, 4) and (0,−10)(0, -10) lie on the circle of radius 1010 centred at the origin? Which is inside it?
  6. Find the midpoint of (7,−2)(7, -2) and (−3,8)(-3, 8).
  7. M(0,5)M(0, 5) is the midpoint of P(−6,2)P(-6, 2) and QQ. Find QQ.
  8. The vertices of a square are (2,1)(2, 1), (−1,2)(-1, 2), (−2,−1)(-2, -1) and (1,−2)(1, -2) in order. Verify that all four sides are equal and that the two diagonals are equal, and find the area.

Answers

Show answers
  1. (a) 55. (b) 144+25=13\sqrt{144 + 25} = 13. (c) 1515.
  2. Sides: 16+9=5\sqrt{16 + 9} = 5, 66, 16+9=5\sqrt{16 + 9} = 5. Two equal sides.
  3. 13\sqrt{13}, 52=213\sqrt{52} = 2\sqrt{13}, 117=313\sqrt{117} = 3\sqrt{13}. Yes.
  4. Sides 33, 44 and 55; 9+16=259 + 16 = 25. Hypotenuse 55, between (4,1)(4, 1) and (1,5)(1, 5).
  5. Distances from OO: 1010, 97≈9.85\sqrt{97} \approx 9.85, 1010. The first and third are on the circle; (9,4)(9, 4) is inside.
  6. (2,3)(2, 3).
  7. Q=(6,8)Q = (6, 8).
  8. Every side is 9+1=10\sqrt{9 + 1} = \sqrt{10}. Diagonals: (2,1)(2, 1) to (−2,−1)(-2, -1) is 16+4=20\sqrt{16 + 4} = \sqrt{20}; (−1,2)(-1, 2) to (1,−2)(1, -2) is 4+16=20\sqrt{4 + 16} = \sqrt{20}. Area =(10)2=10= (\sqrt{10})^2 = 10 square units.