Distance Formula and 3D Diagonals
The distance formula gives the length of the segment between two points from their coordinates, and in space the same idea gives the diagonal of a box. In brief: the distance between (x1, y1) and (x2, y2) is d = √[(x2 − x1)2 + (y2 − y1)2]. For (1, 2) and (4, 6) it is √(9 + 16) = 5. The space diagonal of a box with edges a, b, c is √(a2 + b2 + c2).
Both formulas are direct applications of the Pythagorean theorem. They are used to measure lengths on maps, to check whether a triangle is isosceles or right-angled in coordinate geometry and to compute the longest straight line that fits inside a room or a box. This guide derives the formulas, works through examples in the plane and in space and lists the diagonals of common boxes.
How do you find the distance between two points in the plane?
Draw a right triangle whose hypotenuse is the segment between the points. The horizontal leg has length |x2 − x1| and the vertical leg has length |y2 − y1|. The Pythagorean theorem then gives d2 = (x2 − x1)2 + (y2 − y1)2. Squares remove the signs, so the order of the points does not matter.
- Subtract the x-coordinates and the y-coordinates.
- Square both differences.
- Add the squares.
- Take the square root.
Example 1: A(−2, 3) and B(4, −5)
Differences: 4 − (−2) = 6 and −5 − 3 = −8. Then d = √(36 + 64) = √100 = 10.
Example 2: non-integer result
P(1, 1) and Q(3, 6): differences 2 and 5, so d = √(4 + 25) = √29 ≈ 5.39.
Example 3: classifying a triangle
Triangle with A(0, 0), B(4, 0) and C(0, 3). The sides are AB = 4, AC = 3 and BC = √(16 + 9) = 5. Since 32 + 42 = 52, the triangle is right-angled at A.
Example 4: points on a circle
Is (5, 12) on the circle with center (0, 0) and radius 13? The distance is √(25 + 144) = 13, so yes. This is the idea behind the equation of a circle.
How does the midpoint relate to the distance?
The midpoint of the segment from (x1, y1) to (x2, y2) is ((x1 + x2)/2, (y1 + y2)/2). It is at distance d/2 from each end. For A(−2, 3) and B(4, −5), the midpoint is (1, −1), and its distance to A is √(9 + 16) = 5, half of 10 ✓.
How do you find the diagonal of a box?
A rectangular box with edges a, b and c has a face diagonal and a space diagonal. Use the Pythagorean theorem twice. The face diagonal of the base has length d1 = √(a2 + b2). The space diagonal is the hypotenuse of a right triangle with legs d1 and c: d = √(d12 + c2) = √(a2 + b2 + c2).
Example 5: a room
A room is 6 m long, 4 m wide and 3 m high. The base diagonal is √(36 + 16) = √52 ≈ 7.21 m. The space diagonal is √(36 + 16 + 9) = √61 ≈ 7.81 m. A straight rod of length 7.8 m would just fit from one bottom corner to the opposite top corner.
Example 6: a cube
A cube with edge a has face diagonal a√2 and space diagonal a√3. For a = 5 the space diagonal is 5√3 ≈ 8.66.
How do you find the distance between two points in space?
The formula extends to three coordinates: d = √[(x2 − x1)2 + (y2 − y1)2 + (z2 − z1)2]. It is the space diagonal of the box whose edges are the coordinate differences. For A(1, 2, 3) and B(4, 6, 15): differences 3, 4 and 12, so d = √(9 + 16 + 144) = √169 = 13.
Space diagonals of common boxes
| a | b | c | a² + b² + c² | Diagonal |
|---|---|---|---|---|
| 1 | 2 | 2 | 9 | 3 |
| 2 | 3 | 6 | 49 | 7 |
| 1 | 4 | 8 | 81 | 9 |
| 2 | 6 | 9 | 121 | 11 |
| 3 | 4 | 12 | 169 | 13 |
| 4 | 4 | 7 | 81 | 9 |
| 1 | 1 | 1 | 3 | √3 ≈ 1.73 |
Where do these formulas come from?
The distance formula is a coordinate version of the Pythagorean theorem and became natural with the analytic geometry of Descartes in the seventeenth century. Formulas for the diagonal of a box follow from the same theorem and were known to practical geometers earlier. The general idea of distance in n dimensions was developed in the nineteenth century and is called the Euclidean distance.
Where are they used today?
Maps and navigation systems measure straight-line distances from coordinates, although for long distances on Earth a curved surface must be considered. Computer graphics and games compute distances between objects constantly. Packers check whether a long item fits in a box using the space diagonal. In data science, the Euclidean distance measures similarity between records.
Which mistakes are common?
Adding coordinates instead of subtracting
Use differences between corresponding coordinates, x with x and y with y.
Forgetting the square root
The sum of squares is d2, not d. Check this before writing the final answer.
Mishandling negative signs
Put brackets around negative coordinates: 4 − (−2) = 6, not 2. Squaring will remove the sign of the difference.
Using the face diagonal as the space diagonal
The space diagonal includes all three edges: √(a2 + b2 + c2).