# Law of Cosines

The Law of Cosines (also known as the Cosine Rule) allows to find the length of the third side of a triangle knowing two other sides and the angle between them.

## Theorem (Law of Cosines)

Consider a triangle with the sides *a*, *b*, *c* and angles *α*, *β*, *γ*.

The Law of Cosines states that

where \(\gamma\) denotes the angle between the sides \(a\) and \(b.\)

The sides \(a\) and \(b\) can also be expressed in terms of two other sides and angle between them:

When the angle \(\gamma\) between the sides \(a\) and \(b\) is a right angle, the Law of Cosines reduces to the Pythagorean Identity:

So the law of cosines is a generalization of the Pythagorean Theorem for an arbitrary triangle.

### Proof

We consider separately the cases of acute and obtuse triangles.

In the first case, assume that the angle \(\gamma\) is an acute angle.

Draw the altitude \(BD\) from the vertex \(B\) to the side \(AC = b.\) Its height \(h\) can be found from the trigonometric identity for the right triangle \(BDC:\)

The line segment \(CD\) (the projection of side \(a\) onto the side \(b\)) has the length

In the right traingle \(ADB,\) the side \(AD\) is given by

Using the Pythagorean Identity for \(\triangle ADB\), we get:

Notice that

Therefore

Let now the angle \(\gamma\) be obtuse.

In this case, the altitude \(BD = h\) is given by

By the reduction identity, \(\sin \left( {180^\circ - \gamma } \right) = \sin \gamma .\) Hence, the height \(h\) is expressed by the same formula:

Again, by the reduction identity, the length of the line segment \(CD\) is given by

From the right triangle \(ADB,\) we have

Similarly, the Law of Cosines can be proved for two other sides of the triangle.