Pythagorean Theorem Calculator

a² + b² = c² relates the three sides of any right triangle, and this calculator runs it in all three directions: find the hypotenuse from two legs, recover a missing leg from the hypotenuse and one leg, or test three measured lengths to see whether the corner between them is truly square. It also returns the perimeter, area and both acute angles, and reports how far a failed squareness check is from a right angle. Use any unit — results come back in it.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
What you wantPick the direction you need; unused fields are ignored.Hypotenuse from two legs
Leg aOne of the two shorter sides that meet at the right angle.3
Leg bThe other side at the right angle, in the same unit.4
Hypotenuse cThe longest side, opposite the right angle — the diagonal you measured.5

It returns

  • Solved side — In check mode this is the hypotenuse the two legs require, which is what a square corner would measure.
  • Leg a
  • Leg b
  • Hypotenuse c
  • Perimeter
  • Area
  • Angle opposite leg a
  • a² + b² − c² — Zero for a true right triangle. Positive means the corner is under 90°, negative means over.

The formula

a2+b2=c2
c=a2+b2

In plain text: a² + b² = c²; c = √(a² + b²); a = √(c² − b²)

  • a, bThe legs — the two sides meeting at the right angle (units)
  • cThe hypotenuse — the side opposite the right angle, always the longest (units)

Applies only to right triangles. The converse also holds: if a² + b² = c² for three measured lengths, the angle opposite c is exactly 90°, which is what makes it a field test for square.

Updated Category Triangle Solvers & Trigonometric Laws Verified against published test cases Reading time 9 min

What the theorem says, and what it does not

In a right triangle, the square built on the hypotenuse has exactly the same area as the two squares built on the legs added together: a² + b² = c². That statement is about areas, not lengths, which is why the squares are there and why the relationship cannot be simplified to a + b = c.

The theorem applies only when one angle is exactly 90°. Feed it a triangle without a right angle and it gives a wrong answer with no complaint. For those, use the law of cosines calculator, whose formula is this one plus a correction term that vanishes at 90°.

Just as useful is the converse, proved as the last proposition of Euclid's first book: if three lengths satisfy a² + b² = c², then the angle opposite c must be a right angle. That is what turns the theorem into a measuring tool. Mark 3 units along one line and 4 along another, and if the diagonal between the marks reads exactly 5, the corner is square. No instrument is needed, only a tape — which is why the 3-4-5 method has been standard on building sites for millennia.

The same relationship is the distance formula in disguise. The gap between two points is √((Δx)² + (Δy)²), which is the hypotenuse of the right triangle formed by their horizontal and vertical separations. See the distance formula calculator.

Three problems, one identity

Finding the hypotenuse. Square both legs, add, take the root: c = √(a² + b²). The result is always longer than either leg but shorter than their sum, and for two equal legs it is exactly s√2 ≈ 1.4142s.

Finding a leg. Subtract instead: a = √(c² − b²). This requires c > b; a hypotenuse shorter than a leg describes no triangle, and the calculator rejects it rather than returning the root of a negative number.

Checking for square. Compute a² + b² − c². Zero means a right angle. Positive means the sum of the leg squares is too large for the measured diagonal, so that diagonal is short and the corner is acute. Negative means the diagonal is long and the corner is obtuse. The calculator reports both the deviation and the diagonal a square corner would require, which is the number you actually adjust to.

Because the relationship is homogeneous in length, right triangles scale exactly: multiply all three sides by any factor and the identity still holds. That is why 3-4-5, 6-8-10, 9-12-15 and 12-16-20 are all valid squaring checks — pick the one that fits the space, and prefer the largest that fits, since a longer baseline reduces the angular effect of a given measuring error.

Integer solutions like 3-4-5 are called Pythagorean triples. Every primitive one is generated by a = m² − n², b = 2mn, c = m² + n² for coprime integers m > n of opposite parity: m = 2, n = 1 gives 3-4-5; m = 3, n = 2 gives 5-12-13; m = 4, n = 1 gives 15-8-17.

Worked example: bracing a wall and squaring a slab

Part one: a diagonal brace. A wall frame is 8.000 ft tall and 10.000 ft long, and you need a brace corner to corner.

  1. Square the legs. 8² = 64 and 10² = 100.
  2. Add. 64 + 100 = 164.
  3. Root. c = √164 = 12.8062 ft, which is 12 ft 91116 in.
  4. Angles. The brace meets the bottom plate at arctan(8/10) = 38.6598°, and the top at 51.3402°.
  5. Area enclosed. ½ × 8 × 10 = 40 ft².

Part two: squaring a slab. You have formed a slab intended to be 12 ft by 16 ft, and the measured diagonal is 20.125 ft.

  1. What a square corner needs. √(12² + 16²) = √(144 + 256) = √400 = 20.000 ft exactly — 12-16-20 is 3-4-5 scaled by four.
  2. Deviation. a² + b² − c² = 400 − 405.0156 = −5.0156. Negative, so the diagonal is long and the corner is obtuse.
  3. How far out. The corner angle is arccos[(12² + 16² − 20.125²)/(2 × 12 × 16)] = arccos(−0.013062) = 90.7485°, so the form is 0.75° out of square.
  4. The fix. Racking the frame until the diagonal reads 20.000 ft squares it. The 0.125 ft of diagonal error corresponds to that three-quarters of a degree, which is the useful sensitivity of this test: on a 20 ft diagonal, one inch of error is roughly 0.5°.

Using the deviation number in the field

The sign of a² + b² − c² tells you which way to push. Positive means the measured diagonal is shorter than a square corner requires, so the corner is acute and the frame needs opening up. Negative means the diagonal is longer than required, the corner is obtuse, and the frame needs closing. The magnitude of the deviation is in squared units and is not intuitive on its own, which is why the calculator also gives the diagonal a square corner would need — that is the number to chase with a tape.

Choose the largest triple your space allows. The angular effect of a fixed tape error scales as 1/baseline: a 1/16-inch error on a 3-4-5 check laid out in feet gives dθ = c·dc/(ab) = 60 × 0.0625 / (36 × 48) = 0.0022 rad, about 0.12°, while the same error on a 12-16-20 check gives exactly a quarter of that, about 0.03°. Squaring a 20 ft form off a 3-4-5 triangle throws away that factor of four, so the small triple should be a last resort.

Two practical cautions on measurement. First, everything must be measured along the same plane: a diagonal taken across a sloping site is longer than the plan diagonal and will report a square corner as obtuse. Second, tape sag and tension matter over long spans — a loose tape reads long, which biases the check toward "obtuse" every time.

On angles: the two acute angles always sum to 90°, so finding one gives the other. Their tangent is the ratio of the legs, which is the same quantity a builder calls slope or pitch. A 4-in-12 roof is a right triangle with legs 4 and 12, hypotenuse √160 = 12.6491, and a pitch angle of arctan(4/12) = 18.4349°.

Pythagorean triples and common right triangles

Integer triples verify exactly; the last three rows show frequently needed irrational cases to seven figures.
Legs a, bHypotenuse ca² + b²Angle opposite a
3, 459 + 16 = 2536.8699°
5, 121325 + 144 = 16922.6199°
8, 151764 + 225 = 28928.0725°
7, 242549 + 576 = 62516.2602°
20, 2129400 + 441 = 84143.6028°
9, 404181 + 1600 = 168112.6804°
1, 11.41421361 + 1 = 245.0000°
1, 1.732050821 + 3 = 430.0000°
4, 1212.649110616 + 144 = 16018.4349°

The last row is a 4-in-12 roof pitch. Every integer row can be scaled by any factor and still works as a squaring check — 12-16-20 is the 3-4-5 row times four.

Mistakes that produce a wrong length or a false square

  • Adding the legs instead of their squares. a + b is always larger than c. For 3 and 4 that gives 7 rather than 5.
  • Forgetting the square root. The formula produces c². Reporting 164 instead of 12.806 is a common slip on the last step.
  • Applying it to a triangle with no right angle. The identity holds only at 90°. Anywhere else you need the law of cosines.
  • Treating a leg as the hypotenuse. The hypotenuse is always the longest side and always opposite the right angle. Subtracting in the wrong order gives the root of a negative number.
  • Squaring a large layout with a small triple. A 3-4-5 check on a 20-foot form multiplies your tape error into the corner angle. Use the largest triple the space allows.
  • Measuring a diagonal across a slope. Slope distance exceeds plan distance, so a level-plane square corner will read as obtuse. Measure horizontally or correct for the grade.

Where the theorem leads next

The theorem generalises in two directions worth knowing. Sideways, into the law of cosines: c² = a² + b² − 2ab·cos C, which reduces to Pythagoras when C = 90° and quantifies the departure otherwise. Upwards, into three dimensions: the diagonal of a rectangular box is √(l² + w² + h²), which is the theorem applied twice, and the 3D distance calculator does exactly that.

For a complete right triangle including both angles, the altitude to the hypotenuse and the inradius, use the right triangle calculator. Two right triangles turn up so often that they have their own tools: the 30-60-90 triangle calculator and the 45-45-90 triangle calculator, whose side ratios are 1 : √3 : 2 and 1 : 1 : √2.

The theorem also produced the first known irrational number. Set both legs to 1 and the hypotenuse is √2, which cannot be written as a ratio of whole numbers — a discovery attributed to the Pythagorean school itself and one that forced Greek mathematics to separate number from magnitude. Every diagonal of a square you measure is a physical instance of it. For coordinate work, the same identity becomes the distance formula, and in trigonometry it becomes the identity sin²θ + cos²θ = 1, which is just the theorem applied to a right triangle with a hypotenuse of one.

Frequently asked questions

How do I find the hypotenuse?

Square both legs, add them, and take the square root: c = √(a² + b²). For legs of 8 and 10 that is √164 = 12.8062. The hypotenuse is always longer than either leg and always shorter than the two added together.

How do I find a missing leg?

Subtract rather than add: a = √(c² − b²). With a hypotenuse of 13 and one leg of 5, that is √(169 − 25) = √144 = 12. The hypotenuse must be the larger of the two numbers, or the expression under the root goes negative and no triangle exists.

How do I check that a corner is square with a tape measure?

Mark 3 units along one side and 4 along the other from the corner, then measure between the marks. Exactly 5 means the corner is 90°. Any multiple works, so 6-8-10 or 12-16-20 is better on a large layout because tape error affects the angle less over a longer baseline.

What does it mean if my diagonal is longer than the calculated value?

The corner is obtuse — more than 90° — and the frame needs closing up. A shorter-than-calculated diagonal means the corner is acute and the frame needs opening. The calculator reports the exact diagonal a square corner would require, which is the target to rack the frame to.

What is a Pythagorean triple?

Three whole numbers satisfying a² + b² = c², such as 3-4-5, 5-12-13, 8-15-17 and 7-24-25. Every primitive triple comes from a = m² − n², b = 2mn, c = m² + n² with coprime m > n of opposite parity. They are useful because the checking arithmetic is exact.

Does the theorem work on any triangle?

No, only on right triangles. For any other triangle use the law of cosines, c² = a² + b² − 2ab·cos C, which adds a correction term that is zero exactly when the angle is 90°. The sign of a² + b² − c² tells you which side of a right angle the triangle sits on.

How do I find the diagonal of a box or a room in three dimensions?

Apply the theorem twice: d = √(l² + w² + h²). For a 3 by 4 by 12 box that is √(9 + 16 + 144) = √169 = 13. The first application gives the floor diagonal, and the second combines that with the height.

Why is the diagonal of a square irrational?

Because with both legs equal to 1 the hypotenuse is √2, and no fraction of whole numbers squares to exactly 2. This was the Pythagoreans' own discovery and the first known irrational number. Every square you measure has a diagonal 1.4142136 times its side, a ratio that never terminates.

References

  • Euclid's Elements, Book I, Propositions 47 and 48 — Public domain
  • CRC Standard Mathematical Tables and Formulae, 33rd ed. — CRC Press
  • The Pythagorean Proposition — Elisha Scott Loomis, National Council of Teachers of Mathematics