Skip to content

Law of Cosines

In this lesson you’ll learn the Law of Cosines and how to use it to find missing sides and angles when the Law of Sines won’t cut it.

The Law of Cosines is a generalization of the Pythagorean Theorem that works for any triangle:

a2=b2+c22bccosAa^2 = b^2 + c^2 - 2bc\cos A

You can write it for any side:

b2=a2+c22accosBb^2 = a^2 + c^2 - 2ac\cos B c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C

Notice that if the angle is 90°, then cos 90° = 0 and the formula reduces to the Pythagorean Theorem. So this is really the same idea, just extended to handle any angle.

Use the Law of Cosines when you have:

  • Two sides and the included angle (SAS) - find the third side
  • All three sides (SSS) - find any angle

The Law of Sines handles AAS and ASA nicely, but for SAS and SSS, the Law of Cosines is the right tool.

Example 1 (SAS): Find the missing side

In triangle PQR, p = 7, q = 10, and angle R = 55°. Find side r.

We know two sides and the included angle, so we plug straight into the formula:

r2=p2+q22pqcosRr^2 = p^2 + q^2 - 2pq\cos R r2=49+1002(7)(10)cos(55°)r^2 = 49 + 100 - 2(7)(10)\cos(55°) r2=149140(0.5736)14980.3=68.7r^2 = 149 - 140(0.5736) \approx 149 - 80.3 = 68.7 r68.78.29r \approx \sqrt{68.7} \approx 8.29

Example 2 (SSS): Find an angle

A triangle has sides a = 5, b = 7, c = 9. Find angle A.

Rearrange the Law of Cosines to solve for cos A:

cosA=b2+c2a22bc\cos A = \frac{b^2 + c^2 - a^2}{2bc} cosA=49+81252(7)(9)=1051260.8333\cos A = \frac{49 + 81 - 25}{2(7)(9)} = \frac{105}{126} \approx 0.8333 A=cos1(0.8333)33.6°A = \cos^{-1}(0.8333) \approx 33.6°

Example 3 (SSS): Find all angles

A triangle has sides a = 8, b = 6, c = 10. Find all three angles.

Start with the largest angle (opposite the longest side, c = 10):

cosC=a2+b2c22ab=64+361002(8)(6)=096=0\cos C = \frac{a^2 + b^2 - c^2}{2ab} = \frac{64 + 36 - 100}{2(8)(6)} = \frac{0}{96} = 0 C=cos1(0)=90°C = \cos^{-1}(0) = 90°

This is actually a right triangle (6-8-10 is a Pythagorean triple). Now find angle A:

cosA=b2+c2a22bc=36+100642(6)(10)=72120=0.6\cos A = \frac{b^2 + c^2 - a^2}{2bc} = \frac{36 + 100 - 64}{2(6)(10)} = \frac{72}{120} = 0.6 A=cos1(0.6)53.1°A = \cos^{-1}(0.6) \approx 53.1°

And angle B = 180° - 90° - 53.1° = 36.9°.

The Law of Cosines is used in:

  • GPS and navigation (calculating distances between three known points)
  • Surveying (when you can measure two sides and the angle between them)
  • Physics (finding the resultant of two forces at an angle)
  • Construction (calculating diagonal measurements for non-rectangular structures)
  • Aviation (determining flight paths and distances between waypoints)

Example: two roads diverge from a town at a 65° angle. One road leads to a lake 12 miles away, the other to a mountain 8 miles away. The Law of Cosines tells you the straight-line distance between the lake and the mountain.

The Law of Cosines states:
When angle A = 90°, the Law of Cosines reduces to:
The Law of Cosines is the best choice when you know:
In a triangle with sides 5, 7, and 9, $\cos A$ equals:
If $p = 6$, $q = 10$, and angle $R = 60°$, then $r$ is approximately: