Pythagorean Theorem Calculator
Results
Formulas Used in Pythagorean Theorem Calculator
Full formula reference: Pythagorean Theorem · Right Triangle Formulas
In-Depth Tutorial: Pythagorean Theorem Calculator
The Pythagorean Theorem is the single most useful relationship in plane geometry: in any right triangle, the sum of the squares of the two legs equals the square of the hypotenuse. Stated as a formula: a² + b² = c², where a and b are the legs (the two sides forming the right angle) and c is the hypotenuse (the side opposite the right angle, always the longest). This tutorial covers how to use the theorem to find any missing side, recognize the most common Pythagorean triples, and apply the theorem in three dimensions and on coordinate planes.
What the theorem says — and why it works
The Pythagorean Theorem appears as Proposition I.47 in Euclid's Elements (around 300 BCE) but the result was known to Babylonian mathematicians more than a thousand years earlier — clay tablets from ~1800 BCE list dozens of integer Pythagorean triples (sets where a, b, c are all whole numbers).
The theorem only applies to right triangles. If your triangle does not have a 90° angle, you need the more general Law of Cosines (which reduces to a² + b² = c² when the included angle is 90°, because cos 90° = 0).
One of the cleanest geometric proofs: place four copies of the right triangle inside a square of side (a + b), arranged so the hypotenuses form an inner square. The inner square has area c². The outer square has area (a + b)² = a² + 2ab + b². Subtracting the four triangles (each with area ab/2, total 2ab) from the outer square: c² = (a² + 2ab + b²) − 2ab = a² + b². QED.
Three ways to use the theorem
Depending on which side you know and which you need, the formula rearranges:
- Find the hypotenuse (you know both legs): c = √(a² + b²).
- Find leg a (you know leg b and hypotenuse): a = √(c² − b²).
- Find leg b (you know leg a and hypotenuse): b = √(c² − a²).
In the leg formulas, the value inside the square root must be positive — if you ever get a negative number under the radical, you have given the calculator an impossible triangle (a leg longer than the hypotenuse, which cannot happen by definition).
Example 1 — Finding the hypotenuse
Input: a = 3, b = 4. Compute: c² = 3² + 4² = 9 + 16 = 25. c = √25 = 5.
This is the most famous of all triangles: the 3-4-5 right triangle. Carpenters and builders use it to lay out perfect right angles — measure 3 units along one edge, 4 units perpendicular, and the diagonal will be exactly 5 units only if the corner is truly square.
Example 2 — Finding a leg
Input: c = 13, a = 5. Compute: b² = 13² − 5² = 169 − 25 = 144. b = √144 = 12.
This is the 5-12-13 triangle — another integer triple. Notice that we subtract; the leg formula is the rearranged theorem.
Pythagorean triples — sets of integer solutions
A "Pythagorean triple" is a set of three positive integers (a, b, c) with a² + b² = c². The first few primitive triples (where gcd(a, b, c) = 1):
- 3-4-5 (the foundational one)
- 5-12-13
- 8-15-17
- 7-24-25
- 20-21-29
- 9-40-41
Any multiple of a primitive triple is also a triple: 6-8-10 (= 2 × 3-4-5), 10-24-26 (= 2 × 5-12-13), 9-12-15 (= 3 × 3-4-5), and so on. Recognizing a triple in a problem lets you skip the square root step entirely — if the legs are 3 and 4, you know without computing that the hypotenuse is 5.
The 3D extension
The Pythagorean Theorem extends naturally to three dimensions. If a rectangular box has edge lengths a, b, and c, then the length of the space diagonal d (from one corner to the opposite corner) is:
d = √(a² + b² + c²)
Proof: the diagonal of the bottom face is √(a² + b²) by the standard theorem. Then the space diagonal is the hypotenuse of a right triangle whose legs are that face diagonal and the height c. Applying the theorem again: d² = (a² + b²) + c². See the 3D Pythagorean Theorem Calculator for problems with box-shaped diagonals.
The distance formula on a coordinate plane
The distance between two points P₁ = (x₁, y₁) and P₂ = (x₂, y₂) is also a direct application of the theorem. Treat the horizontal difference |x₂ − x₁| as one leg and the vertical difference |y₂ − y₁| as the other leg of a right triangle whose hypotenuse is the distance:
distance = √((x₂ − x₁)² + (y₂ − y₁)²)
This formula is the entire foundation of coordinate geometry. Every distance, every magnitude, every Euclidean norm in any dimension is a generalization of a² + b² = c².
Verifying that a triangle is a right triangle
If you have all three side lengths, the theorem becomes a test: plug them in and check whether a² + b² = c² (where c is the longest side). If yes, the triangle is right. If a² + b² > c², the triangle is acute (all angles less than 90°). If a² + b² < c², the triangle is obtuse (one angle greater than 90°). This is the Converse of the Pythagorean Theorem.
Common mistakes
- Confusing the hypotenuse with a leg. The hypotenuse is always the longest side, always opposite the right angle. If a problem says "the longest side is 10" and you plug 10 into a leg field, every answer comes out wrong.
- Forgetting to square-root at the end. The theorem gives c², not c. To get c, take the square root after summing the squared legs.
- Trying to apply to non-right triangles. If there is no 90° angle, a² + b² ≠ c² — you need the Law of Cosines instead.
- Mixing units. All three sides must be in the same unit. You cannot have legs in inches and a hypotenuse in centimeters.
Beyond geometry
The Pythagorean Theorem reaches far beyond plane geometry. The same formula computes vector magnitudes in physics (the magnitude of a velocity vector with components (vx, vy) is √(vx² + vy²)), the modulus of complex numbers (|a + bi| = √(a² + b²)), and the Euclidean distance in any number of dimensions. It is also the geometric origin of the trigonometric identity sin²θ + cos²θ = 1 (a Pythagorean triple on the unit circle).
Frequently Asked Questions – Pythagorean Theorem Calculator
Enter any two of the three sides (a, b, c). The missing side is calculated using c² = a² + b² (or rearranged to find a leg).
The hypotenuse (c) is always the longest side — it is opposite the right angle. It satisfies c² = a² + b².
Enter all three sides. If a² + b² = c² (within rounding tolerance), the triangle is a right triangle.
Yes. After finding the missing side it gives both acute angles (tan A = a / b), plus the area (½ab), the perimeter and the height to the hypotenuse (ab / c).
Enter all three sides. By the converse of the Pythagorean theorem, the triangle is right when a² + b² = c² for the longest side c; if c² is smaller it is acute, and if it is larger it is obtuse.
3-4-5, 5-12-13, 8-15-17, 7-24-25 and 20-21-29, plus any multiple of them such as 6-8-10 or 9-12-15. If your sides match one, the missing side is a whole number.
Yes. Enter one side and angle A (the angle opposite leg a). The calculator uses sine, cosine and tangent: for a hypotenuse of 10 and A = 30°, leg a = 10 · sin 30° = 5 and leg b = 10 · cos 30° ≈ 8.6603.
Yes — free and unlimited.
The theorem has more proofs than any other in mathematics
Elisha Scott Loomis's 1907 book The Pythagorean Proposition collected 370 distinct proofs of a² + b² = c². New ones still appear — including one published by future US president James A. Garfield in 1876, five years before he took office. Garfield's proof is short enough to reproduce in two sentences: form a trapezoid by stacking two copies of the right triangle (legs a and b, hypotenuse c) plus an isoceles right triangle (legs both c) along a common edge. Compute the area two ways — as a trapezoid (a+b)(a+b)/2 and as the sum of three triangles ab/2 + ab/2 + c²/2 — set them equal, and out falls a² + b² = c².
The similar-triangles proof is the one most modern textbooks present. Drop an altitude from the right angle to the hypotenuse, splitting the original right triangle into two smaller triangles, each similar to the original. The ratios of corresponding sides give a/c = (a's projection on c)/a and the analogous statement for b. Adding the two projection lengths gives c, and the algebra collapses to the theorem in three lines. Albert Einstein wrote a version of this proof at age 11; it appears in his autobiographical notes.
The flexibility matters because each proof reveals something different about why the relationship holds. Garfield's says it's an area-of-trapezoid identity. The similar-triangles proof says it's a statement about how perpendicular projections decompose lengths. Dissection proofs say it's a fact about cutting and rearranging squares. All three are correct simultaneously — and that's why the theorem keeps showing up in physics, linear algebra, and number theory under different names.
Pythagoras probably didn't discover it
Historians of mathematics are skeptical that Pythagoras himself proved the theorem now attached to his name. The earliest hard evidence of the relationship is Babylonian clay tablet Plimpton 322, dated to around 1800 BCE — more than 1,200 years before Pythagoras lived. The tablet lists 15 sets of integers that satisfy a² + b² = c², including non-trivial cases like (3367, 3456, 4825); this strongly suggests the Babylonians knew the relationship and had a systematic way to generate triples.
Chinese mathematics encoded the same theorem as the gōugŭ rule (勾股定理) in the Zhoubi Suanjing, with derivations dated to roughly the same period as Euclid. The Indian Sulba Sutras (c. 800–500 BCE) use the relationship to construct altars whose dimensions guarantee right angles. Modern usage of "Pythagorean theorem" reflects the influence of Euclid's Elements on European mathematics rather than priority of discovery.
The computational gotcha: don't compute √(a² + b²) naively
For most calculator inputs the straightforward formula sqrt(a*a + b*b) is fine. It breaks in two cases that come up in scientific computing:
When a or b is very large, squaring it can overflow the floating-point range even though the final hypotenuse is representable. A leg of 10^200 squares to 10^400, which exceeds the largest representable double (~1.8 × 10^308), so a*a returns infinity and the answer is lost. A leg of 10^160 with another of 10^160 should give a hypotenuse around 1.4 × 10^160 — well in range — but the naive formula overflows first.
When a or b is very small, the same issue happens in the other direction (underflow to zero). For typical geometry problems this almost never matters because side lengths fit comfortably in a few digits, but engineers analyzing astronomical distances or sub-atomic separations do hit it.
The fix is the hypot(a, b) function, present in essentially every modern math library (including JavaScript's Math.hypot). It rescales the inputs before squaring so the intermediate result stays in range, then unscales the final answer. The mathematical output matches sqrt(a² + b²) exactly within rounding error; the difference is only in the numerical robustness.
One more thing the theorem is not
Does the Pythagorean theorem work on a sphere?
No — and the way it fails is informative. On a sphere, the analog of a right triangle is a spherical triangle with one 90° angle, whose sides are arcs of great circles measured in radians. The relationship is cos(c) = cos(a)·cos(b) (a special case of the spherical Law of Cosines). For small triangles (sides much shorter than the sphere's radius), expanding the cosines in a Taylor series and dropping high-order terms recovers a² + b² ≈ c². So the planar Pythagorean theorem is the "flat-space limit" of the spherical relationship, which is why it works fine for room-sized measurements on Earth but starts to fail by miles when you measure across whole continents.
Why does the theorem produce integer triples at all? Is that a coincidence?
No, it's a number-theoretic structure. Every primitive triple (a, b, c) with gcd(a, b, c) = 1 can be generated by Euclid's formula: pick two coprime integers m > n > 0 with one even and one odd, and set a = m² − n², b = 2mn, c = m² + n². For m = 2, n = 1 this gives (3, 4, 5); m = 3, n = 2 gives (5, 12, 13); m = 4, n = 1 gives (15, 8, 17). The formula generates every primitive triple exactly once, so the "list of Pythagorean triples" is an infinite but well-understood family, not a random collection of coincidences.
If a calculator says my triangle is right but my measurements were rounded, how much error should I tolerate?
Use the rule that the tolerance on a² + b² − c² scales with how precisely you measured the longest side. If you measured to the nearest millimeter and the longest side is around 100 mm, then c² has uncertainty roughly 2·c·Δc = 2·100·1 = 200 mm². So |a² + b² − c²| < 200 mm² means your measurements are consistent with a right triangle. If the difference is many times larger than that, the triangle is not right — the error is too big to blame on the ruler.