Law of Cosines

Category: Trigonometry   Level: 201

c2 = a2 + b2 - 2ab cos C

The law of cosines is the Pythagorean theorem with a correction term. The term −2ab cos C shrinks c when the angle C is acute and grows it when C is obtuse.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Start with two sides and the angle between

Sides a = 8 and b = 5 meet at the angle C = 60°. Find the third side c, across from C.

a = 8, b = 5, C = 60°, c = ?

Step 1: Start with two sides and the angle between

Step 2: Compare with a right angle

If C were 90°, the Pythagorean theorem gives c = √89 ≈ 9.43 (dashed). The real angle is smaller, so c is shorter. A correction term accounts for the difference.

C = 90° ⇒ c2 = a2 + b2 = 89

Step 2: Compare with a right angle

Step 3: Drop the height from A

The height h from A splits a into two pieces. The piece next to C has length b cos C, and h has length b sin C, both from SOH-CAH-TOA in the left triangle.

b cos C = 2.5, h = b sin C ≈ 4.33

Step 3: Drop the height from A

Step 4: Use Pythagoras on the right triangle

The right part of the picture is a right triangle with legs h and a − b cos C and hypotenuse c. Apply the Pythagorean theorem to it.

c2 = (b sin C)2 + (a - b cos C)2

Step 4: Use Pythagoras on the right triangle

Step 5: Expand and simplify

Expanding gives b² sin² C + b² cos² C, which is b² because sin² C + cos² C = 1. What remains is Pythagoras plus the correction term −2ab cos C.

c2 = a2 + b2 - 2ab cos C

Step 5: Expand and simplify

Step 6: Compute c

Put in the numbers. The correction 2ab cos C = 40 takes c² down from 89 to 49.

c2 = 64 + 25 - 2(8)(5)(1/2) = 49, c = 7

Step 6: Compute c

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render law-of-cosines --out /tmp/law-of-cosines

Source: svgmath/diagrams/trig_triangles.py