• Foundation
  • About 16 min
  • 5 practice questions

Distance between two points in space

Derive the distance formula PQ = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²] using two right triangles, and use it to find distances and unknown coordinates.

If something looks wrong, please tell us.

In the plane, the distance between two points came from Pythagoras' theorem used once. In space we use it twice, once along the floor and once upwards. The resulting formula is the most used tool in three-dimensional coordinate geometry.

Deriving the distance formula

Let P(x₁, y₁, z₁) and Q(x₂, y₂, z₂) be two points. Through P and Q draw planes parallel to the coordinate planes. They form a rectangular box (a rectangular parallelepiped) with PQ as one of its diagonals. Its edges are parallel to the axes, with lengths |x₂ − x₁|, |y₂ − y₁| and |z₂ − z₁|.

  1. Let A be a corner of the box joined to P by an edge parallel to the y-axis, so PA = |y₂ − y₁|, and such that angle PAQ is a right angle.
  2. In right triangle PAQ: PQ² = PA² + AQ².
  3. AQ is the diagonal of a face of the box. Let N be the corner between A and Q, with AN parallel to the x-axis and NQ parallel to the z-axis. Angle ANQ is a right angle.
  4. In right triangle ANQ: AQ² = AN² + NQ².
  5. Combine: PQ² = PA² + AN² + NQ² = (y₂ − y₁)² + (x₂ − x₁)² + (z₂ − z₁)².

Distance between P(x₁, y₁, z₁) and Q(x₂, y₂, z₂): PQ = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. From the origin: OQ = √(x² + y² + z²).

Because each difference is squared, the order of the points does not matter and the signs of the differences do not matter. The formula is the plane formula with one more term, and if both points have z = 0 it reduces exactly to the familiar two-dimensional formula.

Pythagoras twice inside the box

  1. Box with diagonal PQ Edges |x₂ − x₁|, |y₂ − y₁|, |z₂ − z₁|
  2. Face diagonal AQ² = (x₂ − x₁)² + (z₂ − z₁)²
  3. Space diagonal PQ² = AQ² + (y₂ − y₁)²
  4. Result PQ² = sum of the three squared differences

Worked examples

Worked example 1

Find the distance between (2, −1, 3) and (5, 3, 15). Differences: 3, 4, 12. PQ = √(9 + 16 + 144) = √169 = 13 units.

Worked example 2

Find the distance between (0, 3, −1) and (2, −3, 2). Differences: 2, −6, 3. PQ = √(4 + 36 + 9) = √49 = 7 units. Note that (−6)² = 36: the sign of a difference never matters.

Worked example 3: from the origin

How far is (1, 2, −2) from the origin? OQ = √(1 + 4 + 4) = √9 = 3 units. The length of the diagonal of a cuboid with edges a, b, c is the same calculation: √(a² + b² + c²). For a cuboid 3 cm × 4 cm × 12 cm the diagonal is √(9 + 16 + 144) = 13 cm.

Worked example 4: an unknown coordinate

The distance between (1, k, 3) and (3, 2, −3) is 7. Find k. Square both sides: (3 − 1)² + (2 − k)² + (−3 − 3)² = 49, so 4 + (2 − k)² + 36 = 49 and (2 − k)² = 9. Hence 2 − k = ±3, giving k = −1 or k = 5. Squaring an equation of distances usually gives two answers; both are valid here, one on each side.

Worked example 5: a point on an axis

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

Distances worked out in this lesson
Pair of pointsSquared differencesDistance
(2, −1, 3), (5, 3, 15)9 + 16 + 144 = 16913
(0, 3, −1), (2, −3, 2)4 + 36 + 9 = 497
(0, 0, 0), (1, 2, −2)1 + 4 + 4 = 93
(1, 1, 1), (2, 2, 2)1 + 1 + 1 = 3√3

Key takeaways

  • PQ = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]; from the origin √(x² + y² + z²).
  • Squaring removes signs, so the order of points does not matter.
  • Set squared distances equal (or equal to a given square) to find unknown coordinates; expect up to two answers.

Check your understanding

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

    1. 5
    2. 6
    3. 7
    4. 49
    Show answer

    Answer: C. Differences: 2, 3, −6. Distance = √(4 + 9 + 36) = √49 = 7.

  2. 2. What is the distance of (−6, 2, 3) from the origin?

    1. 11
    2. √11
    3. 5
    4. 7
    Show answer

    Answer: D. √(36 + 4 + 9) = √49 = 7.

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

    1. √24
    2. √20, that is 2√5
    3. 4
    4. √10
    Show answer

    Answer: B. Differences: −4, 2, 0. Distance = √(16 + 4 + 0) = √20 = 2√5. The z-coordinates are equal, so this is really a distance within the plane z = 2.

  4. 4. If the distance between (k, 0, 4) and (1, 2, 0) is 6, the values of k are:

    1. 5 and −3
    2. 3 and −5
    3. 3 and −1
    4. 4 and 2
    Show answer

    Answer: A. (1 − k)² + 2² + 4² = 36, so (1 − k)² + 20 = 36 and (1 − k)² = 16. Then 1 − k = ±4, giving k = −3 or k = 5.

  5. 5. Assertion (A): The distance formula in space reduces to the plane distance formula when both points have z = 0. Reason (R): Then the term (z₂ − z₁)² is 0.

    1. Both A and R are true, and R is the correct explanation of A
    2. Both A and R are true, but R is not the correct explanation of A
    3. A is true, but R is false
    4. A is false, but R is true
    Show answer

    Answer: A. Both are true. If z₁ = z₂ = 0, the third squared difference vanishes and the formula becomes √[(x₂ − x₁)² + (y₂ − y₁)²], the plane formula. R explains A.

Privacy · Terms · Refunds · Delivery