Subsection B.4.1 Cosine Law or Law of Cosines
¶The cosine law says that, if a triangle has sides of length \(a\text{,}\) \(b\) and \(c\) and the angle opposite the side of length \(c\) is \(\gamma\text{,}\) then
\begin{align*}
c^2 &= a^2+b^2 - 2ab\cos\gamma
\end{align*}
Observe that, when \(\gamma=\tfrac{\pi}{2}\text{,}\) this reduces to, (surpise!) Pythagoras' theorem \(c^2=a^2+b^2\text{.}\) Let's derive the cosine law.
Consider the triangle on the left. Now draw a perpendicular line from the side of length \(c\) to the opposite corner as shown. This demonstrates that
\begin{align*}
c &= a \cos \beta + b \cos \alpha\\
\end{align*}
Multiply this by \(c\) to get an expression for \(c^2\text{:}\)
\begin{align*} c^2 &= ac \cos \beta + bc \cos \alpha\\ \end{align*}Doing similarly for the other corners gives
\begin{align*} a^2 &= ac \cos \beta + ab \cos \gamma\\ b^2 &= bc \cos \alpha + ab \cos \gamma \end{align*}Now combining these:
\begin{align*}
a^2+b^2-c^2 &= (bc-bc) \cos \alpha + (ac-ac)\cos\beta + 2ab \cos \gamma\\
&= 2ab\cos \gamma
\end{align*}
as required.