# Cosine Rule (Law of Cosines)

The **cosine rule**, also known as the **law of cosines**, relates all 3 sides of a triangle with an angle of a triangle.

It is most useful for solving for missing information in a triangle. For example, if all three sides of the triangle are known, the cosine rule allows one to find any of the angle measures. Similarly, if two sides and the angle between them is known, the cosine rule allows one to find the third side length.

#### Contents

## Statement and Proof of the Theorem

Given the following triangle \(ABC\) with corresponding sides length \(a\), \(b\), and \(c\),

the **law of cosines** states that:

\[\begin{align} a^2&=b^2+c^2-2bc \cdot \cos A\\ b^2&=a^2+c^2-2ac \cdot \cos B\\ c^2&=a^2+b^2-2ab \cdot \cos C. \end{align}\]

It can be seen as a generalization of the Pythagorean theorem. Take one arbitrary side of the triangle, for instance, \(a\). Then its square equals the sum of the squares of the other two sides, i.e. \(a^2 = b^2 + c^2\). Since the angle \(\alpha\) that faces our arbitrary side \(a\) is not necessarily \(90°\), we will have to subtract something, as the identity \(a^2 = b^2 + c^2\) does not hold yet. The right side of this equation is still "too big." That something we have to subtract becomes \(2bc \cdot \cos A\).

We'll prove for side \(a\). Let's denote its facing angle as \(\alpha\). The other two equations can be done in a similar way.

By definition we have \[\begin{align} \sin \alpha &= \frac{h}{c} \implies h = c \cdot \sin \alpha \\ \cos \alpha &= \frac{r}{c} \implies r = c \cdot \cos \alpha. \end{align}\] Using the Pythagorean theorem, we get \[a^2 = h^2 + (b-r)^2.\] Substituting for \(h\) and \(r\), we get \[\begin{align} a^2 &= (c \cdot \sin \alpha)^2 + (b - c \cdot \cos \alpha)^2 \\ &= c^2 \cdot \sin^2 \alpha + b^2 - 2bc \cdot \cos \alpha + c^2 \cdot \cos^2 \alpha \\ &= c^2 \cdot \big( \sin^2 \alpha + \cos^2 \alpha \big) + b^2 - 2bc \cdot \cos \alpha\\ &= c^2 + b^2 - 2bc \cdot \cos \alpha.\ _\square \end{align}\]

Note:

The identity \(\sin^2 \alpha + \cos^2 \alpha = 1\) is also known as the Pythagorean identity.

This proof isn't perfect. We should have been worried about angles. This can be avoided by usingdirected angles.

Let \( \vec{a} \cdot \vec{b} \) denote the dot product between \(\vec{a}\) and \(\vec{b}\).

Also, let \( \vec{a} = \vec {BC}\), \( \vec{b} = \vec {AC}\), and \( \vec{c} = \vec {AB}\).

Then \[c^2 = \vec{c} \cdot \vec{c} = (\vec{b} - \vec{a}) \cdot (\vec{b} - \vec{a}) = b^2 + a^2 - 2\vec{a} \cdot \vec{b} = b^2 + a^2 - 2ab\cos C.\ _\square\]

## Finding Missing Side Lengths and Angles

**Given side-angle-side:**

In triangle \( ABC\), we have \( \angle BAC = \frac {\pi}{4}, \lvert \overline{BC} \rvert = \sqrt{5}\) and \( \lvert \overline{AB} \rvert = 3\). Determine \( \lvert \overline{AC} \rvert\).

Applying the cosine rule on \( \angle BAC\), we get

\[\begin{align} \lvert \overline{AB} \rvert^2 + \lvert \overline{AC} \rvert^2 - 2 \lvert \overline{AB} \rvert \cdot \lvert \overline{AC} \rvert \cdot \cos \frac {\pi}{4} &= \lvert \overline{BC} \rvert^2\\ \lvert \overline{AC} \rvert^2 - 3 \sqrt{2} \lvert \overline{AC} \rvert + 4 &=0 \\ \left(\lvert \overline{AC} \rvert-\sqrt{2}\right)\left(\lvert \overline{AC} \rvert-2\sqrt{2}\right)&=0. \end{align}\]

Hence, \( \lvert \overline{AC} \rvert=\sqrt{2} \text{ or } 2\sqrt{2}\). \( _\square \)

Note: This is similar to the 'ambiguous case' of sine rule, since we have \( 3 \sin \frac {\pi}{4} < \sqrt{5} < 3\), which is the condition \( c \sin \alpha < a < c\).

In triangle \( ABC\), \(\angle ACB = 90^\circ \). \(A, D, E,\) and \(B\) are consecutive points on \(AB\) such that \(\overline{AD}=\overline{DE}=\overline{EB}\). If there exists \( \theta\) such that \( \overline{CD} = 5 \cos \theta\) and \(\overline{CE} = 5 \sin \theta \), what is \(\overline{AB}^2?\)

**Given side-side-side:**

In triangle \(ABC\), \(\overline{AB} = \sqrt{6} - \sqrt{2}, \overline{AC} = 2\sqrt{2},\) and \(\overline{BC} = 2\sqrt3.\) Find the measure of \(\angle ABC.\)

Applying the law of cosines on side \(AC,\) we get

\[\begin{align} {\overline{AC}}^2 &= {\overline{AB}}^2 + {\overline{BC}}^2 - 2 \cdot \overline{AB} \cdot \overline{BC} \cdot \cos {\angle ABC} \\\\ {\big(2\sqrt{2}\big)}^2 &= {\big(\sqrt{6} - \sqrt{2}\big)}^2+ {\big(2\sqrt3\big)}^2 - 2\cdot 2\sqrt3 \cdot \big(\sqrt{6} - \sqrt{2}\big) \cdot \cos {\angle ABC}\\\\ 8 &= 6 - 4\sqrt{3} + 2 + 12 - \big(12\sqrt{2} - 4\sqrt{6}\big)\cos{\angle ABC}\\\\ -12 +4\sqrt{3} &= (-12\sqrt{2}+4\sqrt{6})\cos{\angle ABC}\\\\ \cos{\angle ABC} &=\dfrac{-12 +4\sqrt{3}}{-12\sqrt{2}+4\sqrt{6}} \\\\ &=\dfrac{1}{\sqrt2} \cdot \dfrac {-12 +4\sqrt{3}}{-12+4\sqrt{3}} =\dfrac{\sqrt2}{2}\\\\ \Rightarrow \angle ABC &= \dfrac{\pi}{4}.\ _\square \end{align}\]

Try the following problem:

## Applications to Bearing and Heading Problems

See: Bearing

## Vector Form of Cosine Rule

We have \[\begin{align} \vec{c}^{2} &= \vec{a}^{2} + \vec{b}^{2} - 2 \cdot \vec{a} \cdot \vec{b}\\ &= \vec{a}^{2} - 2 \cdot \vec{a} \cdot \vec{b} + \vec{b}^{2} \\ &= \big(\vec{a} - \vec{b}\big)^2. \end{align} \]

## Deriving Other Laws Using the Cosine Rule

- Triangle Inequality
- Pythagorean Theorem

From the cosine rule, we have

\[c^2 \leq a^2 + b^2 + 2ab = (a+b)^2,\]

and by taking the square root of both sides, we have \(c \leq a + b\), which is also known as the

triangle inequality. One useful application of the triangle inequality is to test if three given lengths can define a triangle.

The Pythagorean theorem applies to right triangles, so let \(\gamma \) be a right angle, i.e., \(\gamma = \frac{\pi}{2}\). Then by the cosine rule,

\[ c^2 = a^2 + b^2 - 2ab \cos \gamma = a^2 + b^2 - 2ab \cos \frac{\pi}{2} = a^2 + b^2 - 0 = a^2 + b^2.\]

## Suppose \( a, b,\) and \( c\) are positive reals such that \( a^2 = b^2+c^2 - bc, b^2 = c^2 + a^2 - ac,\) and \( c^2 = a^2 + b^2 - ab\). Show that \( a = b = c\).

Since \( c^2 = a^2 + b^2 - ab < a^2 + b^2 + 2ab = (a+b)^2\), it follows that \( c < a+b\) and we have similar inequalities for other variables. Hence, the numbers \( a, b\) and \( c\) satisfy the triangle inequality, and there exists a triangle \( ABC\) such that \( \lvert \overline{AB} \rvert=c, \lvert \overline{BC} \rvert=a, \lvert \overline{CA} \rvert=b\). As such

\[ \cos \angle ABC = \frac {a^2 + c^2 - b^2}{2ac} = \frac {a^2 + c^2 - (a^2+c^2-ac)}{2ac} = \frac {1}{2},\]

which gives us that \( \angle ABC = 60^\circ\). Similarily, we have \( \angle BCA = 60^\circ\) and \(\angle CAB = 60^\circ\), which show that triangle \( ABC\) is equilaterial, implying that \( a=b=c\). \( _\square \)

Note:This may also be done directly by summing up the 3 equations to get \( (a-b)^2 + (b-c)^2 + (c-a)^2 =0\).

The figure above shows an isosceles triangle \(ABC\) with \(BA = AC \) and \(\angle BAC = 120^\circ\).

Let \(D\) be a point on \(AC\) such that \(AD > DC\). Given that the lengths of \(BA\), \(AD\), \(DC\), and \(BD\) are all distinct prime numbers, what is the length of \(BD\)?

## Problem Solving

## See Also

**Cite as:**Cosine Rule (Law of Cosines).

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/cosine-rule/