Skip to main content

Law of Cosines

Even though the Law of Sines enables us to solve many oblique triangles, it does not help with triangles where the known angle is between two known sides or when all three sides are known but no angles are known. We refer to these triangles are SAS (side-angle-side) and SSS (side-side-side) triangles respectively and for these cases, we can use the Law of Cosines to find the unknown angles or sides.

Law of Cosines

In order to derive the Law of Cosines, we need to use the Generalized Pythagorean Theorem, which is an extension of the Pythagorean Theorem for non-right triangles. To derive this theorem, we place an arbitrary non-right triangle ABCABC somewhere in the coordinate plane where the vertex AA is at the origin, the side cc is drawn along the xx-axis, and the vertex CC is located at some point (x,y)(x, y) in the plane.

Generalized Pythagorean Theorem
Fig. 1 - Generalized Pythagorean Theorem
note

The triangle could have been placed anywhere in the plane but for the sake of simplicity, we placed it in this specific location making it easier to derive the theorem with.

When we draw a perpendicular line from CC to the xx-axis, we get a right triangle which lets us get these identities:

cosθ=x (adjacent)b (hypotenuse)sinθ=y (opposite)b (hypotenuse)x=bcosθy=bsinθ\begin{array}{cccccccccccccc} \cos \theta = \dfrac{x \text{ (adjacent)}}{b \text{ (hypotenuse)}} &&&& \sin \theta = \dfrac{y \text{ (opposite)}}{b \text{ (hypotenuse)}} \\[1.5em] x = b \cos \theta &&&& y = b \sin \theta \end{array}

Now if we use the side (xc)(x - c) as one leg of a right triangle and yy as the second leg, we can find the length of hypotenuse aa using the Pythagorean Theorem...

a2=(xc)2+y2=(bcosθc)2+(bsinθ)2=(b2cos2θ2bccosθ+c2)+(b2sin2θ)=b2(cos2θ+sin2θ)+c22bccosθa2=b2+c22bccosθ\begin{array}{cccccccccccccc} a^2 &=& (x - c)^2 + y^2 \\[1em] &=& (b \cos \theta - c)^2 + (b \sin \theta)^2 \\[1em] &=& (b^2 \cos^2 \theta - 2bc \cos \theta + c^2) + (b^2 \sin^2 \theta) \\[1em] &=& b^2 (\cos^2 \theta + \sin^2 \theta) + c^2 - 2bc \cos \theta \\[1em] a^2 &=& b^2 + c^2 - 2bc \cos \theta \end{array}

The formula we derived is one of the three equations of the Law of Cosines and the other equations can be found in a similar fashion. However, all of these equations state that the square of any side of a triangle is equal to the sum of the squares of the other two sides minus the product of the other two sides and the cosine of the included angle. This means all the equations for the Law of Cosines are...

  1. a2=b2+c22bccosαa^2 = b^2 + c^2 - 2bc \cos \alpha
  2. b2=a2+c22accosβb^2 = a^2 + c^2 - 2ac \cos \beta
  3. c2=a2+b22abcosγc^2 = a^2 + b^2 - 2ab \cos \gamma

...where α\alpha, β\beta, and γ\gamma are the angles opposite to sides aa, bb, and cc respectively.

note

To make solving for an angle easier, we can rearrange the Law of Cosines in terms of cosine which gives us...

  1. cosα=b2+c2a22bc\cos \alpha = \dfrac{b^2 + c^2 - a^2}{2bc} \\[1.5em]
  2. cosβ=a2+c2b22ac\cos \beta = \dfrac{a^2 + c^2 - b^2}{2ac} \\[1.5em]
  3. cosγ=a2+b2c22ab\cos \gamma = \dfrac{a^2 + b^2 - c^2}{2ab}

Example\underline{Example}

Find the missing side and angles of the given triangle: α=30\alpha = 30^\circ, b=12b = 12, c=24c = 24.

We can use the Law of Cosine to find the value of the unknown side aa. For this case, we will use the formula a2=b2+c22bccosαa^2 = b^2 + c^2 - 2bc \cos \alpha because we know the value of α\alpha, bb, and cc leaving only aa as the unknown variable...

a2=b2+c22bccosαa2=122+24221224cos30=144+57657632=7202883a221.13a14.9\begin{array}{cccccccccccccc} a^2 &=& b^2 + c^2 - 2bc \cos \alpha \\[1em] a^2 &=& 12^2 + 24^2 - 2 \cdot 12 \cdot 24 \cdot \cos 30^\circ \\[1em] &=& 144 + 576 - 576 \cdot \dfrac{\sqrt{3}}{2} \\[1em] &=& 720 - 288\sqrt{3} \\[1em] a &\approx& \sqrt{221.13} \\[1em] a &\approx& 14.9 \end{array}

Now we can find one of the missing angles using all the three sides. For this case, let's find the value of β\beta.

cosβ=a2+c2b22accosβ(14.9)2+(24)2(12)2214.924cosβ222.01+576144214.924cosβ654.01715.2βcos1(654.01715.2)β23.9\begin{array}{cccccccccccccc} \cos \beta &=& \dfrac{a^2 + c^2 - b^2}{2ac} \\[1.5em] \cos \beta &\approx& \dfrac{(14.9)^2 + (24)^2 - (12)^2}{2 \cdot 14.9 \cdot 24} \\[1.5em] \cos \beta &\approx& \dfrac{222.01 + 576 - 144}{2 \cdot 14.9 \cdot 24} \\[1.5em] \cos \beta &\approx& \dfrac{654.01}{715.2} \\[1.5em] \beta &\approx& \cos^{-1} \left(\dfrac{654.01}{715.2}\right) \\[1.5em] \beta &\approx& 23.9^\circ \end{array}

Finally, we can find the last angle using the fact that the sum of all angles in a triangle is 180180^\circ.

180=α+β+γ30+23.9+γ53.9+γ126.1γ\begin{array}{cccccccccccccc} 180^\circ &=& \alpha + \beta + \gamma \\[1.5em] &\approx& 30^\circ + 23.9^\circ + \gamma \\[1.5em] &\approx& 53.9^\circ + \gamma \\[1.5em] 126.1^\circ &\approx& \gamma \end{array}

So, all the angles of the triangle are α=30\alpha = 30^\circ, β23.9\beta \approx 23.9^\circ, and γ126.1\gamma \approx 126.1^\circ and all the sides are a14.9a \approx 14.9, b=12b = 12, and c=24c = 24.

Heron's Formula

We can use the Law of Cosines to derive the Heron's Formula which is a valuable formula because it allows us to find the area of an oblique triangle when we know the lengths of all three sides.

To derive this formula, let aa, bb, and cc be the sides of the triangle and α\alpha, β\beta, and γ\gamma be the opposite angles to the sides respectively. To derive the formula, we can use any of the Law of Cosines equations to express one of the angles in terms of the sides. In this case, we can use the formula...

cosγ=a2+b2c22ab\cos \gamma = \dfrac{a^2 + b^2 - c^2}{2ab}

With this formula, aa would be the base of the triangle meaning the altitude/height would be bsinγb \sin \gamma. Finally, we will also need the trigonometric identity sinγ=1cos2γ\sin \gamma = \sqrt{1 - \cos^2 \gamma}. Putting this all together, we can derive Heron's Formula...

A=12(base)(altitude)=12(a)(bsinγ)=12ab1cos2γ=12ab1(a2+b2c22ab)2=12ab1(a2+b2c2)24a2b2=12ab4a2b2(a2+b2c2)24a2b2=12ab4a2b2(a2+b2c2)22ab=144a2b2(a2+b2c2)2=14(2ab)2(a2+b2c2)2=14(2ab+(a2+b2c2))(2ab(a2+b2c2))=14(a2+2ab+b2c2)(c2a2+2abb2)=14((a+b)2c2)(c2(ab)2)=14((a+b)c)((a+b)+c)(c(ab))(c+(ab))=(a+bc)(a+b+c)(cab)(c+ab)16=(a+b+c2)(b+ca2)(a+cb2)(a+bc2)\begin{array}{cccccccccccccc} A &=& \dfrac{1}{2} (\text{base})(\text{altitude}) \\[1.5em] &=& \dfrac{1}{2} (a) (b \sin \gamma) \\[1.5em] &=& \dfrac{1}{2}ab \sqrt{1 - \cos^2 \gamma} \\[1.5em] &=& \dfrac{1}{2}ab \sqrt{1 - \left(\dfrac{a^2 + b^2 - c^2}{2ab}\right)^2} \\[1.5em] &=& \dfrac{1}{2}ab \sqrt{1 - \dfrac{\left(a^2 + b^2 - c^2\right)^2}{4a^2b^2}} \\[1.5em] &=& \dfrac{1}{2}ab \sqrt{\dfrac{4a^2b^2 - \left(a^2 + b^2 - c^2\right)^2}{4a^2b^2}} \\[1.5em] &=& \dfrac{1}{2}ab \cdot \dfrac{\sqrt{4a^2b^2 - \left(a^2 + b^2 - c^2\right)^2}}{2ab} \\[1.5em] &=& \dfrac{1}{4}\sqrt{4a^2b^2 - \left(a^2 + b^2 - c^2\right)^2} \\[1.5em] &=& \dfrac{1}{4}\sqrt{\left(2ab\right)^2 - \left(a^2 + b^2 - c^2\right)^2} \\[1.5em] &=& \dfrac{1}{4}\sqrt{\left(2ab + (a^2 + b^2 - c^2)\right)\left(2ab - (a^2 + b^2 - c^2)\right)} \\[1.5em] &=& \dfrac{1}{4}\sqrt{\left(a^2 + 2ab + b^2 - c^2\right)\left(c^2 - a^2 + 2ab - b^2\right)} \\[1.5em] &=& \dfrac{1}{4}\sqrt{\left((a + b)^2 - c^2\right)\left(c^2 - (a - b)^2\right)} \\[1.5em] &=& \dfrac{1}{4}\sqrt{\left((a + b) - c\right)\left((a + b) + c\right)\left(c - (a - b)\right)\left(c + (a - b)\right)} \\[1.5em] &=& \sqrt{\dfrac{\left(a + b - c\right)\left(a + b + c\right)\left(c - a - b\right)\left(c + a - b\right)}{16}} \\[1.5em] &=& \sqrt{\left(\dfrac{a + b + c}{2}\right)\left(\dfrac{b + c - a}{2}\right)\left(\dfrac{a + c - b}{2}\right)\left(\dfrac{a + b - c}{2}\right)} \end{array}

We can simplify this formula even further by substituting s=a+b+c2s = \dfrac{a + b + c}{2}, which is one half of the perimeter of the triangle also known as the semi-perimeter. This gives us the final form of Heron's Formula...

A=s(sa)(sb)(sc)A = \sqrt{s(s - a)(s - b)(s - c)}

where s=a+b+c2s = \dfrac{a + b + c}{2} is the semi-perimeter of the triangle.

Example\underline{Example}

Use Heron's formula to find the area of a triangle with sides of lengths a=29.7 fta = 29.7 \text{ ft}, b=42.3 ftb = 42.3 \text{ ft}, and c=38.4 ftc = 38.4 \text{ ft}.

First, we need to find the semi-perimeter ss...

s=a+b+c2=29.7+42.3+38.42=55.2 fts = \dfrac{a + b + c}{2} = \dfrac{29.7 + 42.3 + 38.4}{2} = 55.2 \text{ ft}

Now we can use Heron's formula to find the area of the triangle...

A=s(sa)(sb)(sc)=55.2(55.229.7)(55.242.3)(55.238.4)=55.2(25.5)(12.9)(16.8)=305055.072552 ft2\begin{array}{cccccccccccccc} A &=& \sqrt{s(s - a)(s - b)(s - c)} \\[1.5em] &=& \sqrt{55.2(55.2 - 29.7)(55.2 - 42.3)(55.2 - 38.4)} \\[1.5em] &=& \sqrt{55.2(25.5)(12.9)(16.8)} \\[1.5em] &=& \sqrt{305055.072} \\[1.5em] &\approx& 552 \text{ ft}^2 \end{array}

Therefore, the area of the triangle is approximately 552 ft2552 \text{ ft}^2.

Real World Applications

Just like with the Law of Sines, the Law of Cosine is an invaluable tool in various fields because with both these laws, we can solve all possible oblique triangles.

Example\underline{Example}

Suppose a boat leaves port, travels 1010 miles, turns 2020 degrees, and travels another 88 miles. How far from port is the boat?

Law of Cosines Real World Example
Fig. 2 - Law of Cosines Real World Example

We can label the values of the triangle as a=8a = 8, b=10b = 10, and γ=18020=160\gamma = 180^\circ - 20^\circ = 160^\circ. To find the distance from the boat to the port, we will need to find the value of the side cc which we can do using the Law of Cosines...

c2=a2+b22abcosγ=(8)2+(10)22(8)(10)cos(160)=64+100160cos(160)=164160cos(160)c2314.35c314.35c17.7 miles\begin{array}{cccccccccccccc} c^2 &=& a^2 + b^2 - 2ab \cos \gamma \\[1.5em] &=& (8)^2 + (10)^2 - 2(8)(10) \cos(160^\circ) \\[1.5em] &=& 64 + 100 - 160 \cos(160^\circ) \\[1.5em] &=& 164 - 160 \cos(160^\circ) \\[1.5em] c^2 &\approx& 314.35 \\[1.5em] c &\approx& \sqrt{314.35} \\[1.5em] c &\approx& 17.7 \text{ miles} \end{array}

Therefore, the distance from the boat to the port is approximately 17.7 miles17.7 \text{ miles}.