Law of cosines

Fig. 1 – A triangle. The angles α (or A), β (or B), and γ (or C) are respectively opposite the sides a, b, and c.

In trigonometry, the law of cosines (also known as the cosine formula or cosine rule or Al-Kashi’s theorem) 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.