Explainer: Law of Cosines

In this explainer, we will learn how to find the sides and angles in non-right triangles using the law of cosines.

The law of cosines, also known as the cosine rule, allows us to relate all three sides of a triangle with one of its angles.

Definition: The Law of Cosines

Let us consider a triangle ๐ด๐ต๐ถ, with corresponding sides of lengths ๐‘Ž, ๐‘, and ๐‘. For this triangle, each side has been labeled with the lower case letter of its opposite angle.

The law of cosines tells us that ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…๐ด.๏Šจ๏Šจ๏Šจcos

It may be useful to see that the law of cosines can be viewed as a generalized form of the Pythagorean theorem. In order to see this, let us consider an arbitrary triangle with an angle ๐ด=90โˆ˜.

Inputting this value into the law of cosines, we can see that our final term becomes 2๐‘๐‘โ‹…90cosโˆ˜: ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…90.๏Šจ๏Šจ๏Šจโˆ˜cos

Since we know that cos90=0โˆ˜, we can see the last term will vanish from our equation: ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…0๐‘Ž=๐‘+๐‘.๏Šจ๏Šจ๏Šจ๏Šจ๏Šจ๏Šจ

Here, we can see that, for the special case of a right triangle, the law of cosines reduces to the Pythagorean theorem, with side length ๐‘Ž being defined as the hypotenuse.

The law of cosines can be used in a couple of different cases. The first case is when finding an unknown side length when given its opposite angle and the two adjacent side lengths. You may see the angle referred to as โ€œthe enclosed angleโ€ in this situation.

Understanding each of the terms will help us correctly utilize the cosine rule: ๐ดโŸน,๐‘ŽโŸน,๐‘โŸน,๐‘โŸน.theangleenclosedbytwoknownsidesthesideoppositetheenclosedangleoneoftheadjacentsidestotheenclosedangleoneoftheadjacentsidestotheenclosedangle

In this case, we have chosen to observe the relationship between the side lengths with respect to the enclosed angle ๐ด. It is worth noting that the law of cosines can be applied to a triangle with respect to any of its angles.

We could instead observe the relationship between the side lengths with respect to either of the remaining two angles (bottom left and bottom right in the diagram), simply by relabeling our triangle to fit the known information.

Let us now look at some examples where the law of cosines is used to find an unknown length in a triangle.

Example 1: Using the Law of Cosines to Calculate an Unknown Length in a Triangle

๐ด๐ต๐ถ is a triangle where ๐ต๐ถ=25cm, ๐ด๐ถ=13cm, and ๐‘šโˆ ๐ถ=142โˆ˜. Find length ๐ด๐ต giving the answer to three decimal places.

Answer

Often, sketching out a triangle can be helpful for visualizing this type of problem (diagram not to scale).

Looking at our triangle, we can see that we have two side lengths, ๐ต๐ถ and ๐ด๐ถ, and the enclosed angle, ๐ถ. This situation tells us that we can use the law of cosines: ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…๐ด.๏Šจ๏Šจ๏Šจcos

We can define the values of our triangle with respect to the law of cosines, starting with the enclosed angle. The final term of our equation will therefore contain the following element: coscos๐ดโŸน142.โˆ˜

As required, the unknown side length, ๐ด๐ต, is opposite the enclosed angle. We therefore define the side lengths as follows: ๐‘ŽโŸน๐ด๐ต,๐‘โŸน25,๐‘โŸน13.cmcm

Substituting these values into the law of cosine, we find the following equation: ๐ด๐ต=25+13โˆ’2(25)(13)โ‹…142.๏Šจ๏Šจ๏Šจโˆ˜cos

Finally, we can simplify and take the square root of both sides of our equation. We can also ignore the negative solution to our square root, since we are solving to find a length: ๐ด๐ต=โˆš1,306.2069โ€ฆ=36.14148โ€ฆโ‰ˆ36.141.cm

Our answer has been round to three decimal places as required by the question.

Example 2: Using the Law of Cosines to Calculate an Unknown Length in a Triangle

๐ด๐ต๐ถ is a triangle where ๐‘Ž=13cm, ๐‘=10cm, and cos๐ถ=0.2. Find the value of ๐‘ giving the answer to three decimal places.

Answer

When approaching this type of problem, it can be helpful to sketch out the triangle, as shown below (not to scale).

Looking at our triangle, we can see that we have two side lengths, ๐‘Ž and ๐‘, and a trigonometric evaluation for the enclosed angle, ๐ถ. This situation tells us that we can use the law of cosines: ๐‘=๐‘Ž+๐‘โˆ’2๐‘Ž๐‘โ‹…๐ถ.๏Šจ๏Šจ๏Šจcos

Substituting these values into the law of cosines, we find the following equation: ๐‘=13+10โˆ’2(13)(10)โ‹…0.2.๏Šจ๏Šจ๏Šจ

Simplifying our equation and solving for ๐‘, we get the following side length, which we round to three decimal places: ๐‘=โˆš217=14.73091โ€ฆโ‰ˆ14.731.cm

Let us now consider the second case in which the law of cosines can be used to solve problems. The questions we have looked at so far involved finding an unknown side length when given its opposite angle and the two adjacent side lengths.

Let now us consider a new case where we have a triangle with the side lengths ๐‘Ž, ๐‘, and ๐‘ and we wish to find an unknown angle ๐ด.

How to Rearrange the Law of Cosines

To help us solve this problem, we can rearrange our current equation to a more convenient form. To start, we can add 2๐‘๐‘โ‹…๐ดcos to both sides of the law of cosines: ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…๐ด๐‘Ž+2๐‘๐‘โ‹…๐ด=๐‘+๐‘.๏Šจ๏Šจ๏Šจ๏Šจ๏Šจ๏Šจcoscos

We can now subtract ๐‘Ž๏Šจ from both sides: 2๐‘๐‘โ‹…๐ด=๐‘+๐‘โˆ’๐‘Ž.cos๏Šจ๏Šจ๏Šจ

Finally, we can divide both sides by 2๐‘๐‘, giving us the cosine of angle ๐ด in terms of the side lengths of our triangle: cos๐ด=๐‘+๐‘โˆ’๐‘Ž2๐‘๐‘.๏Šจ๏Šจ๏Šจ

In this example, we have chosen to focus on angle ๐ด; however, this form of the law of cosines can be used to find any of the angles in a triangle by observing the following relationships between the variables: ๐ดโŸน,๐‘ŽโŸน,๐‘โŸน,๐‘โŸน.theunknownangletobefoundthesideoppositetheunknownangleoneoftheadjacentsidestotheunknownangleoneoftheadjacentsidestotheunknownangle

Example 3: Using the Law of Cosines to Calculate an Angle in a Triangle

๐ด๐ต๐ถ is a triangle where ๐‘Ž=12cm, ๐‘=20cm, and ๐‘=26cm. Find the smallest angle in ๐ด๐ต๐ถ giving the answer to the nearest second.

Answer

As with most problems of this type, it may be helpful to sketch out the triangle (not to scale) to help visualize the problem.

We know that, for any triangle, the smallest side will be opposite to the smallest angle.

Inspecting our side lengths, we can see that ๐‘Ž<๐‘<๐‘. We can therefore conclude that angle ๐ด is the smallest, since it is opposite side ๐‘Ž.

In order to find ๐ด, we can use the following form of the law of cosines: cos๐ด=๐‘+๐‘โˆ’๐‘Ž2๐‘๐‘.๏Šจ๏Šจ๏Šจ Our side lengths then take the following values: ๐‘ŽโŸน12,๐‘โŸน20,๐‘โŸน26.cmcmcm

Substituting these values into the law of cosines, we find the following equation: cos๐ด=20+26โˆ’12(2)(20)(26).๏Šจ๏Šจ๏Šจ We can then multiply out each of the terms and simplify the right-hand side of the equation: cos๐ด=400+676โˆ’1441,040=233260.

Lastly, we solve for angle ๐ด: ๐ด=๏€ผ233260๏ˆ=26.342975โ€ฆ.cos๏Šฑ๏Šงโˆ˜

We have now found ๐ด in degrees; however, the question requires us to give a solution to the nearest second. In order to do this, we can recall the following relationship between degrees (โˆ˜), minutes (๏Ž˜), and seconds (๏Ž™). 1=60,1=60.โˆ˜๏Ž˜๏Ž˜๏Ž™

Looking at our solution, we can see that ๐ด=26โˆ˜ with a remainder of 0.342975โ€ฆโˆ˜. We can multiply this remainder by 60 to find the number of minutes in our solution: 60ร—0.342975โ€ฆ=20.578532.โˆ˜๏Ž˜

Using the same method, we see that this remainder contains 20๏Ž˜ with a remainder of 0.578532โ€ฆ๏Ž˜. Again multiplying this by 60, we can calculate the number of seconds: 60ร—0.578532โ€ฆ=34.711959โ€ฆโ‰ˆ35.๏Ž˜๏Ž™

We can now write our solution to the nearest second: ๐ด=262035.โˆ˜๏Ž˜๏Ž™

Some questions may require you to use a combination of both forms of the law of cosines in order to solve a triangle. We will now explore examples where the equation is used in both forms sequentially.

Example 4: Using the Law of Cosines to Find Unknown Angles and Lengths of a Triangle

๐ด๐ต๐ถ is a triangle where ๐‘Ž=28cm, ๐‘=17cm, and ๐‘šโˆ ๐ถ=60โˆ˜. Find the missing length rounded to three decimal places and the missing angles rounded to the nearest degree.

Answer

We first sketch our triangle to visualize the problem.

Upon inspection, we see that the our triangle contains one known angle enclosed between two known side lengths: ๐ถโŸน,๐‘โŸน,๐‘ŽโŸน,๐‘โŸน.theangleenclosedbytwoknownsidesthesideoppositetheenclosedangleoneoftheadjacentsidestotheenclosedangleoneoftheadjacentsidestotheenclosedangle

This situation tells us that we can use the first form of the law of cosines. Using this form of the equation, we can formulate a relationship between angle ๐ถ and the three sides of our triangle: ๐‘=๐‘Ž+๐‘โˆ’2๐‘Ž๐‘โ‹…๐ถ.๏Šจ๏Šจ๏Šจcos

We can now substitute in the known information from our triangle: ๐‘=28+17โˆ’2(28)(17)โ‹…60.๏Šจ๏Šจ๏Šจโˆ˜cos

Next, we evaluate each individual term on the right-hand side of our equation and simplify it. In doing this, we can recognize that cos60โˆ˜ is one of the exact trigonometric ratios: ๐‘=784+289โˆ’952โ‹…12=597.๏Šจ

We can now take the square root of both sides of our equation, ignoring the negative solution since we are solving to find the length, ๐‘. We round our answer to three decimal places, as stated in the question: ๐‘=โˆš597=24.433583โ€ฆโ‰ˆ24.434.

Let us now redraw our triangle with the newly found information.

We now have a triangle with three known sides and one known angle. In order to find either of the two remaining angles, we can use the second form of the law of cosines. Let us find angle ๐ด using the following equation: cos๐ด=๐‘+๐‘โˆ’๐‘Ž2๐‘๐‘.๏Šจ๏Šจ๏Šจ

We now substitute our side lengths into the equation. Here we have chosen to use the exact length of side ๐‘=โˆš597, instead of the rounded answer, to maintain precision: cos๐ด=17+๏€ปโˆš597๏‡โˆ’28(2)(17)๏€ปโˆš597๏‡.๏Šจ๏Šจ๏Šจ

We can then multiply out each of the terms and simplify the right-hand side of the equation: cos๐ด=289+597โˆ’784830.741โ€ฆ=102830.741โ€ฆ.

We now solve for ๐ด and round to the nearest degree as stated in the question: ๐ด=๏€ป๏‡=82.947โ€ฆโ‰ˆ83.cos๏Šฑ๏Šง๏Šง๏Šฆ๏Šจ๏Šฎ๏Šฉ๏Šฆ๏Ž–๏Šญ๏Šช๏Šงโ€ฆโˆ˜โˆ˜

Finally, we know that angles in a triangle sum to 180โˆ˜. Since two of the angles in the triangle are now known, we are able to find the third by substituting into the following equation: ๐ด+๐ต+๐ถ=18082.947โ€ฆ+๐ต+60=180.

Solving for ๐ต, we complete the information for the triangle giving our final answer to the nearest degree: ๐ต=180โˆ’82.947โ€ฆโˆ’60=37.053โ€ฆโ‰ˆ37.โˆ˜

In some situations, we may not be able to use the law of cosines immediately. In such cases, it may be necessary to first use other geometric methods to find an angle or side length. Doing this will allow us to proceed using one of the methods described above in this explainer.

Here we show an example using the area of a triangle and standard trigonometric techniques.

Example 5: Solving a Triangle by Using Trigonometry in Combination with the Law of Cosines

๐ด๐ต๐ถ is a triangle where ๐ต๐ถ=38cm, ๐‘šโˆ ๐ด๐ถ๐ต=60โˆ˜, and the area is 399โˆš3 cm2. Find the other lengths and angles giving lengths to one decimal place and angles to the nearest degree.

Answer

Here we sketch the triangle using the known information.

Looking at our triangle, we have one known angle and one of its adjacent side lengths. Unfortunately, this information is not sufficient to use the law of cosines in either form! In order to proceed, we will need to make use of a combination of techniques:

  1. Use the given area to find the height of the triangle.
  2. Use trigonometry in conjunction with triangle height to find the side length (๐‘).
  3. Use the law of cosines to solve for the remaining unknowns.

1. Use the Given Area to Find the Height of the Triangle

Alongside the given angle and the side length, the question also provides us with the area of the triangle. Let us recall the formula for the area of a triangle: areabaseheight=ร—2. Taking ๐ต๐ถ to be the base of our triangle, let us now redraw our diagram. A new point, ๐ท, has been marked on the base of the triangle directly below point ๐ด. The line segment ๐ด๐ท is therefore the perpendicular height (โ„Ž) of the triangle.

Using the formula for area of a triangle, we can substitute in the known information: 399โˆš3=38ร—โ„Ž2. We can now solve to find โ„Ž by multiplying both sides of the equation by 2 and dividing by 38: โ„Ž=(2)๏€ป399โˆš3๏‡38=21โˆš3.cm

2. Use Trigonometry in Conjunction with Triangle Height to Find Side Length ๐‘

Now that we have found the height of the triangle, let us observe triangle ๐ด๐ถ๐ท. Upon inspection, we see this is a right triangle with one known side (๐‘) and one known angle (๐ถ).

We can therefore use the rules of trigonometry to find side length ๐‘: sinoppositehypotenuse๐œƒ=. Looking at angle ๐ถ, we find that โ„Ž is the opposite side and ๐‘ is the hypotenuse (within triangle ๐ด๐ถ๐ท): sin๐ถ=โ„Ž๐‘. We can substitute in the known information and rearrange our equation to find ๐‘:sinsinsin60=21โˆš3๐‘๐‘(60)=21โˆš3๐‘=21โˆš360.โˆ˜โˆ˜โˆ˜ Recognizing that sin60โˆ˜ is one of the exact trigonometric ratios then allows us to solve:๐‘=21โˆš3๏€ฝ๏‰=(2)๏€ป21โˆš3๏‡โˆš3=(2)(21)=42.โˆš๏Šฉ๏Šจcm Since we have been asked to give our answer to one decimal place, we write ๐‘=42.0cm.

Here we see our triangle with the new information.

3. Use the Law of Cosines to Solve for the Remaining Unknowns

Now that we have found ๐‘, we have a familiar situation within triangle ๐ด๐ต๐ถ, where a known angle is enclosed between two known side lengths: ๐ถโŸน,๐‘โŸน,๐‘ŽโŸน,๐‘โŸน.theangleenclosedbytwoknownsidesthesideoppositetheenclosedangleoneoftheadjacentsidestotheenclosedangleoneoftheadjacentsidestotheenclosedangle Using the first form of the law of cosines, we formulate a relationship between angle ๐ถ and the three sides of our triangle: ๐‘=๐‘Ž+๐‘โˆ’2๐‘Ž๐‘โ‹…๐ถ.๏Šจ๏Šจ๏Šจcos We now substitute in the known information from our triangle: ๐‘=38+42โˆ’2(38)(42)โ‹…60.๏Šจ๏Šจ๏Šจโˆ˜cos Next, we simplify the right-hand side of our equation, recognizing that cos60โˆ˜ is one of the exact trigonometric ratios: ๐‘=1,444+1,764โˆ’3,192โ‹…12=1,612.๏Šจ

We can now take the square root of both sides of our equation, ignoring the negative solution since we are solving to find the length, ๐‘. Our answer is rounded to one decimal place, as stated in the question: ๐‘=โˆš1,612=40.149โ€ฆโ‰ˆ40.1.cm

We now have a triangle with three known sides and one known angle.

The second form of the law of cosines can be used to find either of the remaining angles, but letโ€™s choose angle ๐ต and construct a relationship using the following equation: cos๐ต=๐‘Ž+๐‘โˆ’๐‘2๐‘Ž๐‘.๏Šจ๏Šจ๏Šจ We first substitute in our side lengths into the equation: cos๐ต=38+๏€บโˆš1,612๏†โˆ’42(2)(38)๏€บโˆš1,612๏†.๏Šจ๏Šจ๏Šจ We can now solve for ๐ต, by simplifying our terms and taking the inverse cosine of both sides. Our answer is rounded to the nearest degree as stated in the question: ๐ต=๏€ผ1,2923,051.378โ€ฆ๏ˆ=64.949โ€ฆโ‰ˆ65.cos๏Šฑ๏Šงโˆ˜โˆ˜

Now that we have found two angles, we can use the fact that angles in a triangle sum to 180โˆ˜ to solve for ๐ด, giving our answer to the nearest degree: ๐ด=180โˆ’64.949โ€ฆโˆ’60=55.051โ€ฆโ‰ˆ55.โˆ˜

Key Points

  1. The law of cosines allows us to relate all three sides of a triangle with one of its angles.
  2. The law of cosines can be viewed as a generalized form of the Pythagorean theorem and will work for all triangles.
  3. In order to find an unknown side length in a triangle when given its opposite angle and the two adjacent side lengths, we can use the following form of the law of cosines: ๐‘Ž=๐‘+๐‘โˆ’2๐‘๐‘โ‹…๐ด.๏Šจ๏Šจ๏Šจcos
  4. In order to find an unknown angle in a triangle when given all three side lengths, we can use the following rearranged form of the law of cosines: cos๐ด=๐‘+๐‘โˆ’๐‘Ž2๐‘๐‘.๏Šจ๏Šจ๏Šจ

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.