The Space Diagonal of a Box and Pythagoras in Three Dimensions
Find the longest straight line inside any box, see why d² = a² + b² + c² holds, and use it on fitting and distance problems.
Key takeaways
- The space diagonal of an a by b by c rectangular box has length √(a² + b² + c²).
- The proof uses two right triangles: one across the floor, then one standing on that floor diagonal with a vertical edge.
- The second triangle is right because a vertical edge is perpendicular to every line in the floor that passes through its foot.
- The same formula gives the distance between any two points in space from their three coordinate differences.
- A long thin object fits corner to corner only if it is no longer than the space diagonal, and its thickness reduces that limit.
The space diagonal of a rectangular box is the straight segment from one corner to the opposite corner, passing through the inside. If the box has edges a, b and c, its length d satisfies d² = a² + b² + c², so d = √(a² + b² + c²).
That formula is the Pythagorean theorem applied twice. Once you see the two right triangles hiding in the box, you can rebuild the result any time, and you can stretch it to distances between points in space and to questions about what will fit in a suitcase.
Seeing the two triangles
Picture a room. Stand in one floor corner and look to the ceiling corner farthest from you. The line your eye follows is the space diagonal, and it is longer than any wall, edge or floor measurement.
It also does not lie on any face of the box. That is the difference between a space diagonal and a face diagonal, which runs corner to corner across a single rectangle such as the floor or a wall.
To measure it, break the trip into two stages. First draw the face diagonal across the floor, from your corner to the opposite floor corner. Then go straight up the vertical edge to the ceiling. The floor diagonal, the vertical edge and the space diagonal close up into a triangle.
The derivation in two lines
Call the floor dimensions a and b, the height c, the floor diagonal f and the space diagonal d.
f² = a² + b² (right angle at a floor corner)
d² = f² + c² (right angle where the vertical edge meets the floor)
d² = a² + b² + c² (substitute the first line into the second)
d = √(a² + b² + c²) (lengths are positive) The first line is the ordinary theorem on a rectangle. The second deserves a moment, because the right angle is between a vertical edge and a diagonal that slants across the floor.
A line perpendicular to a flat surface makes a right angle with every line in that surface through the point where they meet. The vertical edge is perpendicular to two floor edges, so it is perpendicular to the whole floor, including the floor diagonal. You can test this with a physical corner using a model built around perpendiculars in space.
Worked examples
Take a box measuring 3 by 4 by 12. The floor diagonal across the 3 by 4 face is √(9 + 16) = 5. Then d = √(25 + 144) = √169 = 13.
For a box measuring 2 by 3 by 6, you can skip the middle step: d = √(4 + 9 + 36) = √49 = 7.
The order of the edges never matters. If you had started with the 3 by 12 face, its diagonal would be √153, and adding 4² = 16 still gives 169. Addition does not care which face you call the floor.
A cube with edge s is the special case a = b = c = s. Its space diagonal is √(3s²) = s√3, about 1.732 times the edge. Its face diagonal is s√2, about 1.414 times the edge. A cube of edge 10 cm therefore has face diagonals near 14.1 cm and space diagonals near 17.3 cm.
You can also work backward. Suppose a box has two edges of 10 and a space diagonal of 15. The third edge satisfies c² = 225 − 100 − 100 = 25, so c = 5. If the subtraction ever comes out zero or negative, no such box exists.
Will it fit?
Say you have a thin rod 90 cm long and a carton measuring 60 by 40 by 50 cm. Lying flat on the 60 by 40 base, the best you can do is √(3600 + 1600) = √5200, about 72.1 cm. Tilted from a bottom corner to the opposite top corner, you get √(5200 + 2500) = √7700, about 87.7 cm. The 90 cm rod does not fit, while an 85 cm rod does.
Real objects have thickness, and that matters near the limit. The ends of a fat tube cannot reach into the very tip of a corner, so the longest tube that fits is shorter than d. Treat the formula as an upper bound and leave a margin.
You also have to get the object in. An opening smaller than the box, a lip around the lid or a stiff item that must be tipped through the top can all defeat a measurement that looks fine on paper.
Distance between two points in space
Give each point three coordinates: two for position on the floor and one for height. The segment between points (x₁, y₁, z₁) and (x₂, y₂, z₂) is the space diagonal of an imaginary box whose edges are the three differences.
d = √( (x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)² ) For the points (1, 2, 3) and (4, 6, 15), the differences are 3, 4 and 12, so the distance is 13. Squaring removes any minus signs, which is why you may subtract in either order as long as you stay consistent within one coordinate pair.
If one difference is zero, the box is flat and the formula falls back to the familiar plane version. The same idea underlies distances and midpoints in three dimensions, including how to find the center of a box as the average of opposite corners.
A box has four space diagonals, one from each bottom corner to the opposite top corner. All four have the same length and cross at the center, each cut exactly in half. So the center is d/2 from all eight corners, and a sphere of radius d/2 passes through every one of them.
Through the box or around it
The space diagonal is the shortest route between opposite corners only if you may travel through the interior. An ant that must walk on the cardboard faces a longer trip.
To find its route, unfold two adjacent faces into one flat rectangle and draw a straight line. For the 3 by 4 by 12 box there are three ways to pair the edges, giving √(7² + 12²) = √193, √(15² + 4²) = √241 and √(16² + 3²) = √265. The shortest surface path is √193, about 13.89, compared with 13 straight through. The reasoning is laid out in the problem of the shortest walk over a box.
Boxes with whole-number diagonals
Some boxes have whole numbers for all three edges and the space diagonal. These sets of four are called Pythagorean quadruples.
| Edges | Sum of squares | Diagonal |
|---|---|---|
| 1, 2, 2 | 1 + 4 + 4 = 9 | 3 |
| 2, 3, 6 | 4 + 9 + 36 = 49 | 7 |
| 1, 4, 8 | 1 + 16 + 64 = 81 | 9 |
| 2, 6, 9 | 4 + 36 + 81 = 121 | 11 |
| 3, 4, 12 | 9 + 16 + 144 = 169 | 13 |
Multiplying every number in a row by the same factor gives another quadruple, since every length in the box scales together.
Asking for more is much harder. A box with edges 44, 117 and 240 has whole-number face diagonals of 125, 244 and 267, but its space diagonal is √73,225, which is not a whole number. A box with whole edges, whole face diagonals and a whole space diagonal is called a perfect cuboid. As of the mid-2020s, nobody had found one or proved that none exists.
Beyond three edges
The pattern keeps going. In four dimensions, a box with edges a, b, c and e has longest diagonal √(a² + b² + c² + e²), by one more right triangle. In n dimensions a cube of edge s has diagonal s√n, so the corners of a high-dimensional cube sit surprisingly far apart.
There is also a version about areas. Slice one corner off a box with a flat cut, leaving a tetrahedron with three right-angled faces. The square of the area of the slanted face equals the sum of the squares of the other three areas. This is usually called de Gua's theorem. With corner edges 1, 2 and 2, the right-angled faces have areas 1, 2 and 1, so the slanted face has area √(1 + 4 + 1) = √6.
Angles you can read from the box
The right triangle made of the floor diagonal, the vertical edge and the space diagonal also tells you how steeply the diagonal climbs. Its rise is c and its run is f. For the 3 by 4 by 12 box, the diagonal rises 12 over a floor distance of 5, so it is far closer to vertical than to level.
In a cube, the rise is s and the run is s√2. The diagonal therefore climbs less steeply than a 45° line, because it travels farther across the floor than it goes up.
Two space diagonals of a cube do not meet at right angles. Each half diagonal has length s√3/2, and two neighboring corners are s apart. The triangle formed at the center has sides s√3/2, s√3/2 and s. Since 3/4 + 3/4 = 3/2 is more than 1, the angle at the center facing the edge is acute, and its supplement on the other side is obtuse.
Mistakes to avoid
- Adding the edges before squaring. √(a² + b² + c²) is not a + b + c; for the 3 by 4 by 12 box, the sum is 19 while the diagonal is 13.
- Stopping at a face diagonal. If your answer uses only two of the three edges, you have measured across a face.
- Mixing units. Convert inches and feet, or centimeters and meters, before squaring anything.
- Using the formula on a slanted box. It needs right angles at the corners. A leaning box requires its angles as extra information.
To practice setting up problems like these from a written description, work through strategies for Pythagorean word problems. If you want to check that a real box or room corner is square before trusting the formula, the converse of the theorem gives a tape-measure test.