The law of cosines generalises the Pythagorean theorem to any triangle:
where is the side opposite angle , and are the other two sides. Symmetrically: , .
Special case: when , , and the formula collapses to — the Pythagorean theorem.
Use cases:
- SSS: given three sides, find an angle: .
- SAS: given two sides and the included angle, find the third side directly.
Companion to the law of sines . Together they handle all four triangle-solving cases (SSS, SAS, ASA, AAS) — only SSA (the ambiguous case) requires extra care.
The law of cosines is also the geometric origin of the dot product in vector analysis: .