The Pythagorean Theorem and Law of Cosines: When Each One Applies
The Law of Cosines is the Pythagorean theorem generalized to any triangle — here's exactly how the extra term appears, and why it vanishes at 90 degrees.
Published July 12, 2026
The Pythagorean theorem is the tool everyone learns first for triangle side calculations, but it only works for right triangles — the Law of Cosines extends the identical underlying idea to any triangle at all, and seeing exactly how is more useful than memorizing them as two unrelated formulas.
The Pythagorean theorem, and its one restriction
a² + b² = c²
c is the hypotenuse, always opposite the right angle. Right triangles only.
For a right triangle, a² + b² = c², where c is the hypotenuse (always the longest side, always opposite the right angle) and a, b are the two legs. This relationship is exact and reliable — but only for genuine right triangles. Applying it to a triangle without a 90° angle produces a wrong answer, since the formula’s derivation depends specifically on that right angle.
The Law of Cosines: the same formula, plus one term
c² = a² + b² − 2ab·cos(C)
Works for any triangle; collapses to the Pythagorean theorem when C = 90°.
The Law of Cosines states c² = a² + b² - 2ab·cos(C), where C is the angle between sides a and b. Compare this directly to the Pythagorean theorem: it’s identical, with one additional term, -2ab·cos(C). When C is exactly 90°, cos(90°) = 0, and that entire extra term vanishes — the Law of Cosines collapses exactly into the Pythagorean theorem, confirming it as the true generalization, not a separate, coincidentally-similar formula.
| Triangle type | Use | Extra term |
|---|---|---|
| Right triangle (C = 90°) | Pythagorean theorem | None — vanishes since cos(90°) = 0 |
| Any other triangle | Law of Cosines | −2ab·cos(C) |
What that extra term actually does
For an acute included angle (under 90°), cosine is positive, so the extra term subtracts from a²+b² — the resulting side comes out shorter than a right-angle triangle with the same a and b would give, matching the geometric intuition that a “pinched,” sharper-than-90° angle pulls the opposite side in closer. For an obtuse angle (over 90°), cosine is negative, so the term effectively adds instead — the opposite side stretches out longer, matching a wider, more “open” angle pushing that side further away.
Choosing the right tool
If you know you’re working with a right triangle, the Pythagorean theorem is the simpler, faster tool — no need for trigonometry at all. If the triangle isn’t a right triangle, or you’re not certain, the Law of Cosines works universally, correctly handling the right-triangle case too as its built-in special case. A quick way to check which applies: if you know two sides and the angle between them, and that angle isn’t stated (or confirmed) to be 90°, the Law of Cosines is the safe default.
Solving a triangle directly
The Pythagorean Theorem Calculator solves for any missing side of a right triangle — hypotenuse or either leg. The Law of Cosines Calculator handles the general case, any triangle, given two sides and the included angle. For finding a triangle’s area rather than a missing side, the Triangle Area Calculator uses Heron’s formula directly from all three known side lengths.
Related calculators
Pythagorean Theorem Calculator with Steps
Find any missing side of a right triangle — hypotenuse or leg — from the other two, using a² + b² = c².
Law of Cosines Calculator for Triangles
Find a triangle's third side from two sides and the included angle — the Law of Cosines, generalizing the Pythagorean theorem to any triangle.
Triangle Area Calculator
Find a triangle's area from its three side lengths, using Heron's formula — no angle or height measurement required.