Why use this calculator
The theorem is the single most used piece of geometry outside a classroom, because a right angle is the cheapest thing to guarantee on a building site and the easiest thing to check afterwards. It converts two measurements taken along the square into a diagonal that would otherwise need a laser or a very long tape.
This calculator does more than the square root: it tells you which input is impossible, which is the failure mode that catches people out when they mistake a leg for the hypotenuse and get an imaginary answer. It also returns the two acute angles, because on site the follow-up question after a rafter length is almost always the cut angle, and the area and perimeter, which are what you need to order material rather than just mark it out.
How to use it
- Start by choosing which side you are missing.
- If you have measured the rise and the run and want the diagonal, leave it on hypotenuse.
- Enter the first leg, which in a roof problem is the vertical rise from the wall plate to the ridge, and the second leg, which is the horizontal run measured along the level rather than along the slope.
- If instead you know the diagonal and one side, switch the dropdown and the inputs change to ask for the hypotenuse and the one leg you did measure.
- Pick the unit you measured in from the last dropdown; every side must be in that same unit, since the theorem does no conversion. The unit only labels the output.
What each result means
- Hypotenuse (c)
- The long side opposite the right angle. The diagonal, rafter or brace length you need to cut or measure.
- Leg a
- The missing short side, worked back from the hypotenuse and the other leg using the same relationship.
- Leg b
- The other missing short side, again derived from the hypotenuse and the leg you supplied.
- Perimeter
- All three sides added together, which is what you order when edging, trimming or fencing the triangle.
- Area
- Half the product of the two legs, in squared units, useful for sheet material, paint or turf on a triangular section.
- Angle A (opposite leg a)
- The acute angle facing leg a, in degrees. On a roof this is the pitch when leg a is the rise and leg b the run.
- Angle B (opposite leg b)
- The other acute angle. It is always ninety degrees minus angle A, so the two together complete the right angle.
- Working
- The substituted expression showing exactly which numbers were squared, added or subtracted before the square root.
The formula
The theorem states
a² + b² = c²
Rearranged, c = √(a² + b²)
A = √(c² − b²)
B = √(c² − a²)
A solution for a leg exists only when c is strictly greater than that leg, otherwise the square root has a negative argument. The area of the triangle is (a × b) ÷ 2 and the perimeter is a + b + c. The angle opposite leg a is arctan(a ÷ b) in degrees, and the two acute angles always sum to 90.
How this number is used in practice
Carpenters and concreters square a frame with the 3-4-5 method: measure three units along one edge, four along the adjoining edge, and adjust until the diagonal between the marks reads exactly five. Because any multiple of a triple is also a triple, the same check works at 1.5-2-2.5 metres for a door opening or at 3-4-5 metres for a slab, and it needs nothing but a tape.
Roof framing is the same relationship in different clothing: rise and run are the legs, the common rafter is the hypotenuse, and the pitch angle is the arctangent of rise over run.
Surveyors, machinists and navigators use it as the distance formula in disguise. The straight-line distance between two points on a grid is the hypotenuse of the triangle formed by their easting and northing differences, which is how a CNC controller works out the length of a diagonal tool move and how a chart plotter turns a change in coordinates into a distance.
In three dimensions the same idea extends to the body diagonal of a box, which is how removalists check whether a long item will fit through a doorway.
In physics and engineering the theorem is how vectors are resolved. A force with horizontal and vertical components has a magnitude equal to the hypotenuse of those components, and the angle from the horizontal is the same arctangent. Impedance in an alternating-current circuit and resultant velocity in projectile motion are both computed this way, which is why the formula reappears in exams long after geometry has finished.
Worked examples
The classic 3-4-5 square used to check a frame
Hypotenuse exactly 5.0000, area 6.0000 square units, angles 36.87° and 53.13°.
A rafter over a 2.4 m rise and a 4.5 m run
Rafter length 5.1000 m, with a pitch of 28.07° from the horizontal.
A 5 m brace fixed 4 m along the floor: how high does it reach?
Leg a is 3.0000 m, so the brace lands three metres up the post.
A 55 inch television measured on the diagonal at 16:9 (48 in wide)
Height comes out at 26.8514 in, matching the usual 48 by 27 inch panel.
When people use it
- Squaring a slab, deck or wall frame with the 3-4-5 diagonal check
- Calculating common rafter length and roof pitch from rise and run
- Finding the straight-line distance between two points on a survey or map grid
- Working out whether a long item will pass through a door or up a stairwell
- Resolving force, velocity or impedance vectors into a single magnitude and angle
Tips
- The hypotenuse is always the longest side and always sits opposite the right angle. If your longest measurement is not the one you called c, the maths will fail.
- Learn the triples 3-4-5, 5-12-13 and 8-15-17; recognising them saves reaching for a calculator on site.
- Every side must be in the same unit before you start. Mixing feet with inches is the single most common error in this calculation.
- For a leg, check that the hypotenuse really is larger first. A negative value under the square root means the sides were swapped, not that the triangle is impossible.
- Measure the run along the level, not along the slope, or you will feed the hypotenuse in as a leg and get a short rafter.
- The theorem only holds for a right triangle. If the corner is not square, use the law of cosines instead.
What it assumes, and where it stops being accurate
- The triangle contains an exact right angle; a corner a degree or two out will make the calculated side visibly wrong over a long run.
- All three sides are entered in the same unit. No conversion is applied between the inputs.
- Lengths are treated as flat, straight-line distances, so no allowance is made for sag, camber or material thickness.
- Results are geometric only and exclude the kerf, overhang, birdsmouth or seat cut that a real rafter or brace needs.
- Side lengths are capped at one billion units, and zero or negative lengths are rejected rather than silently treated as zero.
- Angles are reported in degrees to two decimals, which is finer than most site tools can actually set.
Terms used on this page
- Hypotenuse
- The side opposite the right angle in a right triangle, and always its longest side.
- Leg
- Either of the two shorter sides that meet at the right angle, sometimes called the rise and the run.
- Pythagorean triple
- Three whole numbers such as 3, 4 and 5 that satisfy a² + b² = c² exactly, so they can be measured without rounding.
- Pitch
- The angle of a roof from the horizontal, equal to the arctangent of the rise divided by the run.
- Law of cosines
- The general rule c² = a² + b² − 2ab·cos(C) for any triangle, which reduces to Pythagoras at a right angle.
Questions people ask
- How do I know which side is the hypotenuse?
- It is the side opposite the right angle, and it is always the longest of the three. In practical terms it is the diagonal: the rafter rather than the rise or run, the brace rather than the post or the floor, the tape stretched corner to corner rather than along an edge. If a measurement you called a leg is longer than the one you called the hypotenuse, they have been swapped.
- Why does the calculator refuse some leg calculations?
- Because a leg can never be as long as the hypotenuse. If you ask for a leg while giving a hypotenuse shorter than the leg you already have, the square root would be of a negative number and no real triangle exists. Rather than print an error symbol the calculator tells you to check which measurement is the diagonal, since that is almost always the mistake.
- Does the 3-4-5 method work in any unit?
- Yes, as long as all three measurements use the same unit. Three and four metres give five metres; three and four feet give five feet. Scaling works too, so 1.5-2-2.5 or 6-8-10 are equally valid. Larger triangles give a more sensitive check, so use the biggest 3-4-5 that fits the space you are squaring.
- Can I use this for a triangle without a right angle?
- No. For any other triangle use the law of cosines, c² = a² + b² − 2ab·cos(C), where C is the angle between sides a and b. The Pythagorean theorem is the special case of that formula when C is ninety degrees, because the cosine of ninety degrees is zero and the final term disappears.
- How do I get the roof pitch from the rise and run?
- The pitch angle is the arctangent of the rise divided by the run, which this calculator reports as the angle opposite leg a when you enter the rise as leg a. A 2.4 metre rise over a 4.5 metre run gives about 28 degrees. Builders often quote the same thing as a ratio or as rise in inches per twelve inches of run.
- Does it work in three dimensions?
- Apply it twice. First find the diagonal of the base rectangle from its length and width, then treat that diagonal as one leg and the height as the other to get the body diagonal. The combined result is the square root of length squared plus width squared plus height squared, which is the longest straight line that fits inside a box.
Use this with
Pythagorean Theorem Calculator answers one part of the question. These pick up where it stops: Area Calculator, Aspect Ratio Calculator, Flooring Calculator and Deck Materials Calculator.
Where these figures come from
This calculation is jurisdiction-neutral arithmetic. No country-specific rules are applied.
- Wolfram MathWorld. Reference definitions, derivations and special cases for standard formulas
- NRICH: University of Cambridge. University-produced problems and explanations for school and competition mathematics
- MIT OpenCourseWare. Full university course material covering algebra, geometry and statistics
Pythagorean Theorem Calculator produces an estimate for general information. It is not financial, tax, medical, legal or engineering advice. read the full disclaimer. Spotted a wrong number? Report it and it gets fixed. The form picks up this calculator and the inputs you used.