The Law of Cosines

The law of cosines is a general equation relating three sides and one angle in a triangle. There are no restrictions on the triangle's shape. Three elements determine a triangle. If any three of the four elements in the law-of-cosines equation are given, the equation allows you to calculate the fourth one.

The diagram in Figure 1 below illustrates a general triangle. The three sides are labeled a, b, c, and the three angles are labeled a, b, g.

Figure 1

There are three law-of-cosines equations, depending on which angle is included:

c2 = a2 + b2 - 2ab cos g (1a)

a2 = b2 + c2 - 2bc cos a (1b)

b2 = c2 + a2 - 2ca cos b . (1c)

Note that the Pythagorean theorem is a special case of these equations, if one of the angles is equal to 90o. E.g., if g = 90o, then cos g = 0 and Equation (1a) reduces to the Pythagorean theorem,

c2 = a2 + b2 . (2)

Also note the minus sign in front of the cosine term in these equations. This has the following effect. Let's consider Equation (1a). If g < 90o, the cosine is positive. With the minus sign in front of the cosine term, Equation (1a) therefore gives a value for c that is less than the value given by the Pythagorean theorem (2). If g > 90o, the cosine is negative. Combined with the minus sign in front of the cosine term, the term now makes a posiitive contribution to the right-hand side of Equation (1a) yielding a value of c that is greater than the one given by the Pythagorean theorem.