Math Core

Lesson 9.7 · Right Triangles and Trigonometry

The law of cosines

The law of sines needs a side paired with its opposite angle. But what if you know two sides and the angle between them (SAS), or all three sides (SSS)? Then there's no complete pair, and you need a different tool: the law of cosines, which is the Pythagorean theorem upgraded to work for every triangle.

The formula

The law of cosines

In any triangle ABCABC,

c2=a2+b2−2abcos⁡C.c^2 = a^2 + b^2 - 2ab \cos C.

The same pattern works for each side:

a2=b2+c2−2bccos⁡Ab2=a2+c2−2accos⁡Ba^2 = b^2 + c^2 - 2bc \cos A \qquad b^2 = a^2 + c^2 - 2ac \cos B

The pattern to remember: the side on the left and the angle at the end are opposite each other, and the other two sides appear everywhere else.

Why it works

Put the triangle on a coordinate plane with CC at the origin and side aa along the positive xx-axis, so B=(a,0)B = (a, 0). Point AA is a distance bb from the origin, at angle CC above the axis. By the definitions of sine and cosine, its coordinates are (bcos⁡C,  bsin⁡C)(b \cos C, \; b \sin C).

Place C at the origin with side a along the x-axis.

Now cc is the distance from AA to BB. Use the distance formula (which is itself the Pythagorean theorem):

c2=(bcos⁡C−a)2+(bsin⁡C−0)2=b2cos⁡2C−2abcos⁡C+a2+b2sin⁡2C=b2(cos⁡2C+sin⁡2C)+a2−2abcos⁡C=a2+b2−2abcos⁡C\begin{aligned} c^2 &= (b \cos C - a)^2 + (b \sin C - 0)^2 \\ &= b^2 \cos^2 C - 2ab \cos C + a^2 + b^2 \sin^2 C \\ &= b^2(\cos^2 C + \sin^2 C) + a^2 - 2ab \cos C \\ &= a^2 + b^2 - 2ab \cos C \end{aligned}

The last step uses sin⁡2C+cos⁡2C=1\sin^2 C + \cos^2 C = 1 from the sine and cosine lesson. (Here cos⁡2C\cos^2 C is shorthand for (cos⁡C)2(\cos C)^2.)

Connection to the Pythagorean theorem

If C=90∘C = 90^\circ, then cos⁡C=0\cos C = 0 and the formula becomes c2=a2+b2c^2 = a^2 + b^2: the Pythagorean theorem is the special case. The term −2abcos⁡C-2ab \cos C is the correction for a triangle that isn't right.

  • If CC is acute, cos⁡C>0\cos C > 0, so you subtract, and c2<a2+b2c^2 < a^2 + b^2.
  • If CC is obtuse, cos⁡C<0\cos C < 0 (your calculator will show a negative number), so you add, and c2>a2+b2c^2 > a^2 + b^2.

That's exactly the acute/obtuse test from the first lesson of this unit, now with a reason behind it.

SAS: finding the third side

Worked example: Two sides and the included angle

In triangle ABCABC, a=8a = 8, b=11b = 11 and C=40∘C = 40^\circ. Find cc to the nearest tenth.

c2=82+112−2(8)(11)cos⁡40∘=64+121−176cos⁡40∘≈185−134.82=50.18c≈50.18≈7.1\begin{aligned} c^2 &= 8^2 + 11^2 - 2(8)(11)\cos 40^\circ \\ &= 64 + 121 - 176 \cos 40^\circ \\ &\approx 185 - 134.82 = 50.18 \\ c &\approx \sqrt{50.18} \approx 7.1 \end{aligned}

Worked example: Two ships

Two ships leave the same port. One sails 3030 miles on a straight course, and the other sails 5050 miles on a course that makes a 120∘120^\circ angle with the first. How far apart are the ships?

d2=302+502−2(30)(50)cos⁡120∘=900+2500−3000(−0.5)=3400+1500=4900d=70 miles\begin{aligned} d^2 &= 30^2 + 50^2 - 2(30)(50)\cos 120^\circ \\ &= 900 + 2500 - 3000(-0.5) \\ &= 3400 + 1500 = 4900 \\ d &= 70 \text{ miles} \end{aligned}

Because 120∘120^\circ is obtuse, its cosine is negative, and the ships end up farther apart than the Pythagorean theorem would suggest (3400≈58.3\sqrt{3400} \approx 58.3).

SSS: finding an angle

Solve the formula for the cosine:

cos⁡C=a2+b2−c22ab\cos C = \frac{a^2 + b^2 - c^2}{2ab}

Then use cos⁡−1\cos^{-1}. Unlike sin⁡−1\sin^{-1}, the inverse cosine gives angles all the way from 0∘0^\circ to 180∘180^\circ, so a negative cosine correctly gives an obtuse angle. There's no ambiguous case.

Worked example: All three sides

A triangle has sides a=7a = 7, b=9b = 9 and c=13c = 13. Find the largest angle, to the nearest tenth of a degree.

The largest angle is opposite the longest side, so find CC.

cos⁡C=72+92−1322(7)(9)=49+81−169126=−39126≈−0.3095\cos C = \frac{7^2 + 9^2 - 13^2}{2(7)(9)} = \frac{49 + 81 - 169}{126} = \frac{-39}{126} \approx -0.3095

C=cos⁡−1(−0.3095)≈108.0∘C = \cos^{-1}(-0.3095) \approx 108.0^\circ

The negative cosine told us right away that the triangle is obtuse.

Tip

When solving an SSS triangle completely, find the largest angle first with the law of cosines. The other two angles are then guaranteed to be acute, so you can safely finish with the law of sines (or the law of cosines again) without worrying about the ambiguous case.

Common mistake

Evaluate in the right order. In 185−176cos⁡40∘185 - 176 \cos 40^\circ, multiply 176cos⁡40∘176 \cos 40^\circ first, then subtract. A common mistake is to compute 185−176=9185 - 176 = 9 and then multiply by cos⁡40∘\cos 40^\circ. If your calculator allows it, type the whole expression at once.

Which law should I use?

You knowUse first
a right triangletrig ratios and the Pythagorean theorem
AAS or ASAlaw of sines
SSAlaw of sines (check the ambiguous case)
SASlaw of cosines
SSSlaw of cosines

Practice

Practice 1

In triangle ABCABC, a=5a = 5, b=8b = 8 and C=60∘C = 60^\circ. Find cc.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

In triangle ABCABC, a=10a = 10, b=14b = 14 and C=35∘C = 35^\circ. Find cc to the nearest tenth.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

A triangle has sides 33, 55 and 77. Find the measure of its largest angle, in degrees.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

A triangle has sides 66, 99 and 1111. Find its smallest angle, to the nearest tenth of a degree.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

In triangle ABCABC, you know a=12a = 12, b=15b = 15 and C=48∘C = 48^\circ. Which tool should you use to find cc?

Practice 6

A parallelogram has sides 66 and 1010, and one of its angles measures 120∘120^\circ. Find the length of the diagonal that lies opposite the 120∘120^\circ angle.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

A golf hole is 380380 yards from the tee. A golfer hits a drive 240240 yards, but 12∘12^\circ off the straight line to the hole. How far is the ball from the hole, to the nearest tenth of a yard?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

A triangle has sides 88, 1010 and 1212. Find the angle opposite the side of length 1212, to the nearest tenth of a degree.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.