Article

Pythagorean Theorem: Formula, Examples and Calculator

The Pythagorean theorem links the three sides of a right triangle through a² + b² = c². Below you will find a clear explanation, four worked examples and answers to common questions, and you can check your own numbers in the Pythagorean theorem calculator.

Last updated:

Once you know all three sides, you can find the area of the triangle, the distance between two points or the roof pitch angle.

The formula: a² + b² = c²

The Pythagorean theorem applies only to right triangles, that is, triangles with one angle of 90°. The two shorter sides are called the legs (a and b), and the longest side, opposite the right angle, is the hypotenuse (c). The sum of the squares of the legs equals the square of the hypotenuse.

a² + b² = c²
c = √(a² + b²)
a = √(c² − b²)
b = √(c² − a²)

Side to findFormulaExample
c (hypotenuse)√(a² + b²)a = 3, b = 4 → c = 5
a (leg)√(c² − b²)c = 10, b = 8 → a = 6
b (leg)√(c² − a²)c = 10, a = 6 → b = 8

The formula holds only when the angle between sides a and b is 90°. For other triangles you need the law of cosines.

Right triangle with sides a, b and cRight triangle with legs a = 3 and b = 4 and hypotenuse c = 5. The right angle lies between sides a and b.a = 3b = 4c = 590°
The 3-4-5 triangle: legs a and b form the right angle and the hypotenuse c lies opposite it. Check: 3² + 4² = 25 = 5².

Try it with an example

The example below shows how to find the hypotenuse from two legs. The values are already stored in the link to the calculator.

Side to find
c
a
7
b
9
Result
c = √130 ≈ 11.4018

Open the calculator with these numbers

The calculator reads the values from the page address and shows the result right away. You can change them freely.

How the calculator works

The calculator finds one of the three sides (c, a or b) from the other two and assumes that the angle between sides a and b is a right angle. It requires positive lengths, and when you solve for a leg it rejects data in which the hypotenuse is not longer than the other side. The result has no unit, so enter all lengths in the same unit.

How to find the hypotenuse or a missing leg

If you know both legs, square each one, add the results and take the square root of the sum. For a = 3 and b = 4 the sum of squares is 9 + 16 = 25, and the square root of 25 is 5.

If you know the hypotenuse and one leg, subtract the square of the known leg from the square of the hypotenuse, then take the square root of the difference. The difference must be positive, because the hypotenuse is always longer than either leg.

In the calculator you choose which side to find and enter the other two. Besides the result you see the squares of the sides and a check that a² + b² really equals c².

The result is often not a whole number. For a = 1 and b = 1 the hypotenuse is √2 ≈ 1.4142. You can take the square root of any non-negative number in the square root calculator; the operation itself is explained in the article Square Root: How to Calculate It.

Pythagorean triples: sides that are whole numbers

A Pythagorean triple is a set of three positive integers that satisfy a² + b² = c². The most common ones are 3-4-5, 5-12-13, 8-15-17 and 7-24-25. Every multiple of a triple is also a triple; for example, 6-8-10 comes from doubling 3-4-5.

abcCheck a² + b²
3459 + 16 = 25
5121325 + 144 = 169
8151764 + 225 = 289
7242549 + 576 = 625
681036 + 64 = 100

The 3-4-5 triple is useful on a building site. If you measure 3 ft along one wall and 4 ft along the other, and the distance between those marks is exactly 5 ft, the corner is a right angle.

45-45-90 and 30-60-90 triangles

Two right triangles appear in problems especially often because their sides have fixed ratios. One known side is enough to find the others.

TriangleSide ratioHypotenuseExample
45-45-90 (half a square)a : a : a√2c = a · √2a = 5 → c ≈ 7.0711
30-60-90 (half an equilateral triangle)x : x√3 : 2xc = 2xx = 1 → 1; 1.7321; 2

A 45-45-90 triangle is what remains when a square is cut along its diagonal, so the diagonal of a square with side a equals a√2. For a square with a side of 5 ft the diagonal is 5 · √2 ≈ 7.07 ft. To verify the result, enter a = 5 and b = 5 in the calculator.

A 30-60-90 triangle is half of an equilateral triangle cut along its height. The shorter leg lies opposite the 30° angle and equals half the hypotenuse, and the longer leg is √3 times the shorter one. The Pythagorean theorem confirms it immediately: 1² + (√3)² = 1 + 3 = 4 = 2².

The converse: how to tell whether a triangle is a right triangle

The converse of the theorem tells you whether a triangle with three known sides has a right angle. Let c be the longest side. If a² + b² = c², the triangle is a right triangle. If a² + b² > c², all angles are acute, and if a² + b² < c², one angle is obtuse.

Sides a, b, ca² + b²c²Type of triangle
6, 8, 1036 + 64 = 100100right
4, 5, 616 + 25 = 4136acute
2, 3, 44 + 9 = 1316obtuse

The calculator assumes a right angle and does not test whether one exists. To use it as a check, enter the two shorter sides and compare the result with the third side. For 4 and 5 you get c ≈ 6.4031, which is more than 6, so the triangle with sides 4, 5 and 6 is acute rather than right.

Where the Pythagorean theorem is used

Diagonal of a rectangle or room. A room measuring 5 m by 12 m has a diagonal of 13 m. If you also need the floor area, use the rectangle area calculator.

Roofs and rafters. The length of a roof slope follows from the horizontal run and the rise. You can check the angle in the roof pitch angle calculator.

Stairs. The length of a stair stringer is the hypotenuse of a triangle whose legs are the total rise and the horizontal run. The height of a single step comes from the stair calculator.

Distance on a plane. The distance between points (x₁, y₁) and (x₂, y₂) is the hypotenuse of a triangle with legs |x₂ − x₁| and |y₂ − y₁|. The distance between two points calculator returns the result directly.

Area of a right triangle. The area is half the product of the legs, so a 3-4-5 triangle has an area of 6. Other cases are handled by the triangle area calculator; the rules are described in the article Area of a Triangle: Formula and Worked Examples.

Quick comparison of results

Side to findKnownResult
ca = 3, b = 45
ca = 5, b = 1213
ca = 7, b = 9√130 ≈ 11.40
ac = 10, b = 86
bc = 10, a = 68

Four worked examples

You can repeat each example in the Pythagorean theorem calculator.

1. Hypotenuse for a = 3 and b = 4

The classic 3-4-5 triangle.

  1. Choose the mode in which you look for side c.
  2. Enter a = 3 and b = 4.
  3. Square the legs: 3² = 9 and 4² = 16, and the sum is 25.
  4. The square root of 25 gives c = 5.

2. Leg a for c = 10 and b = 8

You know the hypotenuse and one leg.

  1. Choose the mode in which you look for side a.
  2. Enter c = 10 and b = 8.
  3. Compute c² − b² = 100 − 64 = 36.
  4. The square root of 36 gives a = 6; check: 6² + 8² = 100.

3. Diagonal of a 5 m by 12 m room

The diagonal of a rectangle is the hypotenuse of a triangle with legs 5 m and 12 m.

  1. Enter a = 5 and b = 12.
  2. The sum of squares is 25 + 144 = 169.
  3. The square root of 169 gives c = 13 m.
  4. This is the 5-12-13 triple, so the result is a whole number.

4. Triangle with legs 1 and 1

An example where the result is irrational.

  1. Enter a = 1 and b = 1.
  2. The sum of squares is 1 + 1 = 2.
  3. The square root of 2 gives c ≈ 1.4142.
  4. In practice you round the result to the precision you need, for example to the nearest millimeter.

Common mistakes with the Pythagorean theorem

  • Treating any side as the hypotenuse — c is always the longest side, opposite the right angle. When you solve for a or b and the hypotenuse is not longer than the leg, the calculator reports an error.
  • Using the formula in a non-right triangle — for other triangles use the law of cosines or Heron’s formula.
  • Adding sides instead of squares — 3 + 4 = 7, but the hypotenuse is 5, because you add 3² and 4².
  • Forgetting the square root — the sum of squares gives c², not c. The last step is always a square root.
  • Subtracting in the wrong order — when you look for a leg, subtract the square of the known leg from c², not the other way round.
  • Mixing units — all sides must use the same unit, for example meters or feet.
  • Rounding too early — round only the final result, because earlier rounding increases the error.

Frequently asked questions

How do you find the hypotenuse?

Use c = √(a² + b²). For legs 3 and 4 the sum of squares is 25, so c = 5.

How do you find a leg when you know the hypotenuse?

Use a = √(c² − b²). For c = 10 and b = 8 you get √36 = 6.

Does the Pythagorean theorem work for every triangle?

No. The formula a² + b² = c² is true only for right triangles. For other triangles use the law of cosines.

What are Pythagorean triples?

They are sets of three positive integers that satisfy a² + b² = c², such as 3-4-5, 5-12-13, 8-15-17 and 7-24-25. Multiples of a triple also satisfy the equation.

What are the sides of a 30-60-90 triangle?

The sides are in the ratio x : x√3 : 2x, where x is the shorter leg opposite the 30° angle. The hypotenuse is twice the shorter leg, and the longer leg equals x · √3. For x = 1 the sides are 1, 1.7321 and 2.

How do you find the diagonal of a square?

The diagonal of a square with side a is d = a · √2, because it is the hypotenuse of a triangle with legs a and a. For a side of 5 you get d = 5 · √2 ≈ 7.0711.

How can you check for a right angle on a building site?

Measure 3 ft and 4 ft from a corner along the two edges. If the distance between the endpoints is exactly 5 ft, the angle is a right angle. Multiples such as 6, 8 and 10 ft work as well.

How can you tell whether a triangle is a right triangle?

Call the longest side c and compare a² + b² with c². If they are equal, the triangle is a right triangle. For sides 6, 8 and 10 we have 36 + 64 = 100 = 10², so there is a right angle. For sides 4, 5 and 6 the sum of squares is 41, which is more than 36, so the triangle is acute.

Check your own side lengths

The Pythagorean theorem calculator finds a missing side in seconds: choose the side you want, enter the two known lengths and read the result together with the check.

Once you have all three sides, the next steps are the triangle area, the area from Heron’s formula or the third side of a non-right triangle with the law of cosines.