Law of cosines
Theorem. If $ABC$ is a triangle with the angle $\gamma$ at the vertex $C$ and with the sides lengths $a = \overline{BC}, b= \overline{AC}$ and $c= \overline{AB}$ (see the figure below), then
\[
c^2 = a^2 + b^2 - 2ab \cos \gamma.
\]
Proof. In the proof below we use the Pythagorean theorem twice and the definition of $\cos \gamma = x/a$;
$\displaystyle
c^2
$ |
$\displaystyle
=
y^2 + h^2
$ |
(by Pythagorean theorem $c^2 = y^2+h^2$) |
|
$\displaystyle
= (b-x)^2 + h^2
$ |
(by the identity $b = x + y$) |
|
$\displaystyle
=
b^2 -2bx + x^2 + h^2 \
$ |
(algebra) |
|
$\displaystyle
= a^2 + b^2 - 2bx
$ |
(by Pythagorean theorem $a^2 = h^2 + x^2$) |
|
$\displaystyle
= a^2 + b^2 - 2ab\dfrac{x}{a}
$ |
(algebra) |
|
$\displaystyle
= a^2 + b^2 - 2ab\cos \gamma
$ |
(the definition of $\cos \gamma$) |
This completes the proof.
Remark. Why is the law of cosines important in a linear algebra class? Here is why. Introduce two vectors in the above figure:
\[
\vec{a} = \vec{CB}, \qquad \vec{b} = \vec{CA}.
\]
Then, $a^2 = \bigl\|\vec{a}\bigr\|^2$, $b^2 = \bigl\|\vec{b}\bigr\|^2$ and \[
\vec{b} - \vec{a} = \vec{BA}.
\]
The last equality implies
\begin{align*}
c^2 & = \| \vec{b} - \vec{a} \|^2 \\
& = \bigl(\vec{b} - \vec{a} \bigr) \cdot \bigl(\vec{b} - \vec{a} \bigr) \\
& = \vec{b} \cdot \vec{b} - 2 \vec{a} \cdot \vec{b} + \vec{a} \vec{a} \\
& = \bigl\|\vec{b}\bigr\|^2 - 2 \vec{a} \cdot \vec{b} + \bigl\|\vec{a}\bigr\|^2 \\
& = a^2 + b^2 - 2 \vec{a} \cdot \vec{b}.
\end{align*}
Now compare the last equality and the law of cosines:
\begin{align*}
c^2 & = a^2 + b^2 - 2 \vec{a} \cdot \vec{b}, \\
c^2 &= a^2 + b^2 - 2ab \cos \gamma.
\end{align*}
We deduce that
\[
\vec{a} \cdot \vec{b} = ab \cos \gamma = \bigl\|\vec{a}\bigr\| \, \bigl\|\vec{b}\bigr\| \cos \gamma.
\]
This gives us a geometric interpretation of the dot product.