✕
The Law of Cosines
The Law of Cosines generalizes the Pythagorean theorem to any triangle, not just right triangles. For a triangle with sides a, b, c and angle C opposite side c:
c² = a² + b² − 2ab·cos(C)
The same relationship holds for any vertex: swap in that vertex's angle and the two sides touching it.
Special case: right triangles
When C = 90°, cos(C) = 0, so the correction term vanishes and the formula collapses exactly to a² + b² = c² — the Pythagorean theorem. Try dragging a vertex to a right angle and watch the correction term shrink to 0.
Why the sign flips
Cosine is positive for acute angles and negative for obtuse ones. So when the reference angle is acute, the correction subtracts a positive amount and a² + b² > c². When it's obtuse, cos is negative, the correction adds, and a² + b² < c². That's exactly the >/< you see in the comparison row above.
Solving triangles
Rearranged as cos(C) = (a² + b² − c²) / (2ab), this lets you find an unknown angle from three known sides (SSS) — it's literally how this tool reconstructs the triangle when you type in a, b, c. Given two sides and the angle between them (SAS), the original form solves directly for the missing side.
A classic example
a = 5, b = 7, c = 8: cos(C) = (25 + 49 − 64)/70 = 10/70 ≈ 0.143, so C ≈ 81.8°. Try typing those values in.
A bit of history
Euclid's Elements (Book II, Propositions 12–13) gave geometric versions of this rule for obtuse and acute triangles around 300 BCE — long before trigonometric cosine notation existed. The explicit trigonometric form is often credited to the 15th-century Persian astronomer Jamshīd al-Kāshī, and in French it's still called Théorème d'Al-Kashi .