The law of cosines gives the relationship between the side lengths of a triangle and the cosine of any of its angles.

In this tutorial, we’ll look at the law of cosines – a critical concept when it comes to solving triangles.

But before we dive into the law, here’s a quick summary of the convention we use to denote angles and side-lengths in a triangle.

The key idea is the length of each side is represented by the small case version of the letter for the opposite angle.

For example, the angle opposite to the side $\hspace{0.2em} AB \hspace{0.2em}$ is angle $\hspace{0.2em} C \hspace{0.2em}$. So the side and its length are represented by $\hspace{0.2em} c \hspace{0.2em}$.

It says –

$a^2 = b^2 + c^2 - 2bc \, \cos A$

We can re-frame the formula above for other sides/angles.

$\begin{align*} b^2 = a^2 + c^2 - 2ac \, \cos B \\[1em] c^2 = a^2 + b^2 - 2ab \, \cos C \end{align*}$

Now, the most common use cases for the law of cosines are –

- to find a side (length), when the other two sides and their included angle is known, or
- to find an angle if all three sides are known.

For cases where we need to find angles using the cosine rule, the three formulas can be rearranged as –

$\begin{align*} \cos A \, = \, \frac{b^2 + c^2 - a^2}{2bc} \\[1.5em] \cos B \, = \, \frac{a^2 + c^2 - b^2}{2ac} \\[1.5em] \cos C \, = \, \frac{a^2 + b^2 - c^2}{2ab} \end{align*}$

The law of cosines is also known as the cosine rule.

To prove the cosine law, we will make use of the following figure.

In $\hspace{0.2em} \triangle ABD \hspace{0.2em}$,

$\begin{align*} \cos A \, \, &= \, \, \frac{r}{b} \\[1em] r \, \, &= \, \, b \, \cos A \hspace{0.25cm} \rule[0.1cm]{1cm}{0.1em} \hspace{0.15cm} (1) \end{align*}$

Also, in the same triangle,

$\begin{align*} \sin B \, \, &= \, \, \frac{h}{b} \\[1em] h \, \, &= \, \, b \, \sin B \hspace{0.25cm} \rule[0.1cm]{1cm}{0.1em} \hspace{0.15cm} (2) \end{align*}$

In $\hspace{0.2em} \triangle ADC \hspace{0.2em}$,

$\begin{align*} a^2 \, \, &= \, \, h^2 + (c - r)^2 \\[1em] a^2 \, \, &= \, \, h^2 + c^2 + r^2 - 2 \cdot c \cdot r \end{align*}$

Substituting the values of $\hspace{0.2em} r \hspace{0.2em}$ and $\hspace{0.2em} h \hspace{0.2em}$ from equations $\hspace{0.2em} (1) \hspace{0.2em}$ and $\hspace{0.2em} (2) \hspace{0.2em}$, we have

And that’s it. We just proved the law of cosines.

In the last three steps, we factored out $\hspace{0.2em} b^2 \hspace{0.2em}$ from two terms (in red) and then made use of the following trigonometric identity –

${\color{Red} \sin^2 A + \cos^2 A} \, \, = \, \, 1$

Alright, now it’s time to cement our understanding of the law of cosines and learn how to use it to solve triangles.

Note – In most cases, we need to use the sine rule along with the cosine rule to solve triangles. However, since the focus of this tutorial is on the cosine rule, we will only use examples that do not need the sine rule.

Also, in the following examples, I would encourage you to pay special attention to how the cosine rule is being used in the solution and not worry too much about how to solve triangles.

Example

Solve the triangle below for the missing sides and angles.

Solution

Here are the steps to solve this triangle.

Step 1. Use the Cosine Rule to find the missing side

When we have two sides and the included angle, the law of cosines allows us to find the third side.

Applying the cosine rule for side b,

$\begin{align*} a^2 \, \, &= \, \, b^2 + c^2 - 2bc \, \cos A \\[1em] &= \, \, 10^2 + 6^2 - 2 \cdot 10 \cdot 6 \, \cos 88 \degree \\[1em] &\approx \, \, 131.81 \end{align*}$

Taking the square root on both sides

$a \, \, \approx \, \, 11.48$

Step 2. Use the Cosine Rule for one of the remaining angles

Using the law of cosines (arranged for angles),

$\begin{align*} \cos B \, &= \, \frac{a^2 + c^2 - b^2}{2ac} \\[1.3em] &\approx \, \frac{6^2 + 11.48^2 - 10^2}{2 \cdot 6 \cdot 11.48} \\[1.3em] &\approx \, 0.4921 \end{align*}$

Taking cos inverse on both sides,

$B \, \approx \, 60.52 \degree$

Step 3. Finally, we can use the "Sum of Angles" property to find $\hspace{0.2em} \angle C \hspace{0.2em}$,

$\begin{align*} A + B + C \, \, &= \, \, 180 \degree \\[1em] 88 \degree + 60.52 \degree + C \, \, &\approx \, \, 180 \degree \\[1em] C \, \, &\approx \, \, 31.48 \degree \end{align*}$

Example

The sides of a triangle measure 5, 8, and 9. Find the measure of its angles.

Solution

This time, the question doesn't contain the drawing. So, let's start by drawing a rough sketch of the triangle and labeling the information given in the question. It’s not necessary but often makes things easier and helps avoid silly mistakes.

Step 1. Use the Cosine Rule to find the largest angle

When we know all the side lengths, we can use the cosine rule to find any of the angles. But it’s best to start with the largest angle – the angle opposite to the longest side. Why?

Because if there is an obtuse angle $\hspace{0.2em} (> 90 \degree) \hspace{0.2em}$ in the triangle, it has to be this angle. The other two angles must be acute. And that’s useful to know when using the sine rule.

Here the largest angle would be $\hspace{0.2em} A \hspace{0.2em}$. So let’s work on that.

$\begin{align*} \cos A \, &= \, \frac{b^2 + c^2 - a^2}{2bc} \\[1.3em] &= \, \frac{5^2 + 8^2 - 9^2}{2 \cdot 5 \cdot 8} \\[1.3em] &= \, 0.1 \end{align*}$

Taking cos inverse on both sides, we have

$A \, \approx \, 84.26 \degree$

Step 2. Use the Cosine Rule for another angle

Because this is a tutorial on the law of cosines, here we are using it to find this angle. However, in general, I would suggest using the sine rule. It involves simpler calculations, and so is less error-prone.

$\begin{align*} \cos B \, &= \, \frac{a^2 + c^2 - b^2}{2ac} \\[1.3em] &= \, \frac{9^2 + 8^2 - 5^2}{2 \cdot 9 \cdot 8} \\[1.3em] &\approx \, 0.8333 \end{align*}$

Again, taking cos inverse on both sides, we have

$B \, \approx \, 33.56 \degree$

Step 3. Finally, we can use the "Sum of Angles" property to find $\hspace{0.2em} \angle C \hspace{0.2em}$,

$\begin{align*} A + B + C \, \, &= \, \, 180 \degree \\[1em] 84.26 \degree + 33.56 \degree + C \, \, &\approx \, \, 180 \degree \\[1em] C \, \, &\approx \, \, 62.18 \degree \end{align*}$

And that brings us to the end of this tutorial on the law of cosines. Until next time.

We use cookies to provide and improve our services. By using the site you agree to our use of cookies. Learn more