Law of cosines

In trigonometry, the law of cosines (also known as the cosine formula or cosine rule) relates the lengths of the sides of a triangle to the cosine of one of its angles. For a triangle with sides , , and , opposite respective angles , , and (see Fig. 1), the law of cosines states:

The law of cosines generalizes the Pythagorean theorem, which holds only for right triangles: if is a right angle then , and the law of cosines reduces to .

The law of cosines is useful for solving a triangle when all three sides or two sides and their included angle are given.