Law of Cosines
If $A$, $B$, and $C$ are the angles of a triangle and $a$, $b$, and $c$ are the corresponding opposing side lengths, then the Law of Cosines states
\[a^2 = b^2 + c^2 - 2bc \cos(A) \\ b^2 = a^2 + c^2 - 2ac \cos(B) \\ c^2 = a^2 + b^2 - 2ab \cos(C)\]Interestingly, this gives us a set of formulas for the cosine of all the angles of a triangle given its side lengths.
Just like in the Law of Sines, we have to break the proof up into 3 cases: acute triangles, right triangles, and obtuse triangles.
Acute Triangles
Using the definition of $\sin$, the definition of $\cos$, and the Pythagorean Theorem, we have the following observations.
- $x + y = a$
- $x = c \cos B$
- $h = c \sin B$
- $y^2 + h^2 = b^2$
There are a couple of ways to do this. One way is to first substitute (1) into (4)
\[(a - x)^2 + h^2 = c^2\]Then substitute (2) and (3) into the above to get
\[(a - c \cos B)^2 + (c \sin B)^2 = b^2\]Now, we do some algebra to simplify and utilize the Pythagorean identity ($\cos^2 \theta + \sin^2 \theta = 1$)
\[\begin{align} b^2 &= (a - c \cos B)^2 + (c \sin B)^2 \\[10pt] &= a^2 - 2ac\cos B + c^2 \cos^2 B + c^2 \sin^2 B \\[10pt] &= a^2 + c^2 (\cos^2 B + \sin^2 B) - 2ac\cos B \\[10pt] &= a^2 + c^2 - 2ac\cos B \end{align}\]The argument works symmetrically for the other two laws.
Right Triangles
The right triangle case just reduces to the Pythagorean Theorem, which we have already proven to be true.
\[b^2 = a^2 + c^2 - 2ac \cos(90^{\circ}) = a^2 + c^2 - 2ac \cdot 0 = a^2 + c^2\]The proof for the other two angles is exactly the same as the acute triangle case.
Obtuse Triangles
Using the definition of $\sin$, the definition of $\cos$, the Pythagorean Theorem, and the supplementary angle identity for $\cos$, we have the following observations.
- $x = c \cos (180^{\circ} - B) = - c \cos B$
- $h = c \sin B$
- $(a + x)^2 + h^2 = b^2$
Substituting (1) and (2) into (3) gives
\[(c \cos B + a)^2 + (- c \sin B)^2 = b^2\]Now, we do some algebra to simplify and utilize the Pythagorean identity ($\cos^2 \theta + \sin^2 \theta = 1$)
\[\begin{align} b^2 &= (a - c \cos B)^2 + (c \sin B)^2 \\[10pt] &= a^2 - 2 ac \cos B + c^2 \cos^2 B + c^2 \sin^2 B \\[10pt] &= a^2 + c^2 (\cos^2 B + \sin^2 B) - 2 ac \cos B \\[10pt] &= a^2 + c^2 - 2 ac \cos B \end{align}\]The proof for the other two angles is exactly the same as the acute triangle case.
Vector Proof
If you are familiar with linear alebra and vectors, then the proof of the law of cosines becomes even easier. Let $\b{a}$, $\b{b}$, and $\b{c}$ denote the vector representation of the sides of the triangle.
Notice that I have carefully chosen the directions of the vectors such that $\b{b} = \b{a} - \b{c}$. Now, the proof just takes advantage of the properties of the dot product \(\displaystyle \boldsymbol{u} \cdot \boldsymbol{v} = \sum_{i=1}^n u_i v_i\) . In particular, distributivity \(\displaystyle \boldsymbol{u} \cdot ( \boldsymbol{v} + \boldsymbol{w} ) = \boldsymbol{u} \cdot \boldsymbol{v} + \boldsymbol{u} \cdot \boldsymbol{w}\) and commutativity \(\displaystyle \boldsymbol{u} \cdot \boldsymbol{v} = \boldsymbol{v} \cdot \boldsymbol{u}\) .
\[\begin{align} \abs{\b{b}}^2 &= \abs{\b{a} - \b{c}}^2 \\[10pt] &= (\b{a} - \b{c}) \cdot (\b{a} - \b{c}) \\[10pt] &= \b{a} \cdot \b{a} - \b{a} \cdot \b{c} - \b{c} \cdot \b{a} + \b{c} \cdot \b{c} \\[10pt] &= \abs{\b{a}}^2 + \abs{\b{c}}^2 - 2 (\b{a} \cdot \b{c}) \\[10pt] &= \abs{\b{a}}^2 + \abs{\b{c}}^2 - 2 \abs{\b{a}} \abs{\b{c}} \cos B \\[10pt] \end{align}\]