• Foundation
  • About 15 min
  • 5 practice questions

The distance formula in three dimensions

Find the distance between two points in space and from the origin, and use distances to test collinearity, identify right-angled, isosceles and equilateral triangles, and find points at equal distances.

If something looks wrong, please tell us.

How far apart are two points in space? In the plane you used Pythagoras once. In space you use it twice, and the result is a formula you will use in almost every problem of this topic: lengths of sides, the shape of a triangle, and points at a given distance.

Pythagoras twice

Let P(x₁, y₁, z₁) and Q(x₂, y₂, z₂) be two points. Picture a box with edges parallel to the axes and with PQ as its long diagonal. Its edges have lengths |x₂ − x₁|, |y₂ − y₁| and |z₂ − z₁|. By Pythagoras, the diagonal of the bottom face has length √((x₂ − x₁)² + (y₂ − y₁)²). That diagonal and the vertical edge are perpendicular, so Pythagoras once more gives the length of PQ.

PQ = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). From the origin: OP = √(x² + y² + z²).

The order of the points does not matter, because each difference is squared: (−3)² = 3² = 9. Work out each difference with its sign, square it, add the three squares and only then take the square root.

Worked example 1: two points

Find the distance between A(1, −2, 3) and B(4, 2, 15). The differences are 4 − 1 = 3, 2 − (−2) = 4 and 15 − 3 = 12. So AB = √(9 + 16 + 144) = √169 = 13.

Worked example 2: from the origin

The distance of P(2, −3, 6) from the origin is √(4 + 9 + 36) = √49 = 7.

Using distances to test shapes

Three points are collinear (on one line) when the longest of the three distances equals the sum of the other two. A triangle is right-angled when the square of its longest side equals the sum of the squares of the other two, isosceles when two sides are equal and equilateral when all three are equal. Compare squared distances where you can: it avoids square roots.

Worked example 3: are the points collinear?

Take A(1, 2, 3), B(2, 4, 5) and C(4, 8, 9). AB = √(1 + 4 + 4) = 3, BC = √(4 + 16 + 16) = 6 and AC = √(9 + 36 + 36) = 9. Since 3 + 6 = 9, the points are collinear, with B between A and C.

Worked example 4: what kind of triangle?

Take A(1, 0, 2), B(3, 1, 4) and C(0, −2, 4). AB² = 4 + 1 + 4 = 9, AC² = 1 + 4 + 4 = 9 and BC² = 9 + 9 + 0 = 18. Two sides are equal and 9 + 9 = 18, so the triangle is right-angled at A and isosceles, with AB = AC = 3 and BC = 3√2.

Worked example 5: a point at equal distances

Find the point on the x-axis that is equidistant from A(1, 2, 3) and B(3, 0, 1). A point on the x-axis is P(x, 0, 0). Set PA² = PB²: (x − 1)² + 4 + 9 = (x − 3)² + 0 + 1. Expanding, x² − 2x + 14 = x² − 6x + 10, so 4x = −4 and x = −1. The point is (−1, 0, 0). Check: PA² = 4 + 4 + 9 = 17 and PB² = 16 + 0 + 1 = 17.

Key takeaways. Subtract the coordinates, square, add, then take the root. Use squared distances to compare lengths and to find unknown points, because equal distances have equal squares. Three points are collinear when the longest distance is the sum of the other two.

Check your understanding

  1. 1. What is the distance between the points (2, −1, 3) and (−4, 1, 0)?

    1. 49
    2. 5
    3. 7
    4. √13
    Show answer

    Answer: C. The differences are −4 − 2 = −6, 1 − (−1) = 2 and 0 − 3 = −3. Distance = √(36 + 4 + 9) = √49 = 7. Forgetting the square root gives 49; adding the coordinates instead of subtracting gives √13.

  2. 2. What is the distance of the point (4, −4, 7) from the origin?

    1. 81
    2. 9
    3. 4√2
    4. √15
    Show answer

    Answer: B. √(4² + (−4)² + 7²) = √(16 + 16 + 49) = √81 = 9. 4√2 = √32 leaves out the z-coordinate; √15 adds the sizes of the coordinates (4 + 4 + 7) without squaring them.

  3. 3. What can you say about the points A(0, 1, 2), B(2, 3, 3) and C(6, 7, 5)?

    1. They form a right-angled triangle
    2. They form an equilateral triangle
    3. They form an isosceles triangle that is not right-angled
    4. They are collinear
    Show answer

    Answer: D. AB = √(4 + 4 + 1) = 3, BC = √(16 + 16 + 4) = 6 and AC = √(36 + 36 + 9) = 9. Since AB + BC = 3 + 6 = 9 = AC, the points lie on one line, with B between A and C.

  4. 4. Which point on the y-axis is equidistant from (3, 1, 2) and (1, 5, 0)?

    1. (0, 2, 0)
    2. (0, 3/2, 0)
    3. (3/2, 0, 0)
    4. (0, −3/2, 0)
    Show answer

    Answer: B. Take P(0, y, 0). Then 9 + (y − 1)² + 4 = 1 + (y − 5)² + 0, so y² − 2y + 14 = y² − 10y + 26. This gives 8y = 12 and y = 3/2. (3/2, 0, 0) is not on the y-axis.

  5. 5. The distance between (1, 2, k) and (3, −1, 2) is 7, and k is positive. What is k?

    1. 8
    2. 4
    3. 6
    4. −4
    Show answer

    Answer: A. 4 + 9 + (k − 2)² = 49, so (k − 2)² = 36 and k − 2 = ±6. So k = 8 or k = −4, and the positive value is 8.

Sign in to keep track of the lessons you finish.

Next lesson → Section formula, midpoint and centroid

Privacy · Terms · Refunds · Delivery