The Law of Cosines

GeometryGeometry Module 9: Right Triangles and TrigonometryGeometry and Trigonometry

Learn the law of cosines step by step with worked examples you can follow. Then practise with 37 instant-feedback questions. Free Geometry lesson from Mr Ahmed Hamouda.

Use the Law of Cosines to find a missing side from SAS, a missing angle from SSS, and to completely solve any right or nonright triangle.

Core Concepts

Why we need a second law

The Law of Sines needs a complete pair — an angle and the side directly across from it. If you are handed two sides and the angle squeezed between them (SAS), or all three sides and no angles at all (SSS), you never get such a pair, so the Law of Sines is useless. When the Law of Sines cannot be used to solve a triangle, the Law of Cosines may apply.

You can use the Law of Cosines to find the length of the third side of a triangle when the measures of two sides and the included angle are known, or to find the angle measures of a triangle if the lengths of all three sides are known.

Theorem 9.11 · Law of Cosines
If △ABC has lengths a, b, and c, representing the lengths of the sides opposite the angles with measures A, B, and C, then
a2 = b2 + c2 − 2bc·cos A
b2 = a2 + c2 − 2ac·cos B
c2 = a2 + b2 − 2ab·cos C
Read the pattern once and you never have to memorise three formulas: the side you are solving for sits alone on the left, and the angle on the right is the one opposite it. The other two sides appear twice — squared, and again in the product 2(side)(side).

The same law, rearranged to hunt for angles

Solve a2 = b2 + c2 − 2bc cos A for cos A and you get the angle form. This is the version you use for SSS.

cos A = (b2 + c2 − a2) / (2bc)  ∴  m∠A = cos−1[(b2 + c2 − a2) / (2bc)]

Notice the numerator: the squared side that stands alone is the one being subtracted, and it is the side opposite the angle you want.

Which law do I reach for?

ASA — two angles and the included side. Third angle by Angle-Sum, then Law of Sines.
AAS — two angles and a non-included side. You already have a complete pair → Law of Sines.
SSA — two sides and a non-included angle. Complete pair exists → Law of Sines (ambiguous case).
SAS — two sides and the included angle. No pair → Law of Cosines.
SSS — three sides, no angles. No pair → Law of Cosines.
Right triangle — sine, cosine, tangent and the Pythagorean Theorem are fastest, but either law still works.

Method — SAS: find the missing side

Name the unknown side with the letter matching the given angle. If ∠C is known, the missing side is c.
Write c2 = a2 + b2 − 2ab cos C.
Substitute the two known side lengths and the angle. Keep the cosine unevaluated for now.
Simplify the constants: c2 = (a2+b2) − (2ab) cos C.
Take the positive square root of each side, then use a calculator in degree mode.

Method — SSS: find a missing angle

Choose which angle you want; write the equation whose lone left-hand side is the side opposite that angle.
Substitute all three lengths.
Simplify both constant pieces, then isolate the cosine term.
Divide by the coefficient of the cosine. Watch the signs — a negative result is legal and means the angle is obtuse.
Apply cos−1 and round.
1
The Law of Cosines works on every triangle — acute, right or obtuse. Nothing about it assumes a right angle.
2
The Pythagorean Theorem is just the Law of Cosines with C = 90°: since cos 90° = 0, the term −2ab cos C vanishes and c2 = a2 + b2.
3
cos A < 0 ⇔ A is obtuse. So if a2 > b2 + c2, angle A is obtuse; if they are equal, A is right.
4
A triangle has at most one obtuse angle, and it is always opposite the longest side. That single fact rescues you from the ambiguous case.
Study Tip · SSS: When given all three side lengths of a triangle, you must use the Law of Cosines to find the first angle measure. Then you can use either the Law of Cosines or the Law of Sines to find a second angle measure. If you plan to use the Law of Cosines for the second angle, the order does not matter. But if you want to use the Law of Sines for the second angle, you should find the largest angle first with the Law of Cosines.
Watch Out! Rounding. When you round a numerical solution and then use it in later calculations, your answers may become inaccurate. Wait until after you have completed all of your calculations to round.
Watch Out! The inverse sine lies. sin−1 on a calculator only ever returns an acute value. If the angle you are chasing is actually obtuse, the calculator hands you its supplement. cos−1 has no such flaw — it returns values from 0° to 180° and gets obtuse angles right automatically. That is why the Law of Cosines is the safe tool for the largest angle.
Study Tip · Obtuse Angles: There are also values for sin A, cos A, and tan A when m∠A ≥ 90°. Values of the ratios for these angles can be found by using the trigonometric functions on your calculator. It is good practice to solve for smaller angles first, and then use the Triangle Angle-Sum Theorem to find the measure of the largest, third angle.

Key Figures

Standard labeling of an oblique triangle
a b c A B C
Lowercase letters name sides, capitals name angles, and each lowercase side sits across from its capital. Every version of the Law of Cosines respects this pairing.
SAS — two sides and the included angle
b = 8 c = 5 60° a = ? A B C
a2 = 82 + 52 − 2(8)(5)cos 60° = 89 − 80(0.5) = 49, so a = 7. The angle is between the two known sides, so no complete pair exists and the Law of Sines cannot start.
Which law solves which triangle?
LAW OF SINES — a complete angle–side pair exists ASA AAS SSA LAW OF COSINES — no complete pair SAS SSS
Orange marks what you are given. In the top row a marked angle always faces a marked side — that is the complete pair the Law of Sines needs. In the bottom row it never does, so the Law of Cosines takes over.
Why the Law of Cosines is true (Exercise 20)
a b h c − x x c B A C
Right triangles give h2 = b2 − x2 and a2 = h2 + (c − x)2. Substituting and expanding: a2 = b2 − x2 + c2 − 2cx + x2 = b2 + c2 − 2cx. Since cos A = x/b, we get x = b cos A and therefore a2 = b2 + c2 − 2bc cos A. Drawn to scale: b = 170, c = 300, x = 80, h = 150, a ≈ 266.3.

Move It Yourself

Worked Examples

Find the value of x to the nearest tenth. In △ABC, AC = 2.9, CB = 0.9, and m∠C = 44°. AB = x.
A C B 2.9 0.9 44° x
Two sides and the angle between them — SAS.

We are given the measures of two sides and their included angle. Use the Law of Cosines to write an equation. The unknown side is opposite ∠C, so it plays the role of c.

1c2 = a2 + b2 − 2ab cos CLaw of Cosines
2x2 = 0.92 + 2.92 − 2(0.9)(2.9) cos 44°Substitution
3x2 = 9.22 − 5.22 cos 44°Simplify
4x = √(9.22 − 5.22 cos 44°)Take the positive square root of each side
5x ≈ √(9.22 − 3.755) = √5.465Use a calculator
x ≈ 2.3
Check: 2.3 lies between 2.9 − 0.9 = 2.0 and 2.9 + 0.9 = 3.8, so the Triangle Inequality is satisfied. ✓ Also, 44° is acute, so x should be shorter than the 2.9 side — and it is.
Watch Out! 2(0.9)(2.9) cos 44° is one product. Do not compute (9.22 − 5.22) first and then multiply by cos 44°. Multiplication comes before subtraction.
Find the value of x to the nearest whole number. In △MNP, MN = 9, MP = 11, NP = 5, and m∠P = x°.
M N P 9 11 5 x°
Three sides, no angles — SSS. Side p = MN = 9 is opposite ∠P, so it stands alone.
1p2 = m2 + n2 − 2mn cos PLaw of Cosines
292 = 52 + 112 − 2(5)(11) cos x°Substitution
381 = 146 − 110 cos x°Simplify
4−65 = −110 cos x°Subtract 146 from each side
5−65/−110 = cos x°Divide each side by −110
6x = cos−1(0.5909)Use the inverse cosine function
7x ≈ 53.78Use a calculator
x ≈ 54
Check: 9 is the middle-length side, so ∠P should be the middle-sized angle. cos−1 of a positive number is acute — consistent with a 54° result. ✓
GOLF · The tee box is 378 yards from the hole. To avoid a water hazard, Nhat turns 32° and hits a shot 261.5 yards up the fairway. Find the distance from Nhat's ball to the hole, to the nearest yard.

Because we know the measures of two sides of the triangle (378 and 261.5) and the included angle (32°), use the Law of Cosines to find the remaining distance x.

1x2 = 261.52 + 3782 − 2(261.5)(378) cos 32°Law of Cosines
2x2 = 211,266.25 − 197,694 cos 32°Simplify
3x = √(211,266.25 − 197,694 cos 32°)Take the positive square root of each side
4x ≈ √(211,266.25 − 167,654) = √43,612Use a calculator
x ≈ 209 yards
Study Tip · Rounding: Do not round 197,694 cos 32° to a few digits and then subtract — carry the full calculator value all the way to the square root, and round only at the very end.
Solve △ABC. Round to the nearest degree. AB = 8, AC = 11, BC = 7.
A B C 8 11 7
Drawn to scale: the 11-side really is the longest, and the angle facing it really is the biggest.

Because 72 + 82 ≠ 112 (49 + 64 = 113, not 121), this is not a right triangle. All three sides are given (SSS), so decide which angle you want first, then use the Law of Cosines. Here a = 7, b = 11, c = 8.

1a2 = b2 + c2 − 2bc cos ALaw of Cosines
272 = 112 + 82 − 2(11)(8) cos ASubstitute
349 = 185 − 176 cos ASimplify
4−136 = −176 cos ASubtract 185 from each side
5−136/−176 = cos ADivide each side by −176
6m∠A = cos−1(0.7727) ≈ 39Inverse cosine, then a calculator
Watch Out! Do not reach for the Law of Sines next. It would give sin B = 11 sin 39.35° / 7 ≈ 0.9974, and sin−1(0.9974) ≈ 86°. But b = 11 is the longest side, so ∠B must be the largest angle — and 86° would be smaller than the third angle. The calculator returned the acute twin; the true angle is its supplement, 180° − 86° = 94°. Use the Law of Cosines for the largest angle and the trap disappears.
7cos B = (a2+c2−b2)/(2ac) = (49+64−121)/112Angle form, for the largest angle
8cos B = −8/112 ≈ −0.0714 ∴ m∠B ≈ 94Negative cosine → obtuse angle
9m∠C ≈ 180 − (39 + 94) = 47Triangle Angle-Sum Theorem
m∠A ≈ 39°, m∠B ≈ 94°, m∠C ≈ 47°
Check: Order the sides 7 < 8 < 11 and the angles 39° < 47° < 94° — the orders match, and 39 + 94 + 47 = 180. ✓
Solve △FGH. Round angle measures to the nearest degree and side measures to the nearest tenth. FH = 3, HG = 2, and m∠H = 90°.
F H G 3 2 √13
Legs 3 and 2 drawn to scale (55 px per unit); the hypotenuse FG measures √13 ≈ 3.6.

Find FG. With a right angle available, the Pythagorean Theorem is fastest.

1h2 = f2 + g2 = 22 + 32 = 13Pythagorean Theorem
2h = √13 ≈ 3.6Positive square root; FG ≈ 3.6

Find m∠F with the Law of Cosines. Side f = GH = 2 is opposite ∠F.

3f2 = g2 + h2 − 2gh cos FLaw of Cosines
422 = 32 + (√13)2 − 2(3)(√13) cos FSubstitution
54 = 22 − 6√13 cos FSimplify
6−18 = −6√13 cos FSubtract 22 from each side
7−18/−6√13 = 3/√13 ≈ 0.8321 = cos FDivide each side by −6√13
8m∠F = cos−1(0.8321) ≈ 34Use a calculator
9m∠G ≈ 90 − 34 = 56Acute angles of a right triangle are complementary
FG ≈ 3.6, m∠F ≈ 34°, m∠G ≈ 56°
Check with right-triangle trig: tan F = opposite/adjacent = 2/3, so m∠F = tan−1(2/3) ≈ 33.7° ≈ 34°. ✓ The Law of Cosines agrees — it simply is not the quickest road for a right triangle.

Try It Yourself

Problem 1 · SAS

In △ABC, b = 6, c = 10, and m∠A = 120°. Find a.
1a2 = 62 + 102 − 2(6)(10) cos 120°Law of Cosines
2a2 = 136 − 120(−0.5)cos 120° = −½
3a2 = 136 + 60 = 196Subtracting a negative adds
a = 14

Problem 2 · SSS, recognising a right angle

A triangle has sides 8, 15, and 17. Find the measure of the angle opposite the side of length 17.
1cos θ = (82 + 152 − 172)/(2·8·15)Angle form
2cos θ = (64 + 225 − 289)/240 = 0/240 = 0Simplify
θ = cos−1(0) = 90°
Why: the numerator is zero exactly when b2 + c2 = a2 — the Pythagorean Theorem falling out of the Law of Cosines. ✓

Problem 3 · SSS

In △ABC, a = 4, b = 5, and c = 6. Find m∠C to the nearest degree.
162 = 42 + 52 − 2(4)(5) cos Cc is opposite ∠C
236 = 41 − 40 cos C → −5 = −40 cos CSimplify, then subtract 41
3cos C = 0.125 → C = cos−1(0.125) ≈ 82.82Inverse cosine
m∠C ≈ 83°

Problem 4 · SAS to the nearest tenth

In △DEF, d = 9, f = 12, and m∠E = 53°. Find e to the nearest tenth.
1e2 = d2 + f2 − 2df cos E∠E is included between d and f
2e2 = 81 + 144 − 2(9)(12) cos 53° = 225 − 216 cos 53°Substitute and simplify
3e2 ≈ 225 − 129.99 = 95.01cos 53° ≈ 0.60182
e ≈ 9.7

Problem 5 · Solve the whole triangle

Solve △ABC completely if a = 6, b = 9, and c = 12. Round angle measures to the nearest degree.
1cos C = (36 + 81 − 144)/(2·6·9) = −27/108 = −0.25Largest side first → largest angle
2m∠C = cos−1(−0.25) ≈ 104.48Negative cosine → obtuse
3cos A = (81 + 144 − 36)/(2·9·12) = 189/216 = 0.875Law of Cosines again
4m∠A = cos−1(0.875) ≈ 28.96Inverse cosine
5m∠B ≈ 180 − (104.48 + 28.96) = 46.56Triangle Angle-Sum Theorem
m∠A ≈ 29°, m∠B ≈ 47°, m∠C ≈ 104°
Check: sides 6 < 9 < 12 pair with angles 29° < 47° < 104°. Because we found the obtuse angle first with the Law of Cosines, the Law of Sines would now be safe for the rest. ✓

Summary

What you are givenWhat to doResult
SAS — two sides and the included anglea² = b² + c² − 2bc cos A, then positive square rootThe third side
SSS — three sidescos A = (b²+c²−a²)/(2bc), then cos−1Any angle you choose
SSS — solve the whole triangleLaw of Cosines for the largest angle first, then Law of Cosines or Law of Sines, then Angle-SumAll three angles
ASA / AAS / SSALaw of Sines — a complete angle–side pair already existsRemaining parts
Right trianglesin, cos, tan or Pythagorean Theorem (either law also works)Remaining parts
Result cos A = 0Recognise a² = b² + c²A = 90°, right triangle
Result cos A < 0Nothing special — cos−1 handles itA is obtuse (90° < A < 180°)
a² = b² + c² − 2bc cos A b² = a² + c² − 2ac cos B c² = a² + b² − 2ab cos C cos A = (b²+c²−a²)/(2bc) cos B = (a²+c²−b²)/(2ac) cos C = (a²+b²−c²)/(2ab) cos 90° = 0 → c² = a² + b² A + B + C = 180°
Common mistakes to avoid
  • Pairing the wrong angle with the lone side. The angle in the cosine is always opposite the side by itself.
  • Subtracting before multiplying: 9.22 − 5.22 cos 44° means 9.22 − (5.22 · cos 44°).
  • Forgetting that −2ab cos C adds when C is obtuse, because cos C is then negative.
  • Dropping the square root at the end of an SAS problem — you solved for a², not a.
  • Using the Law of Sines to find a large angle after an SSS start; sin−1 only returns acute values.
  • Rounding intermediate values and then continuing to calculate.
  • Reaching for the Law of Cosines when a complete angle–side pair already exists — the Law of Sines is far less work.
  • Calculator in radian mode. Every angle here is in degrees.

Practice Quiz

15 questions · click an answer to check it instantly

0/15

๐Ÿ“ Test your understanding