trigonometry

Law of Cosines

The law of cosines generalises the Pythagorean theorem to any triangle: c² = a² + b² − 2ab cos(C). Use for SSS or SAS triangle problems.

The law of cosines generalises the Pythagorean theorem to any triangle:

c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C

where cc is the side opposite angle CC, and a,ba, b are the other two sides. Symmetrically: a2=b2+c22bccosAa^2 = b^2 + c^2 - 2bc\cos A, b2=a2+c22accosBb^2 = a^2 + c^2 - 2ac\cos B.

Special case: when C=90°C = 90°, cos90°=0\cos 90° = 0, and the formula collapses to c2=a2+b2c^2 = a^2 + b^2 — the Pythagorean theorem.

Use cases:

  • SSS: given three sides, find an angle: cosC=a2+b2c22ab\cos C = \frac{a^2 + b^2 - c^2}{2ab}.
  • SAS: given two sides and the included angle, find the third side directly.

Companion to the law of sines asinA=bsinB=csinC\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}. 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: uv=uvcosθ\vec{u} \cdot \vec{v} = |\vec{u}||\vec{v}|\cos\theta.