Solve with the law of cosines
Solved from two sides and the angle between them (SAS).
| Part | Value | Exact |
|---|---|---|
| Side a given | 5 | |
| Side b given | 8 | |
| Side c | 7 | |
| Angle A | 38.2132° | |
| Angle B | 81.7868° | |
| Angle C given | 60° | |
| Area | 17.3205 | 10√3 |
| Perimeter | 20 | |
| Semiperimeter s | 10 | |
| Height to a (h_a) | 6.9282 | 4√3 |
| Height to b (h_b) | 4.3301 | 5√3/2 |
| Height to c (h_c) | 4.9487 | 20√3/7 |
| Inradius r | 1.7321 | √3 |
| Circumradius R | 4.0415 | 7√3/3 |
Working
- Law of cosines. c² = a² + b² − 2ab cos C = 5² + 8² − 2 × 5 × 8 × cos 60° = 49, so c = √49 = 7
- Law of cosines. cos A = (b² + c² − a²) / (2bc) = (8² + 7² − 5²) / (2 × 8 × 7) = 0.785714 (exactly 11/14), so A = arccos(0.785714) = 38.2132°
- Angle sum. B = 180° − C − A = 180° − 60° − 38.2132° = 81.7868°
- Perimeter. a + b + c = 5 + 8 + 7 = 20
- Heron's formula. s = (a + b + c)/2 = 10; area = √(s(s − a)(s − b)(s − c)) = √(10 × 5 × 2 × 3) = 17.3205 (exactly 10√3)
- Area from two sides. ½ab sin C = ½ × 5 × 8 × sin 60° = 17.3205, the same area
- Heights. h = 2 × area / base: h_a = 6.9282, h_b = 4.3301, h_c = 4.9487
- Inradius and circumradius. r = area / s = 1.7321; R = a / (2 sin A) = 4.0415
The law of cosines
For any triangle, c² = a² + b² − 2ab cos C. Angle C sits between sides a and b, and c is the side facing it.
The same rule works from each corner, so a² = b² + c² − 2bc cos A and b² = a² + c² − 2ac cos B as well.
When C = 90°, cos C = 0 and the last term vanishes, leaving c² = a² + b². Pythagoras is the right-angled case. The extra term corrects for the angle: an obtuse C makes cos C negative and c longer, and an acute C makes c shorter.
The two ways round
| You know | Case | Formula |
|---|---|---|
| Two sides and the angle between them | SAS | c = √(a² + b² − 2ab cos C) |
| Three sides | SSS | cos C = (a² + b² − c²) / 2ab, then C = arccos of that |
Worked example: two sides and the angle between
a = 5, b = 8 and C = 60°. Since cos 60° = ½, c² = 25 + 64 − 2 × 5 × 8 × ½ = 89 − 40 = 49, and c = 7 exactly.
Now all three sides are known, so the law of cosines can find another angle. cos A = (8² + 7² − 5²) / (2 × 8 × 7) = 88/112, and A = 38.2132°. Then B = 180° − 60° − 38.2132° = 81.7868°.
The area is ½ab sin C = ½ × 5 × 8 × √3/2 = 10√3, about 17.3205.
Worked example: an obtuse angle
b = 3, c = 5 and A = 120°. cos 120° = −½, so the last term turns into an addition. a² = 9 + 25 + 15 = 49 and a = 7.
That's a neat fact. The triangle with sides 3, 5 and 7 has a 120° angle, and the area is 15√3/4.
With a = 12, b = 15 and C = 110°, the cosine isn't a tidy number. c² = 144 + 225 − 360 cos 110° = 369 + 123.1273 = 492.1273, so c = 22.1839.
Worked example: three sides
Sides 4, 5 and 8. Start with the largest angle, C, facing the longest side. cos C = (16 + 25 − 64) / 40 = −0.575, and C = 125.0996°. A negative cosine means the angle is obtuse.
Then cos A = (25 + 64 − 16) / 80 = 0.9125, A = 24.1468°, and B = 30.7535° from the angle sum.
Why the largest angle first? The arccos of any number from −1 to 1 lands between 0° and 180°, so cosine never mixes up an obtuse angle with its acute partner. The law of sines can, and once the largest angle is settled the other two must be acute.
A little history
Euclid's Elements, from around 300 BC, has the rule in geometric form as Propositions 12 and 13 of Book II, one for obtuse triangles and one for acute. There's no cosine in it. It talks of squares and rectangles on the sides.
The Persian mathematician Jamshīd al-Kāshī gave it in a form fit for trigonometric tables in his Miftāḥ al-ḥisāb of 1427. In France it's still called le théorème d'Al-Kashi.
Questions
When do I use the law of cosines?
When you know three sides, or two sides and the angle between them. In both cases the law of sines has no matched side and angle to start from.
How do I find an angle with it?
Rearrange to cos C = (a² + b² − c²) / 2ab, then take arccos. Sides 7, 8 and 9 give cos A = 2/3 and A = 48.1897°.
Is the law of cosines the same as Pythagoras?
It's a broader version. Put C = 90° and cos C = 0, and it becomes c² = a² + b².
Why did I get a negative cosine?
The angle is obtuse. cos C is negative for any angle between 90° and 180°.
Why does the calculator say the sides don't make a triangle?
The two shorter sides must add up to more than the longest. Sides 2, 3 and 6 fail, since 2 + 3 is less than 6, and the cosine would come out below −1.
Sources
Added and reviewed . What's new
