Skip to main content

Section 4.5: The Law of Cosines

Learning Objectives

In this section you will:

  • Derive the Law of Cosines
  • Apply the Law of Cosines

Suppose a boat leaves port, travels 10 miles, turns 20 degrees, and travels another 8 miles as shown in Figure 1. How far from port is the boat?

a triangle with a 10 mi side, a 20 degree angle, and an 8 mile side

Unfortunately, while the Law of Sines enables us to address many non-right triangle cases, it does not help us with triangles where the known angle is between two known sides, a SAS (side-angle-side) triangle, or when all three sides are known, but no angles are known, a SSS (side-side-side) triangle. In this section, we will investigate another tool for solving oblique triangles described by these last two cases.


Deriving the Law of Cosines

The tool we need to solve the problem of the boat’s distance from the port is the Law of Cosines, which defines the relationship among angle measurements and side lengths in oblique triangles. Three formulas make up the Law of Cosines. At first glance, the formulas may appear complicated because they include many variables. However, once the pattern is understood, the Law of Cosines is easier to work with than most formulas at this mathematical level.


We consider a generic triangle ABC as sketched in the diagram below.

Triangle ABC. Side c has been extended with a dotted line, and an altitude labelled h has been dropped from the vertex at angle gamma down to the dotted line. The extended bit of the base is labelled x - c, and the side c through x-c is labelled x.

We're going to ignore the main, blue triangle for now, and focus on the big right triangle that we create when drop that altitide, h, down to the base line. According to that triangle and gold ol' SOHCAHTOA, we know that $$\cos(\alpha) = \frac{x}{b}$$ and so $$\textcolor{green}{x = b\cos(\alpha)}$$


Still thinking about that big right triangle, we can apply the Pythagorean Theorem:

$$\textcolor{blue}{x^2 + h^2 = b^2}$$

Notice, there's also a smaller right triangle on the right, created with sides h, a, and x-c. We can apply the Pythagorean Theorem to that as well:

$$\textcolor{red}{(x-c)^2 + h^2 = a^2}$$

These two equations each give us an expression for $h$, if we rearrange them:

$$\textcolor{blue}{h^2 = b^2 - x^2}$$ $$\textcolor{red}{h^2 = a^2 - (x-c)^2}$$

Therefore $$\textcolor{blue}{b^2 - x^2} = \textcolor{red}{a^2 - (x-c)^2$$

If we carefully expand the right side, we have $$b^2 - x^2 = a^2 - x^2 + 2xc - c^2$$ $$\Rightarrow b^2 = a^2 - c^2 + 2cx$$

Now, in our inital analysis using SOHCAHTOA, we found $\textcolor{green}{x = b\cos(\alpha)}$, so we can substitute that in to our developing formula: $$b^2 = a^2 - c^2 + 2c\textcolor{green}{b\cos(\alpha)}$$

Finally, we finish with some rearranging, to make this into the standard expression of the Law of Cosines: $$-a^2 = -b^2 - c^2 + 2bc\cos(\alpha)$$ $$\Rightarrow a^2 = b^2 + c^2 - 2bc\cos(\alpha)$$

Through a similar mathematical process, we can derive all of the formulas described below

The Law of Cosines

Given a triangle with angle-side opposite pairs $(\alpha, a)$, $(\beta, b)$ and $(\gamma, c)$, the following equations hold \[ a^2 = b^2 + c^2 - 2bc \cos(\alpha) \qquad b^2 = a^2 + c^2 - 2ac \cos(\beta) \qquad c^2 = a^2 + b^2 - 2ab \cos(\gamma) \] or, solving for the cosine in each equation, we have \[ \cos(\alpha) = \dfrac{b^2+c^2 - a^2}{2bc} \qquad \cos(\beta) = \dfrac{a^2+c^2 - b^2}{2ac} \qquad \cos(\gamma) = \dfrac{a^2+b^2 - c^2}{2ab} \]

Keep in mind that it is always helpful to sketch the triangle when solving for angles or sides. In a real-world scenario, try to draw a diagram of the situation. As more information emerges, the diagram may have to be altered. Make those alterations to the diagram and, in the end, the problem will be easier to solve.

Solving Triangles with the Law of Cosines

Solve the triangle. Given exact answers and decimal approximations (rounded to hundredths) and sketch the triangle.

$\beta = 50^\circ, a = 7$ units, $c = 2$ units

We are given the lengths of two sides, $a=7$ and $c = 2$, and the measure of the included angle, $\beta = 50^{\circ}$. With no angle-side opposite pair to use for the Law of Sines, we apply the Law of Cosines. We get $b^2 = 7^2 + 2^2 - 2(7)(2)\cos\left(50^{\circ}\right)$ which yields $b = \sqrt{53-28\cos\left(50^{\circ}\right)} \approx 5.92$ units.


In order to determine the measures of the remaining angles $\alpha$ and $\gamma$, we are forced to used the derived value for $b$. There are two ways to proceed at this point. We could use the Law of Cosines again, or, since we have the angle-side opposite pair $(\beta, b)$ we could use the Law of Sines.


The advantage to using the Law of Cosines over the Law of Sines in cases like this is that unlike the sine function, the cosine function distinguishes between acute and obtuse angles. The cosine of an acute is positive, whereas the cosine of an obtuse angle is negative. Since the sine of both acute and obtuse angles are positive, the sine of an angle alone is not enough to determine if the angle in question is acute or obtuse.


Since both authors of the textbook prefer the Law of Cosines, we proceed with this method first. When using the Law of Cosines, it's always best to find the measure of the largest unknown angle first, since this will give us the obtuse angle of the triangle if there is one.


Since the largest angle is opposite the longest side, we choose to find $\alpha$ first. To that end, we use the formula $\cos(\alpha) = \frac{b^2+c^2-a^2}{2bc}$ and substitute $a = 7$, $b = \sqrt{53-28\cos\left(50^{\circ}\right)}$ and $c = 2$. We get \[\cos(\alpha) = \frac{2-7\cos\left(50^{\circ}\right)}{\sqrt{53-28\cos\left(50^{\circ}\right)}}\]


Since $\alpha$ is an angle in a triangle, we know the radian measure of $\alpha$ must lie between $0$ and $\pi$ radians. This matches the range of the arccosine function, so we have \[\alpha = \arccos\left(\frac{2-7\cos\left(50^{\circ}\right)}{\sqrt{53-28\cos\left(50^{\circ} \right)}}\right) \, \text{radians} \, \approx 114.99^{\circ}\] At this point, we could find $\gamma$ using $\gamma = 180^{\circ} - \alpha - \beta \approx 180^{\circ} - 114.99^{\circ} - 50^{\circ} = 15.01^{\circ}$, that is if we trust our approximation for $\alpha$.


To minimize propagation of error (and obtain an exact answer for $\gamma$), however, we could use the Law of Cosines again. Your instructor will let you know which procedure to use. It all boils down to how much you trust your calculator. From $\cos(\gamma) = \frac{a^2+b^2-c^2}{2ab}$ with $a = 7$, $b = \sqrt{53-28\cos\left(50^{\circ} \right)}$ and $c=2$, we get $\gamma = \arccos\left(\frac{7-2 \cos\left(50^{\circ}\right)}{\sqrt{53-28\cos\left(50^{\circ} \right)}} \right)$ radians $\approx 15.01^{\circ}$. We sketch the triangle below.


a sketch of the triangle


Solve the triangle. Given exact answers and decimal approximations (rounded to hundredths) and sketch the triangle.

$a=4$ units, $b=7$ units, $c = 5$ units

Since all three sides and no angles are given, we are forced to use the Law of Cosines. Following our discussion in the previous problem, we find $\beta$ first, since it is opposite the longest side, $b$. We get $\cos(\beta) = \frac{a^2+c^2-b^2}{2ac} = -\frac{1}{5}$, so $\beta = \arccos\left(-\frac{1}{5}\right)$ radians $\approx 101.54^{\circ}$.


Now that we have obtained an angle-side opposite pair $(\beta, b)$, we could proceed using the Law of Sines. The Law of Cosines, however, offers us a rare opportunity to find the remaining angles using only the data given to us in the statement of the problem.


Using the Law of Cosines, we get $\gamma = \arccos\left(\frac{5}{7}\right)$ radians $\approx 44.42^{\circ}$ and $\alpha = \arccos\left(\frac{29}{35}\right)$ radians $\approx 34.05^{\circ}$. We sketch this triangle below.

a sketch of the triangle



Solving Application Problems

Just as the Law of Sines provided the appropriate equations to solve a number of applications, the Law of Cosines is applicable to situations in which the given data fits the cosine models. We may see these in the fields of navigation, surveying, astronomy, and geometry, just to name a few.


On many cell phones with GPS, an approximate location can be given before the GPS signal is received. This is accomplished through a process called triangulation, which works by using the distances from two known points. Suppose there are two cell phone towers within range of a cell phone. The two towers are located 6000 feet apart along a straight highway, running east to west, and the cell phone is north of the highway. Based on the signal delay, it can be determined that the signal is 5,050 feet from the first tower and 2,420 feet from the second tower. Determine the position of the cell phone north and east of the first tower, and determine how far it is from the highway.

For simplicity, we start by drawing a diagram and labeling our given information.

a triangle with sides 5050, 6000, and 2420. The angle between the 5050 and 6000 ft sides is labelled theta

Using the Law of Cosines, we can solve for the angle θ. Remember that the Law of Cosines uses the square of one side to find the cosine of the opposite angle. For this example, let $a = 2420$, $b = 5050$, and $c = 6000$. Thus, $\theta$ is the angle opposite side $a$. Hence, with the Law of Cosines, we have: $$2420^2 = 5050^2 + 6000^2 - 2(5050)(6000)\cos(\theta)$$ $$\cos(\theta) = \frac{2420^2-5050^2-6000^2}{-2(5050)(6000)}$$ $$\theta = \cos^{-1}\left(\frac{2420^2-5050^2-6000^2}{-2(5050)(6000)}\right)$$ $$\theta \approx 23.3^\circ$$


To answer the questions about the phone’s position north and east of the tower, and the distance to the highway, drop a perpendicular from the position of the cell phone, as shown below.This forms two right triangles, although we only need the right triangle that includes the first tower for this problem.

a right triangle with base x, height y, hypotenuse 5050, and base angle 23.3 degrees

Using basic trigonometry, we have $$\cos(23.3^\circ) = \frac{x}{5050}$$ $$x = 5050 \cos(23.3^\circ) \approx 4638.15 \text{ feet}$$
$$\sin(23.3^\circ) = \frac{y}{5050}$$ $$y = 5050\sin(23.3^\circ)\approx 1997.5 \text{ feet}$$

The cell phone is approximately 4,638 feet east and 1998 feet north of the first tower, and 1998 feet from the highway.



Returning to our problem at the beginning of this section, suppose a boat leaves port, travels 10 miles, turns 20 degrees, and travels another 8 miles. How far from port is the boat? The diagram is repeated here:

a triangle with a 10 mi side, a 20 degree angle, and an 8 mile side

The boat turned 20 degrees, so the obtuse angle of the non-right triangle is the supplemental angle, 180°−20°=160°. With this, we can utilize the Law of Cosines to find the missing side of the obtuse triangle—the distance of the boat to the port.

$$x^2 = 8^2 + 10^2 - 2(8)(10)\cos(160^\circ)$$ $$x^2 = 314.35$$ $$x \approx 17.7 \text{ miles}$$

The boat is about 17.7 miles from port.





Practice Problems

Use the Law of Cosines to find the remaining side(s) and angle(s) if possible.

1. $a = 7, \; b = 12, \; \gamma = 59.3^{\circ}$

2. $\alpha = 104^{\circ}, \; b = 25, \; c = 37$

3. $a = 153, \; \beta = 8.2^{\circ}, \; c = 153$

4. $a = 3, \; b = 4, \; \gamma = 90^{\circ}$

5. $\alpha = 120^{\circ}, \; b = 3, \; c = 4$

6. $a = 7, \; b = 10, \; c = 13$

7. $a = 1, \; b = 2, \; c = 5$

8. $a = 300, \; b = 302, \; c = 48$

9. $a = 5, \; b = 5, \; c = 5$

10. $a = 5, \; b = 12,\; c = 13$

1. $\begin{array}{lll} \alpha \approx 35.54^{\circ} & \beta \approx 85.16^{\circ} & \gamma = 59.3^{\circ} \\ a = 7 & b = 12 & c \approx 10.36 \end{array}$

2. $\begin{array}{lll} \alpha = 104^{\circ} & \beta \approx 29.40^{\circ} & \gamma \approx 46.60^{\circ} \\ a \approx 49.41 & b = 25 & c = 37 \end{array}$

3. $\begin{array}{lll} \alpha \approx 85.90^{\circ} & \beta = 8.2^{\circ} & \gamma \approx 85.90^{\circ} \\ a = 153 & b \approx 21.88 & c = 153 \end{array}$

4. $\begin{array}{lll} \alpha \approx 36.87^{\circ} & \beta \approx 53.13^{\circ} & \gamma = 90^{\circ} \\ a = 3 & b = 4 & c = 5 \end{array}$

5. $\begin{array}{lll} \alpha = 120^{\circ} & \beta \approx 25.28^{\circ} & \gamma \approx 34.72^{\circ} \\ a = \sqrt{37} & b = 3 & c = 4 \end{array}$

6. $\begin{array}{lll} \alpha \approx 32.31^{\circ} & \beta \approx 49.58^{\circ} & \gamma \approx 98.21^{\circ} \\ a = 7 & b = 10 & c = 13 \end{array}$

7. Information does not \\ produce a triangle

8. $\begin{array}{lll} \alpha \approx 83.05^{\circ} & \beta \approx 87.81^{\circ} & \gamma \approx 9.14^{\circ} \\ a = 300 & b = 302 & c = 48 \end{array}$

9. $\begin{array}{lll} \alpha = 60^{\circ} & \beta = 60^{\circ} & \gamma = 60^{\circ} \\ a = 5 & b = 5 & c = 5 \end{array}$

10. $\begin{array}{lll} \alpha \approx 22.62^{\circ} & \beta \approx 67.38^{\circ} & \gamma = 90^{\circ} \\ a = 5 & b = 12 & c = 13 \end{array}$

11. The hour hand on my antique Seth Thomas schoolhouse clock in 4 inches long and the minute hand is 5.5 inches long. Find the distance between the ends of the hands when the clock reads four o'clock. Round your answer to the nearest hundredth of an inch.

12. A geologist wants to measure the diameter of an impact crater. From her camp, it is 4 miles to the northern-most point of the crater and 2 miles to the southern-most point. If the angle between the two lines of sight is $117^{\circ}$, what is the diameter of the crater? Round your answer to the nearest hundredth of a mile.

13. From a point 300 feet above level ground in a firetower, a ranger spots two fires in the Yeti National Forest. The angle of depression\footnote{See Exercise \ref{angleofdepression} in Section \ref{AppRightTrig} for the definition of this angle.} made by the line of sight from the ranger to the first fire is $2.5^{\circ}$ and the angle of depression made by line of sight from the ranger to the second fire is $1.3^{\circ}$. The angle formed by the two lines of sight is $117^{\circ}$. Find the distance between the two fires. Round your answer to the nearest foot.

HINT: In order to use the $117^{\circ}$ angle between the lines of sight, you will first need to use right angle Trigonometry to find the lengths of the lines of sight. This will give you a Side-Angle-Side case in which to apply the Law of Cosines.

14. If you apply the Law of Cosines to the ambiguous Angle-Side-Side (ASS) case, the result is a quadratic equation whose variable is that of the missing side. If the equation has no positive real zeros then the information given does not yield a triangle. If the equation has only one positive real zero then exactly one triangle is formed and if the equation has two distinct positive real zeros then two distinct triangles are formed. Apply the Law of Cosines to the following triangles to demonstrate this result: $$a = 18, \alpha = 63^\circ, b = 20$$ $$a = 16, \alpha = 63^\circ, b = 20$$ $$a = 22, \alpha = 63^\circ, b = 20$$

11. The distance between the ends of the hands at four o'clock is about $8.26$ inches.

12. The diameter of the crater is about 5.22 miles.

13. The fires are about 17456 feet apart. (Try to avoid rounding errors.)