Hypotenuse of a Right Triangle

Calculates the hypotenuse of a right triangle with the Pythagorean theorem √(a² + b²).

In a right triangle, the side opposite the right angle is the hypotenuse, and it is always the longest of the three. Given the two legs that form the right angle, the Pythagorean theorem produces it.

c=a2+b2c = \sqrt{a^2 + b^2}

The theorem itself states a2+b2=c2a^2 + b^2 = c^2; taking the square root of both sides gives the formula above.

Example

With the defaults, a=3a = 3 and b=4b = 4:

c=32+42=9+16=25=5c = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5

The hypotenuse is 5. The triple 3, 4, 5 is the best known set of whole numbers that fits a right triangle exactly.

Watch out

The Pythagorean theorem holds for right triangles only, and aa and bb are the two legs, never the hypotenuse. If you know the hypotenuse cc and one leg aa and want the other leg, subtract instead: b=c2a2b = \sqrt{c^2 - a^2}. Note also that a2+b2\sqrt{a^2 + b^2} is not a+ba + b; in the example 3+4=73 + 4 = 7, while the true hypotenuse is 5. The hypotenuse is always longer than either leg on its own, and always shorter than the two legs added together.