# Trigonometry/Law of Cosines

## Law of Cosines

The Pythagorean theorem is a special case of the more general theorem relating the lengths of sides in any triangle, the law of cosines:[1]

${\displaystyle a^{2}+b^{2}-2ab\cos(\theta )=c^{2}}$

where ${\displaystyle \theta }$ is the angle between sides ${\displaystyle a}$ and ${\displaystyle b}$ .

### Does the formula make sense?

This formula had better agree with the Pythagorean Theorem when ${\displaystyle \theta =90^{\circ }}$ .

So try it...

When ${\displaystyle \theta =90^{\circ }}$ , ${\displaystyle \cos(\theta )=\cos(90^{\circ })=0}$

The ${\displaystyle -2ab\cos(\theta )=0}$ and the formula reduces to the usual Pythagorean theorem.

## Permutations

For any triangle with angles ${\displaystyle A,B,C}$ and corresponding opposite side lengths ${\displaystyle a,b,c}$ , the Law of Cosines states that

${\displaystyle a^{2}=b^{2}+c^{2}-2bc\cdot \cos(A)}$
${\displaystyle b^{2}=a^{2}+c^{2}-2ac\cdot \cos(B)}$
${\displaystyle c^{2}=a^{2}+b^{2}-2ab\cdot \cos(C)}$

### Proof

Dropping a perpendicular ${\displaystyle OC}$ from vertex ${\displaystyle C}$ to intersect ${\displaystyle AB}$ (or ${\displaystyle AB}$ extended) at ${\displaystyle O}$ splits this triangle into two right-angled triangles ${\displaystyle AOC}$ and ${\displaystyle BOC}$ , with altitude ${\displaystyle h}$ from side ${\displaystyle c}$ .

First we will find the lengths of the other two sides of triangle ${\displaystyle AOC}$ in terms of known quantities, using triangle ${\displaystyle BOC}$ .

${\displaystyle h=a\sin(B)}$

Side ${\displaystyle c}$ is split into two segments, with total length ${\displaystyle c}$ .

${\displaystyle {\overline {OB}}}$ has length ${\displaystyle {\overline {BC}}\cos(B)=a\cos(B)}$
${\displaystyle {\overline {AO}}={\overline {AB}}-{\overline {OB}}}$ has length ${\displaystyle c-a\cos(B)}$

Now we can use the Pythagorean Theorem to find ${\displaystyle b}$ , since ${\displaystyle b^{2}={\overline {AO}}^{2}+h^{2}}$ .

 ${\displaystyle b^{2}}$ ${\displaystyle ={\bigl (}c-a\cos(B){\bigr )}^{2}+a^{2}\sin ^{2}(B)}$ ${\displaystyle =c^{2}-2ac\cos(B)+a^{2}\cos ^{2}(B)+a^{2}\sin ^{2}(B)}$ ${\displaystyle =a^{2}+c^{2}-2ac\cos(B)}$

The corresponding expressions for ${\displaystyle a}$ and ${\displaystyle c}$ can be proved similarly.

The formula can be rearranged:

${\displaystyle \cos(C)={\frac {a^{2}+b^{2}-c^{2}}{2ab}}}$

and similarly for ${\displaystyle cos(A)}$ and ${\displaystyle cos(B)}$ .

## Applications

This formula can be used to find the third side of a triangle if the other two sides and the angle between them are known. The rearranged formula can be used to find the angles of a triangle if all three sides are known. See Solving Triangles Given SAS.

## Notes

1. Lawrence S. Leff (2005-05-01). cited work. Barron's Educational Series. p. 326. ISBN 0764128922.