HomeMath & AlgebraPythagorean Theorem Calculator
Math & Algebra

Pythagorean Theorem Calculator

Calculate a right triangle hypotenuse from two positive same-unit legs, with four-decimal results, worked examples, limits, and cited guidance.

pythagorean-theorem-calculator
Hypotenuse (c)

Formula: c = √(a² + b²)

Enter two positive leg lengths in the same unit. The hypotenuse is returned in that unit and rounded to four decimal places.

The Pythagorean Theorem Calculator finds the hypotenuse of a right triangle from its two legs. Enter two positive leg lengths in the same unit. The hypotenuse is returned in that unit and rounded to four decimal places. Select Calculate after entering or changing either leg.

With legs 3 and 4, the calculator returns 5.0000. With legs 1.5 and 2, it returns 2.5000. Both examples use the relationship between the two perpendicular legs and the side opposite the right angle.

How to Use the Pythagorean Theorem Calculator

  1. Enter a positive finite length for leg a.
  2. Enter a positive finite length for leg b in the same unit.
  3. Select Calculate.
  4. Read hypotenuse c in the shared input unit, displayed to four decimal places.

Zero, negative, blank, nonnumeric and non-finite entries are rejected with an accessible field error. Changing either input clears the earlier result until the calculation runs again. The widget does not impose an arbitrary maximum inside the browser's finite numeric range.

Pythagorean Formula and Worked Examples

c = √(a² + b²)

For a right triangle, a and b are the perpendicular legs and c is the hypotenuse. The OpenStax Prealgebra 2e discussion of triangles and the Pythagorean theorem states that the sum of the squares of the leg lengths equals the square of the hypotenuse.

For legs 3 and 4, c = √(3² + 4²) = √25 = 5, so the display is 5.0000. For decimal legs 1.5 and 2, c = √(1.5² + 2²) = √6.25 = 2.5, so the display is 2.5000.

The same relationship underlies coordinate distance. Use the Distance Calculator for two points, or the Square Root Calculator when you only need the principal square-root step.

Input Limits, Overflow, Rounding and Related Tools

The exact Lingo Jam runtime evaluates the equivalent calculation with Math.hypot(a, b). MDN's Math.hypot reference explains why direct intermediate squaring can overflow or underflow and why a careful hypotenuse implementation avoids that intermediate loss.

Two finite legs of 1e200 still produce a finite hypotenuse of about 1.414213562373095e200 even though directly squaring either input exceeds the finite range. If the mathematical hypotenuse itself exceeds the browser's finite range, as it does for two Number.MAX_VALUE legs, the widget clears the result and shows an accessible calculation error.

Results are displayed to four decimal places using standard browser floating-point arithmetic. Display rounding does not add precision. Keep both leg measurements in the same unit; mixing units makes the numerical result meaningless.

Use the Slope Calculator for rise over run. To find a rectangle diagonal from its length and width, use the Rectangle Diagonal Calculator.

Frequently asked questions

What formula does the Pythagorean Theorem Calculator use?

It uses c = √(a² + b²), where a and b are the perpendicular legs of a right triangle and c is the hypotenuse.

How do I calculate the hypotenuse manually?

Square each positive leg length, add the two squares, and take the principal square root. For legs 3 and 4, √(3² + 4²) = 5.

Can I use this calculator for a non-right triangle?

No. This formula applies to right triangles. A non-right triangle requires other information and a different relationship such as the law of cosines.

Which measurement units should I use?

Use one consistent unit for both positive leg lengths. The returned hypotenuse has that same unit; for example, two centimeter inputs produce a centimeter result.

Can I enter zero, a negative number or a decimal?

Positive finite decimals are supported. Zero, negative, blank, nonnumeric and non-finite values are rejected with a field error.

How are large values and overflow handled?

The runtime uses Math.hypot so large finite legs such as 1e200 avoid false intermediate overflow. If the true hypotenuse is non-finite, the result is cleared and an accessible calculation error is shown.

How are Pythagorean calculator results rounded?

The hypotenuse is displayed to four decimal places using browser floating-point arithmetic. Display rounding does not create additional measurement precision.