Follow these steps to derive the law of cosines.

1. The relationship between the side lengths in ABD is
c2 = x2 + h2 by the .

2. The relationship between the side lengths in CBD is
a2 = (bx)2 + h2 by the .

3. The equation a2 = (bx)2 + h2 is to become
a2 = b2 − 2bx + x2 + h2.

4. Using the equation from step 1, the equation
a2 = b2 − 2bx + x2 + h2 becomes a2 = b2 − 2bx + c2
by .

5. In ABD, the trigonometric function = #&\frac {x}{c}#&.

6. Multiply both sides of the equation in step 5 by
to get x = c cos(A).

7. Substitute for the variable x in the equation
a2 = b2 − 2bx + c2 to produce a2 = b2 − 2bc cos(A) + c2.

8. The law of cosines is obtained by the previous equation.
a2 = b2 + c2 − 2bc cos(A)

bx