The Law of Cosines
The law of cosines is a generalisation of the Pythagorean theorem to any triangle — not only right triangles. It lets us find a third side when two sides and the angle between them are known, or find an angle when all three sides are known. On this page we will understand when to use it, learn the formula, and solve problems involving both finding a side and finding an angle.
Background and Basic Definitions
The law of cosines connects three sides of any triangle with one of its angles:
\[ c^2 = a^2 + b^2 - 2ab\cos(C) \]Here \(C\) is the angle opposite side \(c\), and \(a, b\) are the two sides that enclose it. Symmetrically:
\[ a^2 = b^2 + c^2 - 2bc\cos(A), \qquad b^2 = a^2 + c^2 - 2ac\cos(B) \]Intuition: When \(C = 90^\circ\) we have \(\cos(90^\circ)=0\), so the formula reduces to \(c^2 = a^2 + b^2\) — exactly the Pythagorean theorem. The term \(-2ab\cos(C)\) is the "correction" that handles angles other than \(90^\circ\).
When to use it?
- Two sides and the included angle (SAS) — looking for the third side.
- All three sides known (SSS) — looking for an angle.
To find an angle, isolate the cosine from the formula:
\[ \cos(C) = \frac{a^2 + b^2 - c^2}{2ab} \]If \(\cos(C)\) turns out negative, angle \(C\) is obtuse (greater than \(90^\circ\)); if positive, it is acute.
Solution Steps
- Step 1 — Label the sides of the triangle \(a, b, c\) and the angles \(A, B, C\) opposite them, so you know which side faces which angle.
- Step 2 — Identify what is given: two sides and the angle between them (find a side), or all three sides (find an angle).
- Step 3 — To find a side: substitute into \(c^2 = a^2 + b^2 - 2ab\cos(C)\) where \(C\) is the angle between \(a\) and \(b\), then take the square root.
- Step 4 — To find an angle: isolate \(\cos(C) = \dfrac{a^2 + b^2 - c^2}{2ab}\) and apply \(\cos^{-1}\).
- Step 5 — Check reasonableness: the side opposite the largest angle is the longest, and a negative cosine indicates an obtuse angle.
Worked Examples
Example 1: Finding a Side from Two Sides and the Included Angle
Problem: In triangle \(ABC\), \(a = 7\) cm, \(b = 5\) cm, and the angle between them \(C = 60^\circ\). Find side \(c\).
Solution:
- Use \(c^2 = a^2 + b^2 - 2ab\cos(C)\).
- Substitute: \(c^2 = 7^2 + 5^2 - 2\cdot 7\cdot 5\cdot\cos(60^\circ)\).
- Since \(\cos(60^\circ) = 0.5\): \(c^2 = 49 + 25 - 70\cdot 0.5 = 74 - 35 = 39\).
- Take the square root: \(c = \sqrt{39} \approx 6.24\) cm.
Answer: \(c = \sqrt{39} \approx 6.24\) cm.
Example 2: Finding an Angle from Three Sides
Problem: In a triangle with sides \(a = 6\), \(b = 8\), \(c = 12\), find angle \(C\) (opposite side \(c = 12\)).
Solution:
- Isolate the cosine: \(\cos(C) = \dfrac{a^2 + b^2 - c^2}{2ab}\).
- Substitute: \(\cos(C) = \dfrac{6^2 + 8^2 - 12^2}{2\cdot 6\cdot 8} = \dfrac{36 + 64 - 144}{96}\).
- Compute the numerator: \(36 + 64 - 144 = -44\), so \(\cos(C) = \dfrac{-44}{96} \approx -0.4583\).
- The cosine is negative, so the angle is obtuse: \(C = \cos^{-1}(-0.4583) \approx 117.3^\circ\).
Answer: \(C \approx 117.3^\circ\) (obtuse angle).
Example 3: Applied Problem — Distance Between Two Paths
Problem: Two roads leave from the same point with an angle of \(120^\circ\) between them. One person walks \(10\) km along the first road and another walks \(14\) km along the second road. What is the distance between them?
Solution:
- The distance \(d\) is the side opposite the \(120^\circ\) angle, and the enclosing sides are \(10\) and \(14\).
- Use \(d^2 = 10^2 + 14^2 - 2\cdot 10\cdot 14\cdot\cos(120^\circ)\).
- Since \(\cos(120^\circ) = -0.5\): \(d^2 = 100 + 196 - 280\cdot(-0.5) = 296 + 140 = 436\).
- Take the square root: \(d = \sqrt{436} \approx 20.88\) km.
Answer: The distance is \(\sqrt{436} \approx 20.88\) km.
Example 4: Verifying That an Angle Is a Right Angle
Problem: In a triangle with sides \(a = 9\), \(b = 12\), \(c = 15\), find angle \(C\) opposite side \(c\).
Solution:
- Substitute into the angle formula: \(\cos(C) = \dfrac{9^2 + 12^2 - 15^2}{2\cdot 9\cdot 12}\).
- Numerator: \(81 + 144 - 225 = 0\).
- Therefore \(\cos(C) = \dfrac{0}{216} = 0\), giving \(C = \cos^{-1}(0) = 90^\circ\).
- This is a nice confirmation: \(9\text{-}12\text{-}15\) is a multiple of \(3\text{-}4\text{-}5\), and the triangle is indeed a right triangle.
Answer: \(C = 90^\circ\) — the triangle is a right triangle.
Common Mistakes
✗ Common mistake: Substituting an angle that is not enclosed between the two given sides.
✓ The correct way: In the formula \(c^2 = a^2 + b^2 - 2ab\cos(C)\), angle \(C\) must be the one opposite the desired side \(c\) — that is, the angle between \(a\) and \(b\). Always match each side to the angle opposite it.
✗ Common mistake: Forgetting that an obtuse angle has a negative cosine, and changing the sign or "correcting" it.
✓ The correct way: A negative value of \(\cos(C)\) is perfectly valid and means the angle is obtuse. Substitute it as-is into \(\cos^{-1}\) to obtain an angle between \(90^\circ\) and \(180^\circ\).
✗ Common mistake: Computing \(2ab\cos(C)\) before adding the squares and getting the order of operations wrong.
✓ The correct way: First compute \(a^2 + b^2\), then separately compute \(2ab\cos(C)\), and only then subtract. Keep the minus sign in front of the cosine term.
Practice Tips
- Tip — If the given angle is \(90^\circ\), then \(\cos = 0\) and the formula becomes the Pythagorean theorem. This is a good way to remember the formula.
- Tip — Cosine values worth memorising: \(\cos(60^\circ)=0.5\), \(\cos(120^\circ)=-0.5\), \(\cos(90^\circ)=0\).
- Tip — The sign of the cosine reveals the type of angle: positive = acute, zero = right, negative = obtuse.
- Tip — Do not take the square root until you have finished all addition and subtraction on the right-hand side; an early square root leads to errors.
Summary and Key Formulas
The formula: \(c^2 = a^2 + b^2 - 2ab\cos(C)\), where \(C\) is opposite \(c\).
- Finding a side (SAS): substitute the two sides and the included angle, compute, and take the square root.
- Finding an angle (SSS): \(\cos(C) = \dfrac{a^2 + b^2 - c^2}{2ab}\), then apply \(\cos^{-1}\).
- \(\cos(C)\) negative \(\Rightarrow\) obtuse angle; zero \(\Rightarrow\) right angle; positive \(\Rightarrow\) acute angle.
- When \(C=90^\circ\) the formula reduces to the Pythagorean theorem.