Maths · Ch 7 · Topic 2 of 5Distance formula
Topic 2 of 5

The distance formula

About 60 minutes · 3 things to learn
By the end you can…
  • Derive the distance formula from Pythagoras' theorem; find the distance of a point from the origin and from an axis.
  • Find the distance between two points (including points with letters for coordinates) and find an unknown coordinate from a given distance (two values).
  • Find the condition for a point to be equidistant from two points (a relation between x and y), and find such a point on an axis.

A delivery app knows where the shop is and where your house is, as two pairs of numbers. To show the straight-line ("as the crow flies") distance, it does not need to measure anything: over short distances a formula built from Pythagoras' theorem is enough. In this topic you learn that formula and use it in every direction: to find a distance, to find a missing coordinate, and to find the points that are the same distance from two places.

The formula

Take any two points P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2). From P go across until you are straight below (or above) Q, at the corner T(x2,y1)T(x_2, y_1). Then go up (or down) to Q. The angle at T is 90°, so:

  • the horizontal side is PT=x2−x1PT = x_2 - x_1 (or its opposite, if it comes out negative);
  • the vertical side is TQ=y2−y1TQ = y_2 - y_1 (likewise);
  • by Pythagoras, PQ2=(x2−x1)2+(y2−y1)2PQ^2 = (x_2 - x_1)^2 + (y_2 - y_1)^2.

A length is never negative, so we take the positive root:

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

This is the distance formula. Squaring removes any minus sign, so the order of the points does not matter: (x1−x2)2(x_1 - x_2)^2 is the same as (x2−x1)2(x_2 - x_1)^2.

The fixed routine (use it every time):

  1. Label the points: (x1,y1)=…(x_1, y_1) = \ldots, (x2,y2)=…(x_2, y_2) = \ldots
  2. Substitute in brackets, signs included: (x2−x1)=(…−(…))(x_2 - x_1) = (\ldots - (\ldots)).
  3. Work out each bracket, then square it.
  4. Add.
  5. Take the root and simplify it.

Special cases

  • From the origin: the distance of P(x,y)P(x, y) from O(0,0)O(0, 0) is x2+y2\sqrt{x^2 + y^2}.
  • Same y-coordinate (a horizontal segment): the distance is just the difference of the x-coordinates; same x-coordinate: the difference of the y-coordinates.
  • Distance from an axis. The distance of P(x,y)P(x, y) from the x-axis is the length of the perpendicular from P to the x-axis, which is ∣y∣\lvert y \rvert (the size of y, without its sign). The distance from the y-axis is ∣x∣\lvert x \rvert. So (2,3)(2, 3) is 3 units from the x-axis and 2 units from the y-axis.
  • Mirror image in an axis. The image of P(x,y)P(x, y) in the x-axis is the point the same distance on the other side of the x-axis: (x,−y)(x, -y) — x stays, y changes sign. The image in the y-axis is (−x,y)(-x, y). For example, the image of (4,−7)(4, -7) in the x-axis is (4,7)(4, 7), and in the y-axis it is (−4,−7)(-4, -7). (Check: the mid-point of a point and its image lies on the mirror.)

Finding an unknown coordinate

If a distance is given and one coordinate is unknown, write the distance formula, square both sides to remove the root, and solve. You usually get a quadratic of the form (y−3)2=64(y - 3)^2 = 64, which has two answers, y−3=8y - 3 = 8 or y−3=−8y - 3 = -8. Both are correct unless the question rules one out (for example, "the point is in the fourth quadrant"). Check each value by putting it back into the distance formula.

Points equidistant from two points

P is equidistant from A and B when PA=PBPA = PB. It is easier to use PA2=PB2PA^2 = PB^2 (no roots). Expand both sides; the x2x^2 and y2y^2 terms cancel and a linear equation in x and y is left. Every point on that line is equidistant from A and B — the line is the perpendicular bisector of AB, and it passes through the mid-point of AB.

If the point must lie on an axis, use the axis card: on the x-axis write the point as (x,0)(x, 0); on the y-axis as (0,y)(0, y). Then there is only one unknown.

Visuals

Distance formula as a right triangle P (2, 1), Q (8, 9) and the corner T (8, 1) on a square grid: PT = x₂ − x₁ = 8 − 2 = 6 (dashed, horizontal), TQ = y₂ − y₁ = 9 − 1 = 8 (dashed, vertical), right angle at T, PQ = √(6² + 8²) = √100 = 10. PQ = √((x₂ − x₁)² + (y₂ − y₁)²). Across the axes: P (−3, 4), Q (5, −2), T (5, 4): 5 − (−3) = 8, −2 − 4 = −6 → (−6)² = 36, PQ = 10. x y x2 − x1 = 8 − 2 = 6 y2 − y1 = 9 − 1 = 8 PQ = 10 Q ( x2 , y2 ) T ( x2 , y1 ) P ( x1 , y1 ) right angle at T 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 O P (2, 1),  Q (8, 9),  T (8, 1) PQ = (x2 − x1)2 + (y2 − y1)2 PQ = 62 + 82 = 100 = 10 across the axes x y 5 − (−3) = 8 −2 − 4 = −6 (−6)2 = 36 PQ = 10 P Q T −4 −3 −2 −1 1 2 3 4 5 6 −3 −2 −1 1 2 3 4 5 O P (−3, 4),  Q (5, −2),  T (5, 4)
Distance formula as a right triangleThe distance formula is Pythagoras' theorem in the triangle PTQ.Draw in exam
Axis card Panel 1, on an axis: E (5, 0) on the x-axis and F (0, −4) on the y-axis, ringed; x-axis: y = 0 → (x, 0); y-axis: x = 0 → (0, y). Panel 2, distance from an axis: P (2, 3) with dashed perpendiculars to (0, 3) of length 2 and to (2, 0) of length 3; distance from the y-axis = |x|, distance from the x-axis = |y|. Panel 3: A (2, −6) and B (−3, 4) joined; the x-axis cuts AB where y = 0, at P (−1, 0), ringed; AP = 3√5, PB = 2√5, AP : PB = 3 : 2; (4k − 6)/(k + 1) = 0 ⇒ k = 3/2. On an axis x y E ( 5 , 0 ) F ( 0 , −4 ) 1 2 3 4 5 6 7 −5 −4 −3 −2 −1 1 O x-axis: y = 0 (x, 0) y-axis: x = 0 (0, y) Distance from an axis x y 2 3 P ( 2 , 3 ) 1 2 3 4 1 2 3 4 O distance from the y-axis = |x| = 2 distance from the x-axis = |y| = 3 An axis cutting a segment x y AP = 3 5 PB = 2 5 A ( 2 , −6 ) B ( −3 , 4 ) P ( −1 , 0 ) −6 −5 −4 −3 −2 −1 0 1 2 3 4 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 O the x-axis cuts AB where y = 0 AP : PB = 3 : 2 4k − 6 k + 1 = 0 ⇒ k = 3 2
Axis cardThe three axis facts that most "find the point" questions need.Draw in exam

The coordinate explorer lets you drag two points and watch the right triangle, the distance and the working change together.

Coordinate explorer Coordinate explorer, start view. 'Distance' mode: a square grid from −8 to 8 with A (−3, 4) and B (5, −2); the right triangle with corner (5, 4), legs x₂ − x₁ = 5 − (−3) = 8 and y₂ − y₁ = −2 − 4 = −6, AB drawn thick; the working AB = √((x₂ − x₁)² + (y₂ − y₁)²) = √((5 − (−3))² + (−2 − 4)²) = √(8² + (−6)²) = √(64 + 36) = √100 = 10. In the interactive version you drag A and B (or type their coordinates) and the working updates. 'Ratio' mode (shown on Topic 4): A (−2, 5), B (8, −5), AP : PB = 2 : 3, P (2, 1): x = (2 × 8 + 3 × (−2))/(2 + 3) = 10/5 = 2, y = (2 × (−5) + 3 × 5)/(2 + 3) = 5/5 = 1; P is between A and B; m (next to A) multiplies B's coordinates. Distance Ratio x y x2 − x1 = 5 − (−3) = 8 y2 − y1 = −2 − 4 = −6 A ( −3 , 4 ) B ( 5 , −2 ) −8 −6 −4 −2 2 4 6 8 −8 −6 −4 −2 2 4 6 8 O drag A drag B AB = (x2 − x1)2 + (y2 − y1)2 = (5 − (−3))2 + (−2 − 4)2 = 82 + (−6)2 = 64 + 36 = 100 = 10 Distance Ratio x y m n A ( −2 , 5 ) B ( 8 , −5 ) P ( 2 , 1 ) −8 −6 −4 −2 2 4 6 8 −8 −6 −4 −2 2 4 6 8 O AP : PB = m : n = 2 : 3 x = m1x2 + m2x1 m1 + m2 = 2 × 8 + 3 × (−2) 2 + 3 = 10 5 = 2 y = 2 × (−5) + 3 × 5 2 + 3 = 5 5 = 1 P is between A and B m (next to A) multiplies B's coordinates
Coordinate explorer (interactive)The distance formula as Pythagoras on a moving triangle, with every bracket and sign worked out.

Worked examples

Worked example 1

The distance between two points

Question. Find the distance between A(2, −1) and B(7, 3).

Given: A(2, −1), B(7, 3). Asked: AB.

Concept used: the distance formula. Why it applies: both points are given by their coordinates.

  1. 1

    Label: (x1,y1)=(2,−1)(x_1, y_1) = (2, -1) and (x2,y2)=(7,3)(x_2, y_2) = (7, 3).

  2. 2

    Write the formula.

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

    Substitute in brackets.

    AB=(7−2)2+(3−(−1))2AB = \sqrt{(7 - 2)^2 + (3 - (-1))^2}
  4. 4

    Work out each bracket: 7−2=57 - 2 = 5 and 3−(−1)=3+1=43 - (-1) = 3 + 1 = 4.

    AB=52+42AB = \sqrt{5^2 + 4^2}
  5. 5

    Square and add.

    AB=25+16=41AB = \sqrt{25 + 16} = \sqrt{41}
  6. 6

    41 has no perfect-square factor, so 41\sqrt{41} is already simplest.

  7. Check: take the points the other way round: (2−7)2+(−1−3)2=25+16=41\sqrt{(2 - 7)^2 + (-1 - 3)^2} = \sqrt{25 + 16} = \sqrt{41} ✔.

  8. Answer AB=41AB = \sqrt{41} units (about 6.4 units)

    Common trap: Writing 3−(−1)3 - (-1) as 3−1=23 - 1 = 2, which gives 25+4=29\sqrt{25 + 4} = \sqrt{29}. Keep the bracket round the negative coordinate.

Worked example 2

Points in different quadrants

Question. Find the distance between P(−3, 4) and Q(5, −2).

Given: P(−3, 4) in quadrant II, Q(5, −2) in quadrant IV. Asked: PQ.

Concept used: the distance formula — it works for points anywhere. Why it applies: the squares take care of the signs.

  1. 1

    Label: (x1,y1)=(−3,4)(x_1, y_1) = (-3, 4) and (x2,y2)=(5,−2)(x_2, y_2) = (5, -2).

  2. 2

    Substitute in brackets.

    PQ=(5−(−3))2+(−2−4)2PQ = \sqrt{(5 - (-3))^2 + (-2 - 4)^2}
  3. 3

    Brackets: 5−(−3)=5+3=85 - (-3) = 5 + 3 = 8 and −2−4=−6-2 - 4 = -6.

    PQ=82+(−6)2PQ = \sqrt{8^2 + (-6)^2}
  4. 4

    Square: 82=648^2 = 64 and (−6)2=36(-6)^2 = 36.

    PQ=64+36=100=10PQ = \sqrt{64 + 36} = \sqrt{100} = 10
  5. Check: on a grid, the corner T(5, 4) gives a horizontal side of 8 squares and a vertical side of 6 squares — a 6, 8, 10 triangle ✔.

  6. Answer PQ=10PQ = 10 units

    Common trap: Two sign slips: 5−(−3)=25 - (-3) = 2 and (−6)2=−36(-6)^2 = -36. The first gives 4+36=210\sqrt{4 + 36} = 2\sqrt{10}; the second makes the sum negative, which has no square root at all — a sure sign of an error.

Worked example 3

Coordinates with letters

Question. Find the distance between the points (a+b,a−b)(a + b, a - b) and (a−b,a+b)(a - b, a + b), where b>0b > 0.

Given: two points with letters. Asked: the distance between them.

Concept used: the distance formula with algebra in the brackets. Why it applies: letters follow the same rules as numbers.

  1. 1

    Label: (x1,y1)=(a+b,a−b)(x_1, y_1) = (a + b, a - b), (x2,y2)=(a−b,a+b)(x_2, y_2) = (a - b, a + b).

  2. 2

    First bracket: x2−x1=(a−b)−(a+b)=a−b−a−b=−2bx_2 - x_1 = (a - b) - (a + b) = a - b - a - b = -2b.

  3. 3

    Second bracket: y2−y1=(a+b)−(a−b)=a+b−a+b=2by_2 - y_1 = (a + b) - (a - b) = a + b - a + b = 2b.

  4. 4

    Square and add: (−2b)2+(2b)2=4b2+4b2=8b2(-2b)^2 + (2b)^2 = 4b^2 + 4b^2 = 8b^2.

  5. 5

    Take the root: 8b2=4×2×b2=22 b\sqrt{8b^2} = \sqrt{4 \times 2 \times b^2} = 2\sqrt{2}\,b (as b>0b > 0).

  6. Check: put a=1a = 1, b=1b = 1: the points are (2,0)(2, 0) and (0,2)(0, 2); their distance is 4+4=8=22\sqrt{4 + 4} = \sqrt{8} = 2\sqrt{2}, and the formula gives 22×12\sqrt{2} \times 1 ✔.

  7. Answer 22 b2\sqrt{2}\,b units

    Common trap: Opening −(a+b)-(a + b) as −a+b-a + b. The minus sign multiplies both terms in the bracket: −(a+b)=−a−b-(a + b) = -a - b.

Worked example 4

From the origin and from the axes

Question. For the point M(−8, 15), find its distance (a) from the origin (b) from the x-axis (c) from the y-axis.

Given: M(−8, 15). Asked: three distances.

Concept used: distance from O is x2+y2\sqrt{x^2 + y^2}; distance from the x-axis is ∣y∣\lvert y \rvert; from the y-axis is ∣x∣\lvert x \rvert. Why it applies: the perpendicular from M to an axis is a straight horizontal or vertical segment.

  1. 1

    (a) OM=(−8)2+152=64+225=289=17OM = \sqrt{(-8)^2 + 15^2} = \sqrt{64 + 225} = \sqrt{289} = 17.

  2. 2

    (b) The perpendicular from M to the x-axis is vertical and goes from height 15 to height 0: its length is ∣15∣=15\lvert 15 \rvert = 15.

  3. 3

    (c) The perpendicular from M to the y-axis is horizontal and goes from −8 to 0: its length is ∣−8∣=8\lvert -8 \rvert = 8.

  4. Check: O, M and the foot X(−8, 0) form a right triangle with legs OX = 8 and XM = 15, and 82+152=64+225=289=1728^2 + 15^2 = 64 + 225 = 289 = 17^2, and 82+152=64+225=289=1728^2 + 15^2 = 64 + 225 = 289 = 17^2 ✔.

  5. Answer (a) 17 units (b) 15 units (c) 8 units

    Common trap: Mixing up the axes: the distance from the x-axis is the y-coordinate's size, and the distance from the y-axis is the x-coordinate's size. Another slip is answering "−8": a distance is never negative.

Worked example 5

An unknown coordinate (two values)

Question. The distance between A(−1, 3) and B(5, y) is 10 units. Find the possible values of y.

Given: AB=10AB = 10. Asked: y.

Concept used: the distance formula, squared to remove the root. Why it applies: the formula connects the known distance to the unknown coordinate.

  1. 1

    Distance formula.

    (5−(−1))2+(y−3)2=10\sqrt{(5 - (-1))^2 + (y - 3)^2} = 10
  2. 2

    Square both sides.

    (5+1)2+(y−3)2=100(5 + 1)^2 + (y - 3)^2 = 100
  3. 3

    62=366^2 = 36; subtract 36 from both sides.

    (y−3)2=64(y - 3)^2 = 64
  4. 4

    Take the square root: a number whose square is 64 is 8 or −8.

    y−3=8ory−3=−8y - 3 = 8 \quad \text{or} \quad y - 3 = -8
  5. 5

    Add 3: y=11y = 11 or y=−5y = -5.

  6. Check: y=11y = 11: 36+82=100=10\sqrt{36 + 8^2} = \sqrt{100} = 10 ✔. y=−5y = -5: 36+(−8)2=100=10\sqrt{36 + (-8)^2} = \sqrt{100} = 10 ✔.

  7. Answer y=11y = 11 or y=−5y = -5 — the points (5,11)(5, 11) and (5,−5)(5, -5) are both 10 units from A.

    Common trap: Keeping only y=11y = 11. On a grid you can see why there are two: one point is above A's level and one below, at the same distance.

Worked example 6

An unknown x-coordinate

Question. Find x if the distance between P(x, 2) and Q(3, −5) is 525\sqrt{2} units.

Given: PQ=52PQ = 5\sqrt{2}. Asked: x.

Concept used: the distance formula, squared. Why it applies: only x is unknown.

  1. 1

    Distance formula.

    (3−x)2+(−5−2)2=52\sqrt{(3 - x)^2 + (-5 - 2)^2} = 5\sqrt{2}
  2. 2

    Square both sides: (52)2=25×2=50(5\sqrt{2})^2 = 25 \times 2 = 50.

    (3−x)2+49=50(3 - x)^2 + 49 = 50
  3. 3

    Subtract 49.

    (3−x)2=1(3 - x)^2 = 1
  4. 4

    So 3−x=13 - x = 1 or 3−x=−13 - x = -1.

  5. 5

    x=2x = 2 or x=4x = 4.

  6. Check: x=2x = 2: 12+(−7)2=50=52\sqrt{1^2 + (-7)^2} = \sqrt{50} = 5\sqrt{2} ✔. x=4x = 4: (−1)2+(−7)2=50\sqrt{(-1)^2 + (-7)^2} = \sqrt{50} ✔.

  7. Answer x=2x = 2 or x=4x = 4

    Common trap: Squaring 525\sqrt{2} as 5×2=105 \times 2 = 10 or as 25225\sqrt{2}. Square both factors: (52)2=52×(2)2=25×2=50(5\sqrt{2})^2 = 5^2 \times (\sqrt{2})^2 = 25 \times 2 = 50.

Worked example 7

A relation for equidistant points

Question. Find a relation between x and y such that the point P(x, y) is equidistant from A(2, −1) and B(−4, 3).

Given: PA=PBPA = PB. Asked: an equation in x and y.

Concept used: PA=PBPA = PB means PA2=PB2PA^2 = PB^2. Why it applies: squaring removes the roots, and both sides are positive.

  1. 1

    Write PA2=PB2PA^2 = PB^2.

    (x−2)2+(y−(−1))2=(x−(−4))2+(y−3)2(x - 2)^2 + (y - (-1))^2 = (x - (-4))^2 + (y - 3)^2
  2. 2

    Tidy the signs.

    (x−2)2+(y+1)2=(x+4)2+(y−3)2(x - 2)^2 + (y + 1)^2 = (x + 4)^2 + (y - 3)^2
  3. 3

    Expand each bracket.

    x2−4x+4+y2+2y+1=x2+8x+16+y2−6y+9x^2 - 4x + 4 + y^2 + 2y + 1 = x^2 + 8x + 16 + y^2 - 6y + 9
  4. 4

    Cancel x2x^2 and y2y^2 from both sides.

    −4x+2y+5=8x−6y+25-4x + 2y + 5 = 8x - 6y + 25
  5. 5

    Bring all terms to the right-hand side.

    0=12x−8y+200 = 12x - 8y + 20
  6. 6

    Divide by 4.

    3x−2y+5=03x - 2y + 5 = 0
  7. Check: the mid-point of AB is (2+(−4)2,−1+32)=(−1,1)\left(\dfrac{2 + (-4)}{2}, \dfrac{-1 + 3}{2}\right) = (-1, 1), and it must be equidistant from A and B: 3(−1)−2(1)+5=03(-1) - 2(1) + 5 = 0 ✔.

  8. Answer 3x−2y+5=03x - 2y + 5 = 0 (this line is the perpendicular bisector of AB)

    Common trap: Expanding (y+1)2(y + 1)^2 as y2+1y^2 + 1. The middle term is missing: (y+1)2=y2+2y+1(y + 1)^2 = y^2 + 2y + 1.

Worked example 8

A point on the y-axis, equidistant from two points

Question. Find the point on the y-axis which is equidistant from A(6, 1) and B(−2, 5).

Given: the point is on the y-axis; PA=PBPA = PB. Asked: the point.

Concept used: axis card — a point on the y-axis is (0,y)(0, y); then PA2=PB2PA^2 = PB^2. Why it applies: writing (0,y)(0, y) leaves only one unknown.

  1. 1

    Let the point be P(0,y)P(0, y).

  2. 2

    PA2=PB2PA^2 = PB^2.

    (6−0)2+(1−y)2=(−2−0)2+(5−y)2(6 - 0)^2 + (1 - y)^2 = (-2 - 0)^2 + (5 - y)^2
  3. 3

    Expand.

    36+1−2y+y2=4+25−10y+y236 + 1 - 2y + y^2 = 4 + 25 - 10y + y^2
  4. 4

    Cancel y2y^2 and simplify each side.

    37−2y=29−10y37 - 2y = 29 - 10y
  5. 5

    Add 10y10y and subtract 37.

    8y=−88y = -8
  6. 6

    y=−1y = -1, so the point is P(0,−1)P(0, -1).

  7. Check: PA=62+(1−(−1))2=36+4=40PA = \sqrt{6^2 + (1 - (-1))^2} = \sqrt{36 + 4} = \sqrt{40} and PB=(−2)2+(5−(−1))2=4+36=40PB = \sqrt{(-2)^2 + (5 - (-1))^2} = \sqrt{4 + 36} = \sqrt{40} ✔.

  8. Answer (0,−1)(0, -1)

    Common trap: Writing the point on the y-axis as (y,0)(y, 0). That is a point on the x-axis. On the y-axis, the x-coordinate is 0.

8 examples · they get harder as you go

Quick check

Answer without scrolling up
Quick check · 1 of 5MCQ1 mark

The distance between the points (−2,5)(-2, 5) and (4,−3)(4, -3) is:

Quick check · 2 of 5MCQ1 mark

The distance of the point (−6,4)(-6, 4) from the y-axis is:

Quick check · 3 of 5Short answer2 marks

The distance between the points (a,2)(a, 2) and (3,−2)(3, -2) is 5 units. Find all possible values of a.

Quick check · 4 of 5MCQ1 mark

A point P on the x-axis is equidistant from A(1, 3) and B(5, 1). The correct first line of the working is:

Quick check · 5 of 5MCQ1 mark

The mirror image of the point (6,−1)(6, -1) in the y-axis is:

Key points

  • PQ=(x2−x1)2+(y2−y1)2PQ = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}; the order of the points does not matter.
  • From the origin: x2+y2\sqrt{x^2 + y^2}. From the x-axis: ∣y∣\lvert y \rvert. From the y-axis: ∣x∣\lvert x \rvert.
  • Substitute in brackets, work out each bracket, then square: a square is never negative.
  • An unknown coordinate: square both sides; a squared bracket usually gives two values — check and keep both.
  • Equidistant: use PA2=PB2PA^2 = PB^2; the squares cancel and a linear relation is left (the perpendicular bisector of AB).
  • A point on the x-axis is (x,0)(x, 0); on the y-axis, (0,y)(0, y). Mirror image in the x-axis: (x,−y)(x, -y); in the y-axis: (−x,y)(-x, y).
My notesComing soon