What is the law of cosines?
In triangle ABC, side a faces angle A, side b faces B and side c faces C. Angle C sits between sides a and b.
The law of cosines (also called the cosine rule) says:
c² = a² + b² − 2ab cos C
The same pattern works for every side:
- a² = b² + c² − 2bc cos A
- b² = a² + c² − 2ac cos B
Pattern: the side on the left faces the angle on the right.
Pythagoras is a special case
When C = 90°, cos C = 0, so the last term vanishes and c² = a² + b². That is Pythagoras.
- C bigger than 90° (obtuse): cos C is negative, so −2ab cos C is positive. c² is more than a² + b².
- C smaller than 90° (acute): cos C is positive, so c² is less than a² + b².
This gives a quick test for the type of triangle from its sides: compare c² with a² + b² for the longest side c.
Why it is true: the proof
Put C at the origin and side b along the x-axis, so A = (b, 0). Point B is a distance a from C at angle C, so B = (a cos C, a sin C).
Side c is the distance from A to B:
c² = (a cos C − b)² + (a sin C)²
= a² cos² C − 2ab cos C + b² + a² sin² C
= a²(cos² C + sin² C) + b² − 2ab cos C
= a² + b² − 2ab cos C, because cos² C + sin² C = 1.
The proof works for any angle C, acute or obtuse.
Solving triangles: SAS and SSS
Two sides and the angle between them (SAS)
Put the numbers straight in: a = 5, b = 8, C = 60° gives c² = 25 + 64 − 80 × 0.5 = 49, so c = 7.
Three sides (SSS)
Rearrange to find an angle: cos C = (a² + b² − c²) ÷ 2ab. Find the largest angle first (facing the longest side); then the others are acute and you can safely use the sine rule.
Sides 5, 7, 8: cos C = (25 + 49 − 64) ÷ 70 ≈ 0.143, so C ≈ 81.8°.
Sine rule or cosine rule?
- Complete side–angle pair known → sine rule.
- SAS or SSS → cosine rule.
Exam tips and uses
- Square first, then subtract: (a² + b² − 2ab cos C), and only take the square root at the end.
- A negative cosine means an obtuse angle. Inverse cosine on a calculator gives it correctly (0° to 180°), so SSS never has an ambiguous case.
- If a² + b² − c² gives cos C outside −1 to 1, the three lengths cannot make a triangle.
- Uses: navigation (distance between ships), surveying land, robot arms, finding the angle between two vectors.
Key formulas and definitions
- c² = a² + b² − 2ab cos C
- a² = b² + c² − 2bc cos A; b² = a² + c² − 2ac cos B
- cos C = (a² + b² − c²) ÷ 2ab
- C = 90° → c² = a² + b² (Pythagoras)
- c² > a² + b² → C obtuse; c² < a² + b² → C acute
Worked examples
1. a = 5, b = 8, C = 60°. Find c.
c² = 25 + 64 − 2 × 5 × 8 × cos 60° = 89 − 80 × 0.5 = 49. c = 7.
2. a = 4, b = 6, C = 120°. Find c.
cos 120° = −0.5. c² = 16 + 36 − 2 × 4 × 6 × (−0.5) = 52 + 24 = 76. c = √76 ≈ 8.72.
3. Sides are 5, 7 and 8. Find the largest angle.
Largest angle faces 8. cos C = (25 + 49 − 64) ÷ (2 × 5 × 7) = 10 ÷ 70 ≈ 0.1429. C ≈ 81.8°.
4. Sides are 3, 5 and 7. Is the triangle acute, right or obtuse? Find the largest angle.
7² = 49 and 3² + 5² = 34. 49 > 34, so obtuse. cos C = (9 + 25 − 49) ÷ 30 = −0.5, so C = 120°.
5. Two ships leave a port. One sails 30 km and the other 40 km, on courses 70° apart. How far apart are they?
d² = 30² + 40² − 2 × 30 × 40 × cos 70° = 900 + 1600 − 2400 × 0.3420 = 2500 − 820.8 = 1679.2. d ≈ 41.0 km.
6. A parallelogram has sides 6 cm and 10 cm with an angle of 60° between them. Find both diagonals.
Short diagonal: d² = 36 + 100 − 120 × cos 60° = 76, d ≈ 8.72 cm. Long diagonal uses the angle 120°: d² = 136 − 120 × (−0.5) = 196, d = 14 cm.
7. Sides 2, 3 and 6. Is this a triangle?
cos C = (4 + 9 − 36) ÷ 12 = −1.92, which is less than −1. Impossible, so no triangle (also 2 + 3 < 6).
Common mistakes
- Using an angle that is not between the two known sides. In c² = a² + b² − 2ab cos C, angle C must be between a and b.
- Doing (a² + b² − 2ab) × cos C. Only the 2ab term is multiplied by cos C.
- Dropping the minus sign with an obtuse angle: −2ab × (−0.5) = +ab, which adds.
- Forgetting to take the square root at the end: c² = 49 means c = 7, not 49.