Law of Cosines

Solve triangles when the Law of Sines doesn't work

So, you have learned (or maybe you are about to learn) the Law of Sines. It is a beautiful tool for solving triangles. But here is the thing: it does not always work. Sometimes you are given information about a triangle, and the Law of Sines just sits there, useless, unable to help you. If that has ever left you stuck, know that you are not alone.

The good news? There is another tool waiting for you. The Law of Cosines picks up exactly where the Law of Sines leaves off. And here is something that might surprise you: if you know the Pythagorean Theorem (and you do), then you already understand the Law of Cosines. You may not believe it, but, really, you do. The Law of Cosines is just the Pythagorean Theorem grown up, ready to handle triangles that are not limited to right angles.

Core Concepts

When Does the Law of Sines Fail?

The Law of Sines works beautifully when you have a side and its opposite angle. It connects ratios across the triangle:

$$\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}$$

But what if you do not have a side-angle pair? Consider these two situations:

SAS (Side-Angle-Side): You know two sides and the angle between them. For example, sides $a = 5$ and $b = 7$ with angle $C = 60°$. Notice that angle $C$ is the angle between sides $a$ and $b$, not opposite to either of them. The Law of Sines cannot help here because you do not have a complete ratio to work with.

SSS (Side-Side-Side): You know all three sides but no angles. For example, a triangle with sides 5, 6, and 8. The Law of Sines needs at least one angle to get started, so it is stuck.

These are precisely the situations where the Law of Cosines comes to the rescue.

The Law of Cosines: The Formula

For any triangle with sides $a$, $b$, $c$ and opposite angles $A$, $B$, $C$:

$$c^2 = a^2 + b^2 - 2ab \cos C$$

This formula finds side $c$ when you know sides $a$ and $b$ and the included angle $C$.

You can write this formula three different ways, depending on which side you want to find:

$$a^2 = b^2 + c^2 - 2bc \cos A$$ $$b^2 = a^2 + c^2 - 2ac \cos B$$ $$c^2 = a^2 + b^2 - 2ab \cos C$$

The pattern is always the same: the side you are finding is isolated on the left, the other two sides appear in the squared terms and in the product, and the angle is always the one opposite the side you are finding.

Connection to the Pythagorean Theorem

Here is where things get beautiful. Look at the Law of Cosines again:

$$c^2 = a^2 + b^2 - 2ab \cos C$$

What happens if angle $C$ is exactly $90°$?

Well, $\cos 90° = 0$. So the formula becomes:

$$c^2 = a^2 + b^2 - 2ab(0)$$ $$c^2 = a^2 + b^2 - 0$$ $$c^2 = a^2 + b^2$$

That is the Pythagorean Theorem! The Law of Cosines is really a generalization of the Pythagorean Theorem that works for all triangles, not just right triangles. The term $-2ab \cos C$ is the “adjustment factor” that accounts for angles that are not $90°$.

Think of it this way:

  • When $C < 90°$ (acute angle), $\cos C > 0$, so you subtract something, making $c^2$ smaller than $a^2 + b^2$
  • When $C = 90°$ (right angle), $\cos C = 0$, so you get exactly the Pythagorean Theorem
  • When $C > 90°$ (obtuse angle), $\cos C < 0$, so you are actually adding to $a^2 + b^2$, making $c^2$ larger

Solving SAS Triangles

When you have two sides and the included angle, follow these steps:

  1. Find the third side using the Law of Cosines directly
  2. Find another angle using either the Law of Cosines (rearranged) or the Law of Sines
  3. Find the last angle by subtracting from $180°$

There is a small trap with step 2: if you use the Law of Sines to find an angle, the inverse sine function can give you the wrong answer for obtuse angles (the ambiguous case). The safest approach is to find the angle opposite the shortest side using the Law of Sines (that angle is guaranteed to be acute), or to use the Law of Cosines for all angles.

Solving SSS Triangles

When you know all three sides, you are actually finding angles. Rearrange the Law of Cosines to solve for the cosine of an angle:

$$\cos C = \frac{a^2 + b^2 - c^2}{2ab}$$

Similarly: $$\cos A = \frac{b^2 + c^2 - a^2}{2bc}$$ $$\cos B = \frac{a^2 + c^2 - b^2}{2ac}$$

The strategy for SSS triangles:

  1. Find the largest angle first (opposite the longest side) using the Law of Cosines. This is important because the largest angle is the only one that could be obtuse, and the Law of Cosines correctly identifies obtuse angles (when cosine is negative).
  2. Find a second angle using either the Law of Sines (now safe, since the remaining angles must be acute) or the Law of Cosines.
  3. Find the third angle by subtracting from $180°$.

Choosing Between Law of Sines and Law of Cosines

Here is a quick guide:

You Have You Want Use
AAS or ASA Missing sides/angles Law of Sines
SSA Missing parts Law of Sines (watch for ambiguous case)
SAS Third side Law of Cosines
SAS Other angles Either (Cosines is safer)
SSS Any angle Law of Cosines

The general rule: if you have a side and its opposite angle, the Law of Sines is usually simpler. If you have SAS or SSS, you need the Law of Cosines to get started.

Heron’s Formula for Area

The Law of Cosines leads to a remarkable formula for the area of a triangle when you only know the three sides. This is called Heron’s formula (named after Hero of Alexandria, a Greek mathematician).

First, calculate the semi-perimeter (half the perimeter): $$s = \frac{a + b + c}{2}$$

Then the area is: $$\text{Area} = \sqrt{s(s-a)(s-b)(s-c)}$$

This formula is incredibly useful because it requires only the three side lengths, no angles needed. It is often simpler than finding an angle first and then using the standard area formula $\frac{1}{2}ab\sin C$.

Why does this work? It comes from combining the Law of Cosines with the area formula $\frac{1}{2}ab\sin C$ and doing a fair bit of algebra. You do not need to memorize the derivation, just the formula itself.

Notation and Terminology

Term Meaning Example
SAS Two sides and the included angle $a = 5$, $b = 7$, $C = 60°$
SSS Three sides (no angles given) $a = 5$, $b = 6$, $c = 8$
Law of Cosines $c^2 = a^2 + b^2 - 2ab \cos C$ Generalized Pythagorean Theorem
Included angle The angle between two given sides $C$ is included between $a$ and $b$
Semi-perimeter Half the perimeter: $s = \frac{a+b+c}{2}$ For sides 5, 6, 8: $s = 9.5$
Heron’s formula Area $= \sqrt{s(s-a)(s-b)(s-c)}$ Area when only sides are known

Examples

Example 1: Find a Side (SAS)

Find side $c$ if $a = 5$, $b = 7$, and $C = 60°$.

Solution:

We have two sides and the included angle (SAS), so we use the Law of Cosines directly:

$$c^2 = a^2 + b^2 - 2ab \cos C$$

Substitute the known values: $$c^2 = 5^2 + 7^2 - 2(5)(7) \cos 60°$$

Since $\cos 60° = 0.5$: $$c^2 = 25 + 49 - 70(0.5)$$ $$c^2 = 74 - 35$$ $$c^2 = 39$$

Take the square root: $$c = \sqrt{39} \approx 6.24$$

Example 2: Find an Angle (SSS)

Find angle $A$ if $a = 8$, $b = 6$, and $c = 10$.

Solution:

We have all three sides (SSS), so we rearrange the Law of Cosines to solve for $\cos A$:

$$\cos A = \frac{b^2 + c^2 - a^2}{2bc}$$

Substitute the values: $$\cos A = \frac{6^2 + 10^2 - 8^2}{2(6)(10)}$$ $$\cos A = \frac{36 + 100 - 64}{120}$$ $$\cos A = \frac{72}{120}$$ $$\cos A = 0.6$$

Take the inverse cosine: $$A = \cos^{-1}(0.6) \approx 53.13°$$

Example 3: Solve a Complete SAS Triangle

Solve the triangle with $a = 11$, $b = 13$, and $C = 42°$.

Solution:

Step 1: Find side $c$ using the Law of Cosines.

$$c^2 = a^2 + b^2 - 2ab \cos C$$ $$c^2 = 11^2 + 13^2 - 2(11)(13) \cos 42°$$ $$c^2 = 121 + 169 - 286(0.7431)$$ $$c^2 = 290 - 212.53$$ $$c^2 = 77.47$$ $$c = \sqrt{77.47} \approx 8.80$$

Step 2: Find angle $A$ using the Law of Cosines (safer than Law of Sines).

$$\cos A = \frac{b^2 + c^2 - a^2}{2bc}$$ $$\cos A = \frac{13^2 + 8.80^2 - 11^2}{2(13)(8.80)}$$ $$\cos A = \frac{169 + 77.44 - 121}{228.8}$$ $$\cos A = \frac{125.44}{228.8}$$ $$\cos A \approx 0.5482$$ $$A = \cos^{-1}(0.5482) \approx 56.75°$$

Step 3: Find angle $B$.

$$B = 180° - A - C$$ $$B = 180° - 56.75° - 42°$$ $$B \approx 81.25°$$

Final answer: $c \approx 8.80$, $A \approx 56.75°$, $B \approx 81.25°$

Example 4: Solve a Complete SSS Triangle

Solve the triangle with sides $a = 7$, $b = 8$, $c = 9$.

Solution:

Step 1: Find the largest angle first (opposite the longest side).

Side $c = 9$ is longest, so we find angle $C$ first:

$$\cos C = \frac{a^2 + b^2 - c^2}{2ab}$$ $$\cos C = \frac{7^2 + 8^2 - 9^2}{2(7)(8)}$$ $$\cos C = \frac{49 + 64 - 81}{112}$$ $$\cos C = \frac{32}{112}$$ $$\cos C \approx 0.2857$$ $$C = \cos^{-1}(0.2857) \approx 73.40°$$

Step 2: Find angle $B$ (opposite side $b = 8$).

$$\cos B = \frac{a^2 + c^2 - b^2}{2ac}$$ $$\cos B = \frac{7^2 + 9^2 - 8^2}{2(7)(9)}$$ $$\cos B = \frac{49 + 81 - 64}{126}$$ $$\cos B = \frac{66}{126}$$ $$\cos B \approx 0.5238$$ $$B = \cos^{-1}(0.5238) \approx 58.41°$$

Step 3: Find angle $A$.

$$A = 180° - B - C$$ $$A = 180° - 58.41° - 73.40°$$ $$A \approx 48.19°$$

Final answer: $A \approx 48.19°$, $B \approx 58.41°$, $C \approx 73.40°$

Check: The angles sum to $48.19° + 58.41° + 73.40° = 180°$. Also notice that the smallest angle ($A$) is opposite the smallest side ($a = 7$), and the largest angle ($C$) is opposite the largest side ($c = 9$). This makes sense!

Example 5: Find All Angles of a Triangle

Find all angles of a triangle with sides $a = 5$, $b = 6$, $c = 8$.

Solution:

Step 1: Find the largest angle $C$ (opposite $c = 8$).

$$\cos C = \frac{a^2 + b^2 - c^2}{2ab}$$ $$\cos C = \frac{5^2 + 6^2 - 8^2}{2(5)(6)}$$ $$\cos C = \frac{25 + 36 - 64}{60}$$ $$\cos C = \frac{-3}{60}$$ $$\cos C = -0.05$$ $$C = \cos^{-1}(-0.05) \approx 92.87°$$

Notice that $\cos C$ is negative, which correctly tells us that $C$ is obtuse (greater than $90°$). This is why we always find the largest angle first using the Law of Cosines.

Step 2: Find angle $B$ (opposite $b = 6$).

$$\cos B = \frac{a^2 + c^2 - b^2}{2ac}$$ $$\cos B = \frac{5^2 + 8^2 - 6^2}{2(5)(8)}$$ $$\cos B = \frac{25 + 64 - 36}{80}$$ $$\cos B = \frac{53}{80}$$ $$\cos B = 0.6625$$ $$B = \cos^{-1}(0.6625) \approx 48.51°$$

Step 3: Find angle $A$.

$$A = 180° - B - C$$ $$A = 180° - 48.51° - 92.87°$$ $$A \approx 38.62°$$

Final answer: $A \approx 38.62°$, $B \approx 48.51°$, $C \approx 92.87°$

Notice that one angle is obtuse (greater than $90°$), which the Law of Cosines detected correctly through the negative cosine value.

Example 6: Verify Area Using Two Methods

For a triangle with sides $a = 5$, $b = 7$, and $c = 8$, find the area using Heron’s formula, then verify using $\frac{1}{2}ab\sin C$.

Solution:

Method 1: Heron’s Formula

First, find the semi-perimeter: $$s = \frac{a + b + c}{2} = \frac{5 + 7 + 8}{2} = \frac{20}{2} = 10$$

Now apply Heron’s formula: $$\text{Area} = \sqrt{s(s-a)(s-b)(s-c)}$$ $$\text{Area} = \sqrt{10(10-5)(10-7)(10-8)}$$ $$\text{Area} = \sqrt{10 \cdot 5 \cdot 3 \cdot 2}$$ $$\text{Area} = \sqrt{300}$$ $$\text{Area} = 10\sqrt{3} \approx 17.32$$

Method 2: Using $\frac{1}{2}ab\sin C$

First, we need angle $C$ (opposite side $c = 8$): $$\cos C = \frac{a^2 + b^2 - c^2}{2ab} = \frac{25 + 49 - 64}{70} = \frac{10}{70} = \frac{1}{7}$$

To find $\sin C$, use the identity $\sin^2 C + \cos^2 C = 1$: $$\sin^2 C = 1 - \cos^2 C = 1 - \frac{1}{49} = \frac{48}{49}$$ $$\sin C = \sqrt{\frac{48}{49}} = \frac{\sqrt{48}}{7} = \frac{4\sqrt{3}}{7}$$

Now calculate the area: $$\text{Area} = \frac{1}{2}ab\sin C = \frac{1}{2}(5)(7) \cdot \frac{4\sqrt{3}}{7}$$ $$\text{Area} = \frac{1}{2} \cdot 5 \cdot 4\sqrt{3}$$ $$\text{Area} = 10\sqrt{3} \approx 17.32$$

Both methods give the same answer: Area $= 10\sqrt{3} \approx 17.32$ square units.

This confirms that Heron’s formula works and is often simpler when you only know the three sides.

Key Properties and Rules

The Law of Cosines (Three Forms)

$$a^2 = b^2 + c^2 - 2bc \cos A$$ $$b^2 = a^2 + c^2 - 2ac \cos B$$ $$c^2 = a^2 + b^2 - 2ab \cos C$$

Solving for Angles (Rearranged Form)

$$\cos A = \frac{b^2 + c^2 - a^2}{2bc}$$ $$\cos B = \frac{a^2 + c^2 - b^2}{2ac}$$ $$\cos C = \frac{a^2 + b^2 - c^2}{2ab}$$

Heron’s Formula

For a triangle with sides $a$, $b$, $c$ and semi-perimeter $s = \frac{a+b+c}{2}$:

$$\text{Area} = \sqrt{s(s-a)(s-b)(s-c)}$$

Key Relationships

  • The Law of Cosines reduces to the Pythagorean Theorem when the angle is $90°$
  • A negative cosine value indicates an obtuse angle (greater than $90°$)
  • A positive cosine value indicates an acute angle (less than $90°$)
  • Always find the largest angle first in SSS problems (it is the only one that could be obtuse)

When to Use Each Law

Situation First Step
SAS Law of Cosines to find the third side
SSS Law of Cosines to find the largest angle
AAS, ASA Law of Sines
SSA Law of Sines (be careful of ambiguous case)

Real-World Applications

Finding Distances When Direct Measurement is Impossible

Suppose you want to find the distance across a lake. You cannot swim across with a measuring tape, but you can:

  1. Pick two points $A$ and $B$ on your side of the lake
  2. Measure the distance $AB$
  3. Pick a visible point $C$ on the far shore
  4. Measure angles $\angle CAB$ and $\angle CBA$

With two angles and the included side, you can use the Law of Sines (after finding the third angle). But if you instead measured $AB$ and $AC$ directly by walking around the lake, plus the angle between them, you would use the Law of Cosines to find $BC$.

Surveyors use these techniques constantly to measure distances that cannot be measured directly.

When a ship or aircraft needs to calculate its position, it often involves triangulation. If you know your distances from two known landmarks and the angle between your lines of sight to them, the Law of Cosines helps calculate your position.

GPS actually uses a more sophisticated version of this idea, calculating your distance from multiple satellites and using the mathematical relationships (including principles from the Law of Cosines extended to three dimensions) to pinpoint your location.

Force Vectors in Physics

When two forces act on an object at an angle to each other, the resultant force can be found using the Law of Cosines. If force $F_1$ and force $F_2$ act at an angle $\theta$ to each other, the magnitude of the resultant force $R$ is:

$$R^2 = F_1^2 + F_2^2 + 2F_1F_2\cos\theta$$

(Note: this formula looks slightly different because in physics we often measure the angle differently, but the underlying principle is the same.)

Architecture and Construction

Building designers use the Law of Cosines when working with non-rectangular spaces. If you are designing a triangular addition to a building and you know two wall lengths and the angle between them, you need the Law of Cosines to find the third wall length. This ensures materials are ordered accurately and the structure fits together properly.

Roof trusses, bridge supports, and any structural element that forms a triangle (which is common because triangles are inherently rigid) often require calculations involving the Law of Cosines.

Self-Test Problems

Problem 1: Find side $b$ if $a = 10$, $c = 12$, and $B = 55°$.

Show Answer

Use the Law of Cosines: $$b^2 = a^2 + c^2 - 2ac \cos B$$ $$b^2 = 10^2 + 12^2 - 2(10)(12) \cos 55°$$ $$b^2 = 100 + 144 - 240(0.5736)$$ $$b^2 = 244 - 137.66$$ $$b^2 = 106.34$$ $$b = \sqrt{106.34} \approx 10.31$$

Problem 2: Find angle $B$ in a triangle with sides $a = 7$, $b = 9$, $c = 5$.

Show Answer

$$\cos B = \frac{a^2 + c^2 - b^2}{2ac}$$ $$\cos B = \frac{7^2 + 5^2 - 9^2}{2(7)(5)}$$ $$\cos B = \frac{49 + 25 - 81}{70}$$ $$\cos B = \frac{-7}{70} = -0.1$$ $$B = \cos^{-1}(-0.1) \approx 95.74°$$

Note: The negative cosine correctly indicates that angle $B$ is obtuse.

Problem 3: Determine whether a triangle with sides 4, 5, and 7 is acute, right, or obtuse.

Show Answer

Check if the largest angle (opposite the longest side) is $90°$, less than $90°$, or greater than $90°$.

Let $c = 7$ be the longest side. Calculate: $$a^2 + b^2 = 4^2 + 5^2 = 16 + 25 = 41$$ $$c^2 = 7^2 = 49$$

Since $a^2 + b^2 = 41 < 49 = c^2$, the triangle is obtuse.

Alternatively, using the Law of Cosines: $$\cos C = \frac{16 + 25 - 49}{2(4)(5)} = \frac{-8}{40} = -0.2$$

Since $\cos C < 0$, angle $C > 90°$, confirming the triangle is obtuse.

Problem 4: A triangle has sides 13, 14, and 15. Find its area using Heron’s formula.

Show Answer

Semi-perimeter: $s = \frac{13 + 14 + 15}{2} = \frac{42}{2} = 21$

Heron’s formula: $$\text{Area} = \sqrt{s(s-a)(s-b)(s-c)}$$ $$\text{Area} = \sqrt{21(21-13)(21-14)(21-15)}$$ $$\text{Area} = \sqrt{21 \cdot 8 \cdot 7 \cdot 6}$$ $$\text{Area} = \sqrt{7056}$$ $$\text{Area} = 84$$

The area is 84 square units.

Problem 5: Solve the triangle completely: $a = 8$, $b = 15$, $C = 110°$.

Show Answer

Step 1: Find side $c$: $$c^2 = a^2 + b^2 - 2ab \cos C$$ $$c^2 = 64 + 225 - 240 \cos 110°$$ $$c^2 = 289 - 240(-0.342)$$ $$c^2 = 289 + 82.08$$ $$c^2 = 371.08$$ $$c \approx 19.26$$

Step 2: Find angle $A$ (opposite the smaller known side): $$\cos A = \frac{b^2 + c^2 - a^2}{2bc}$$ $$\cos A = \frac{225 + 371.08 - 64}{2(15)(19.26)}$$ $$\cos A = \frac{532.08}{577.8} \approx 0.921$$ $$A = \cos^{-1}(0.921) \approx 22.94°$$

Step 3: Find angle $B$: $$B = 180° - A - C = 180° - 22.94° - 110° \approx 47.06°$$

Final answer: $c \approx 19.26$, $A \approx 22.94°$, $B \approx 47.06°$

Problem 6: Two ships leave port at the same time. One sails 30 km on a bearing of $040°$, the other sails 40 km on a bearing of $100°$. How far apart are they?

Show Answer

The angle between their paths is $100° - 40° = 60°$.

This is an SAS problem with sides 30 and 40, and included angle $60°$.

Using the Law of Cosines: $$d^2 = 30^2 + 40^2 - 2(30)(40) \cos 60°$$ $$d^2 = 900 + 1600 - 2400(0.5)$$ $$d^2 = 2500 - 1200$$ $$d^2 = 1300$$ $$d = \sqrt{1300} \approx 36.06$$

The ships are approximately 36.06 km apart.

Summary

  • The Law of Cosines solves triangles when the Law of Sines cannot help, specifically in SAS (two sides and included angle) and SSS (three sides) situations.

  • The formula is $c^2 = a^2 + b^2 - 2ab \cos C$, where $C$ is the angle opposite side $c$. It can be rearranged to find any side or any angle.

  • The Law of Cosines is a generalization of the Pythagorean Theorem. When the angle is $90°$, it reduces exactly to $c^2 = a^2 + b^2$.

  • For SAS triangles: use the Law of Cosines to find the third side first, then find the remaining angles.

  • For SSS triangles: use the Law of Cosines to find the largest angle first (the only one that could be obtuse), then find the other angles.

  • A negative cosine indicates an obtuse angle (greater than $90°$). This is why the Law of Cosines correctly identifies obtuse angles, unlike the inverse sine function.

  • Heron’s formula finds a triangle’s area from just the three sides: Area $= \sqrt{s(s-a)(s-b)(s-c)}$ where $s = \frac{a+b+c}{2}$.

  • When choosing between laws: use the Law of Sines when you have a side-angle pair, use the Law of Cosines for SAS or SSS.

  • Real-world applications include surveying, navigation, physics (force vectors), and architecture.

The Law of Cosines is one of those tools that, once you understand it, makes you wonder how you ever solved triangles without it. It handles the cases the Law of Sines cannot, and it does so by being the Pythagorean Theorem’s more versatile cousin. Now you have the complete toolkit for solving any triangle.