Law of Cosines

Trigonometry

The law of cosines generalizes the Pythagorean theorem to any triangle, relating all three sides to the cosine of one of its angles.

Formula

c^2 = a^2 + b^2 - 2ab\cos(C)

Definition

The law of cosines is a formula for finding a missing side or angle in any triangle (not just right triangles). It says: $c^2 = a^2 + b^2 - 2ab\cos(C)$, where $C$ is the angle between sides $a$ and $b$.

Example

A triangle has sides $a = 7$, $b = 10$ with angle $C = 60^\circ$ between them. $c^2 = 49 + 100 - 2 \times 7 \times 10 \times \cos(60^\circ) = 149 - 140 \times 0.5 = 149 - 70 = 79$. So $c = \sqrt{79} \approx 8.89$.

Key Insight

When angle $C = 90^\circ$, $\cos(90^\circ) = 0$, and the formula becomes $c^2 = a^2 + b^2$, the Pythagorean theorem. The law of cosines is its generalization.

Definition

The law of cosines states $c^2 = a^2 + b^2 - 2ab\cos(C)$ for any triangle with sides $a$, $b$, $c$ and opposite angles $A$, $B$, $C$. Use it for SAS (two sides and included angle) to find the third side, or SSS (all three sides) to find angles via $\cos(C) = (a^2 + b^2 - c^2)/(2ab)$.

Example

SSS: $a = 6$, $b = 8$, $c = 9$. $\cos(C) = (36 + 64 - 81)/96 = 19/96 \approx 0.198$. $C = \arccos(0.198) \approx 78.6^\circ$. Then use the law of sines for the remaining angles.

Key Insight

The law of cosines encodes the "correction term" $-2ab\cos(C)$ that adjusts the Pythagorean theorem for non-right angles. When $C$ is obtuse, $\cos(C) < 0$, making $c^2$ larger than $a^2 + b^2$, which matches the geometric intuition that obtuse triangles have a longer third side.

Definition

The law of cosines follows from the dot product formula: $c^2 = |a - b|^2 = |a|^2 - 2a \cdot b + |b|^2$ where $a$ and $b$ are vectors, and $a \cdot b = |a||b|\cos(C)$. In the complex plane, it follows from $|z_1 - z_2|^2 = z_1\overline{z_1} - 2\text{Re}(z_1\overline{z_2}) + z_2\overline{z_2}$. In spherical trigonometry, the analogue is $\cos(c) = \cos(a)\cos(b) + \sin(a)\sin(b)\cos(C)$.

Example

The law of cosines gives the distance formula in $\mathbb{R}^2$: the distance between $(x_1,y_1)$ and $(x_2,y_2)$ can be derived by applying the law of cosines to the triangle formed by the origin and these two points, with $C = $ angle at origin.

Key Insight

The law of cosines is the metric identity in Euclidean geometry. In a general inner product space, it becomes $||u - v||^2 = ||u||^2 - 2\langle u,v \rangle + ||v||^2$, generalizing to arbitrary dimensions and serving as the foundation for Hilbert space geometry.