This article is about the trigonometric identity. For the cosine law of optics, see Lambert's cosine law.
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: