Welcome back to Real-World and 3D Applications! You have arrived at the seventh and final lesson of the course — congratulations on making it all the way here. In Lesson 6, we computed the face diagonal across a single rectangular face of a box. Today, we take one more step into the interior of the box itself. Our goal is to find the space diagonal: the longest possible straight line inside a rectangular box, stretching from one corner all the way to the opposite corner. By the end of this lesson, you will be able to calculate that distance by applying the Pythagorean theorem twice in sequence.
From Face Diagonal to Space Diagonal
Recall from Lesson 5 that every rectangular box contains two connected right triangles linking its edges to the space diagonal. The first right triangle lies flat on the base, where two edges serve as legs and the face diagonal is the hypotenuse. The second right triangle stands upright inside the box, using that same face diagonal as one leg and the box's height as the other, with the space diagonal as its hypotenuse.
The diagram below shows the two linked right triangles inside a rectangular box.
This means finding a space diagonal is really just the Pythagorean theorem applied twice in a row. We already mastered the first application in Lesson 6. Today, we add the second.
The Two-Step Procedure
Let a rectangular box have length l, width w, and height h. We find the space diagonal ds​ by working through two right triangles in sequence.
Step 1 — Find the face diagonal. Choose the base (or any convenient face). Its diagonal df​ satisfies:
df2​=l2+w2
Step 2 — Find the space diagonal. The face diagonal df​ and the remaining edge h form the legs of a second right triangle whose hypotenuse is ds​:
ds2​=df2​+h2
Since df2​=l2+w2, we can substitute directly:
ds2​=l2+w2+h2
Taking the square root gives us a compact formula:
ds​=l2+w2+h2​
Notice the elegant result: the space diagonal equals the square root of the sum of all three squared edge lengths. Even though two separate right triangles are involved, everything collapses into one tidy expression.
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal
Let's walk through a box that measures 2 by 3 by 6.
Step 1 — Face diagonal of the base (2×3):
df2​=22+32=4+9=13
We do not need to take a square root here because df2​ feeds directly into the next step.
Step 2 — Space diagonal using df​ and the height (6):
ds2​=df2​+62=13+36=49ds​=49​=7
The space diagonal is 7 units. Notice how leaving df​ in its squared form (13) kept the arithmetic simple — there was no need to compute 13​ only to square it again in the next line.
In many practical cases, the space diagonal will not be a neat integer. Consider a box that measures 4 by 5 by 7.
Step 1 — Face diagonal of the base (4×5):
df2​=42+52=16+25=41
Step 2 — Space diagonal:
ds2​=41+72=41+49=90ds​=90​≈9.49
The exact answer is 90​, and the decimal approximation rounded to two decimal places is about 9.49 units. As we practiced in Lesson 6, keeping the exact radical form preserves full precision while a rounded decimal is easier to measure with a ruler or tape.
You may have noticed a pattern in both examples above. Each time, we kept df2​ as a plain number and plugged it straight into the second equation rather than taking a square root and then squaring again. This shortcut is worth turning into a deliberate habit:
Computing df2​​ in Step 1 and then squaring the result again in Step 2 creates unnecessary work.
If the face diagonal is irrational (like 41​), rounding it early introduces small errors that grow in Step 2.
By carrying the squared value forward, you stay exact and save effort. Only take the final square root once, at the very end.
One of the most common real-world uses for space diagonals is checking whether a long, rigid object can fit inside a box. The space diagonal represents the absolute longest straight-line distance available inside the box, so if the object is longer than that, it simply will not fit.
Suppose we need to ship a curtain rod that is 50 inches long. The shipping box has inside dimensions of 24 inches by 36 inches by 20 inches. Let's find the space diagonal.
Step 1 — Face diagonal of the base (24×36):
df2​=242+362=576+1296=1872
Step 2 — Space diagonal:
ds2​=1872+202=1872+400=2272ds​=2272​≈47.7 in
The space diagonal is roughly 47.7 inches. Since the curtain rod is 50 inches, it will not fit inside this box, even when placed corner to corner. We would need a longer box — or a rod that can be disassembled.
This same reasoning applies to any rigid object and any rectangular container. Whether you are fitting a baseball bat in a storage bin, a dowel in a shipping carton, or checking the longest item that fits in a refrigerator compartment, the two-step process is the same: compute the space diagonal and compare.
In this lesson, we brought together ideas from across the entire course into one powerful technique. Starting from the two connected right triangles inside a rectangular box, we used the face diagonal as a leg of a second right triangle to reach the space diagonal — a clean two-step process that collapses into the formula ds​=l2+w2+h2​. We also practiced the real-world skill of checking whether a long object fits inside a box by comparing its length to the space diagonal.
This wraps up the final lesson of Real-World and 3D Applications. Up next is a set of practice problems that will walk you through space-diagonal calculations, from guided fill-in-the-blank scaffolding all the way to fully independent, real-world scenarios — let's finish strong!