Skip to content
Non-right Triangles - Law of Cosines

Non-right Triangles - Law of Cosines

By the end of this section, you will be able to:

  • Use the Law of Cosines to solve oblique triangles
  • Solve applied problems using the Law of Cosines
  • Use Heron’s formula to find the area of a triangle

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

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.

Using the Law of Cosines to Solve Oblique Triangles

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.

Understanding how the Law of Cosines is derived will be helpful in using the formulas. The derivation begins with the Generalized Pythagorean Theorem, an extension of the Pythagorean Theorem to non-right triangles. Here is how it works: an arbitrary non-right triangle ABCABC is placed in the coordinate plane with vertex AA at the origin, side cc drawn along the xx-axis, and vertex CC located at some point (x,y)(x,y) in the plane, as shown below. Generally, triangles exist anywhere in the plane, but for this explanation we will place the triangle as noted.

We can drop a perpendicular from CC to the xx-axis (this is the altitude or height). Recalling the basic trigonometric identities, we know that

cosθ=x (adjacent)b (hypotenuse) and sinθ=y (opposite)b (hypotenuse)\cos\theta=\tfrac{x\ (\text{adjacent})}{b\ (\text{hypotenuse})}\ \text{and}\ \sin\theta=\tfrac{y\ (\text{opposite})}{b\ (\text{hypotenuse})}

In terms of θ\theta, x=bcosθx=b\cos\theta and y=bsinθy=b\sin\theta. The (x,y)(x,y) point located at CC has coordinates (bcosθ,bsinθ)(b\cos\theta,b\sin\theta). Using 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. Thus,

a2=(xc)2+y2=(bcosθc)2+(bsinθ)2Substitute (bcosθ) for x and (bsinθ) for y.=(b2cos2θ2bccosθ+c2)+b2sin2θExpand the perfect square.=b2cos2θ+b2sin2θ+c22bccosθGroup terms noting that cos2θ+sin2θ=1.=b2(cos2θ+sin2θ)+c22bccosθFactor out b2.a2=b2+c22bccosθ \begin{array}{lrcl} & a^2 &=& (x-c)^2+y^2 \\[4pt] & &=& (b\cos\theta-c)^2+(b\sin\theta)^2 \\[4pt] \text{Substitute }(b\cos\theta)\text{ for }x\text{ and }(b\sin\theta)\text{ for }y. & &=& (b^2\cos^2\theta-2bc\cos\theta+c^2)+b^2\sin^2\theta \\[4pt] \text{Expand the perfect square.} & &=& b^2\cos^2\theta+b^2\sin^2\theta+c^2-2bc\cos\theta \\[4pt] \text{Group terms noting that }\cos^2\theta+\sin^2\theta=1. & &=& b^2(\cos^2\theta+\sin^2\theta)+c^2-2bc\cos\theta \\[4pt] \text{Factor out }b^2. & a^2 &=& b^2+c^2-2bc\cos\theta \end{array}

The formula derived is one of the three equations of the Law of Cosines. The other equations are found in a similar fashion.

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.

Law of Cosines.

The Law of Cosines states that the square of any side of a triangle is equal to the sum of the squares of the other two sides minus twice the product of the other two sides and the cosine of the included angle. For triangles labeled as below, with angles α\alpha, β\beta, and γ\gamma, and opposite corresponding sides aa, bb, and cc, respectively, the Law of Cosines is given as three equations.

a2=b2+c22bccosαb2=a2+c22accosβc2=a2+b22abcosγ \begin{array}{l} a^2=b^2+c^2-2bc\cos\alpha \\ b^2=a^2+c^2-2ac\cos\beta \\ c^2=a^2+b^2-2ab\cos\gamma \end{array}

Figure: An oblique triangle with standard labels: angles alpha, beta, gamma with opposite sides a, b, c.

To solve for a missing side measurement, the corresponding opposite angle measure is needed.

When solving for an angle, the corresponding opposite side measure is needed. We can use another version of the Law of Cosines to solve for an angle.

cosα=b2+c2a22bccosβ=a2+c2b22accosγ=a2+b2c22ab \begin{array}{l} \cos\alpha=\tfrac{b^2+c^2-a^2}{2bc} \\ \cos\beta=\tfrac{a^2+c^2-b^2}{2ac} \\ \cos\gamma=\tfrac{a^2+b^2-c^2}{2ab} \end{array}

How To: given two sides and the angle between them (SAS), find the measures of the remaining side and angles of a triangle.

  1. Sketch the triangle. Identify the measures of the known sides and angles. Use variables to represent the measures of the unknown sides and angles.
  2. Apply the Law of Cosines to find the length of the unknown side or angle.
  3. Apply the Law of Sines or Cosines to find the measure of a second angle.
  4. Compute the measure of the remaining angle.

Example. Find the unknown side and angles of the triangle below.

Solution. First, make note of what is given: two sides and the angle between them. This arrangement is classified as SAS and supplies the data needed to apply the Law of Cosines.

Each one of the three laws of cosines begins with the square of an unknown side opposite a known angle. For this example, the first side to solve for is side bb, as we know the measurement of the opposite angle β\beta.

b2=a2+c22accosβSubstitute the measurements for the known quantities.b2=102+1222(10)(12)cos(30)Evaluate the cosine and begin to simplify.b2=100+144240(32)b2=2441203Use the square root property.b=2441203b6.013 \begin{array}{lrcl} & b^2 &=& a^2+c^2-2ac\cos\beta \\[4pt] \text{Substitute the measurements for the known quantities.} & b^2 &=& 10^2+12^2-2(10)(12)\cos(30^\circ) \\[4pt] \text{Evaluate the cosine and begin to simplify.} & b^2 &=& 100+144-240\left(\tfrac{\sqrt3}{2}\right) \\[4pt] & b^2 &=& 244-120\sqrt3 \\[4pt] \text{Use the square root property.} & b &=& \sqrt{244-120\sqrt3} \\[4pt] & b &\approx& 6.013 \end{array}

Because we are solving for a length, we use only the positive square root. Now that we know the length bb, we can use the Law of Sines to fill in the remaining angles of the triangle. Solving for angle α\alpha, we have

sinαa=sinβbsinα10=sin(30)6.013Multiply both sides of the equation by 10.sinα=10sin(30)6.013Find the inverse sine of 10sin(30)6.013.α=sin1(10sin(30)6.013)α56.3 \begin{array}{lrcl} & \tfrac{\sin\alpha}{a} &=& \tfrac{\sin\beta}{b} \\[4pt] & \tfrac{\sin\alpha}{10} &=& \tfrac{\sin(30^\circ)}{6.013} \\[4pt] \text{Multiply both sides of the equation by 10.} & \sin\alpha &=& \tfrac{10\sin(30^\circ)}{6.013} \\[4pt] \text{Find the inverse sine of }\tfrac{10\sin(30^\circ)}{6.013}. & \alpha &=& \sin^{-1}\left(\tfrac{10\sin(30^\circ)}{6.013}\right) \\[4pt] & \alpha &\approx& 56.3^\circ \end{array}

The other possibility for α\alpha would be α=18056.3123.7\alpha=180^\circ-56.3^\circ\approx123.7^\circ. In the original diagram, α\alpha is adjacent to the longest side, so α\alpha is an acute angle and, therefore, 123.7123.7^\circ does not make sense. Notice that if we choose to apply the Law of Cosines, we arrive at a unique answer. We do not have to consider the other possibilities, as cosine is unique for angles between 00^\circ and 180180^\circ. Proceeding with α56.3\alpha\approx56.3^\circ, we can then find the third angle of the triangle.

γ=1803056.393.7\gamma=180^\circ-30^\circ-56.3^\circ\approx93.7^\circ

The complete set of angles and sides is

α56.3a=10β=30b6.013γ93.7c=12 \begin{array}{lrcl} & \alpha\approx56.3^\circ & a=10 \\[4pt] & \beta=30^\circ & b\approx6.013 \\[4pt] & \gamma\approx93.7^\circ & c=12 \end{array}

Find the missing sideaaof the triangle withα=30\alpha=30^\circ,b=12b=12, andc=24c=24. Round to the nearest tenth.

Example. Find the angle α\alpha for the given triangle if side a=20a=20, side b=25b=25, and side c=18c=18.

Solution. For this example, we have no angles. We can solve for any angle using the Law of Cosines. To solve for angle α\alpha, we have

a2=b2+c22bccosαSubstitute the appropriate measurements.202=252+1822(25)(18)cosαSimplify in each step.400=625+324900cosα400=949900cosαIsolate cosα.549=900cosα549900=cosα0.61cosαFind the inverse cosine.cos1(0.61)αα52.4 \begin{array}{lrcl} & a^2 &=& b^2+c^2-2bc\cos\alpha \\[4pt] \text{Substitute the appropriate measurements.} & 20^2 &=& 25^2+18^2-2(25)(18)\cos\alpha \\[4pt] \text{Simplify in each step.} & 400 &=& 625+324-900\cos\alpha \\[4pt] & 400 &=& 949-900\cos\alpha \\[4pt] \text{Isolate }\cos\alpha. & -549 &=& -900\cos\alpha \\[4pt] & \tfrac{-549}{-900} &=& \cos\alpha \\[4pt] & 0.61 &\approx& \cos\alpha \\[4pt] \text{Find the inverse cosine.} & \cos^{-1}(0.61) &\approx& \alpha \\[4pt] & \alpha &\approx& 52.4^\circ \end{array}

See the figure below.

Analysis. Because the inverse cosine can return any angle between 00 and 180180 degrees, there will not be any ambiguous cases using this method.

Givena=5a=5,b=7b=7, andc=10c=10, find the missing anglesα\alpha,β\beta, andγ\gamma, in that order, each rounded to the nearest tenth of a degree.

Solving Applied Problems Using the Law of Cosines

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.

Example. 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 6,0006{,}000 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,0505{,}050 feet from the first tower and 2,4202{,}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.

Solution. For simplicity, we start by drawing a diagram similar to the figure below and labeling our given information.

Using the Law of Cosines, we can solve for the angle θ\theta. 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=2,420a=2{,}420, b=5,050b=5{,}050, and c=6,000c=6{,}000. Thus, θ\theta corresponds to the opposite side a=2,420a=2{,}420.

a2=b2+c22bccosθ(2,420)2=(5,050)2+(6,000)22(5,050)(6,000)cosθ(2,420)2(5,050)2(6,000)2=2(5,050)(6,000)cosθ(2,420)2(5,050)2(6,000)22(5,050)(6,000)=cosθcosθ0.9183θcos1(0.9183)θ23.3 \begin{array}{lrcl} & a^2 &=& b^2+c^2-2bc\cos\theta \\[4pt] & (2{,}420)^2 &=& (5{,}050)^2+(6{,}000)^2-2(5{,}050)(6{,}000)\cos\theta \\[4pt] & (2{,}420)^2-(5{,}050)^2-(6{,}000)^2 &=& -2(5{,}050)(6{,}000)\cos\theta \\[4pt] & \tfrac{(2{,}420)^2-(5{,}050)^2-(6{,}000)^2}{-2(5{,}050)(6{,}000)} &=& \cos\theta \\[4pt] & \cos\theta &\approx& 0.9183 \\[4pt] & \theta &\approx& \cos^{-1}(0.9183) \\[4pt] & \theta &\approx& 23.3^\circ \end{array}

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 in the figure below. This forms two right triangles, although we only need the right triangle that includes the first tower for this problem.

Using the angle θ=23.3\theta=23.3^\circ and the basic trigonometric identities, we can find the solutions. Thus

cos(23.3)=x5,050x=5,050cos(23.3)x4,638.15 feetsin(23.3)=y5,050y=5,050sin(23.3)y1,997.5 feet \begin{array}{lrcl} & \cos(23.3^\circ) &=& \tfrac{x}{5{,}050} \\[4pt] & x &=& 5{,}050\cos(23.3^\circ) \\[4pt] & x &\approx& 4{,}638.15\ \text{feet} \\[4pt] & \sin(23.3^\circ) &=& \tfrac{y}{5{,}050} \\[4pt] & y &=& 5{,}050\sin(23.3^\circ) \\[4pt] & y &\approx& 1{,}997.5\ \text{feet} \end{array}

The cell phone is approximately 4,6384{,}638 feet east and 19981998 feet north of the first tower, and 19981998 feet from the highway.

Example. Returning to our problem at the beginning of this section, suppose a boat leaves port, travels 1010 miles, turns 2020 degrees, and travels another 88 miles. How far from port is the boat? The diagram is repeated below.

Solution. The boat turned 2020 degrees, so the obtuse angle of the non-right triangle is the supplemental angle, 18020=160180^\circ-20^\circ=160^\circ. 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.

x2=82+1022(8)(10)cos(160)x2314.35x=314.35x17.7 miles \begin{array}{lrcl} & x^2 &=& 8^2+10^2-2(8)(10)\cos(160^\circ) \\[4pt] & x^2 &\approx& 314.35 \\[4pt] & x &=& \sqrt{314.35} \\[4pt] & x &\approx& 17.7\ \text{miles} \end{array}

The boat is about 17.717.7 miles from port.

Using Heron’s Formula to Find the Area of a Triangle

We already learned how to find the area of an oblique triangle when we know two sides and an angle. We also know the formula to find the area of a triangle using the base and the height. When we know the three sides, however, we can use Heron’s formula instead of finding the height. Heron of Alexandria was a geometer who lived during the first century A.D. He discovered a formula for finding the area of oblique triangles when three sides are known.

Heron’s Formula.

Heron’s formula finds the area of oblique triangles in which sides aa, bb, and cc are known.

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

where s=a+b+c2s=\tfrac{a+b+c}{2} is one half of the perimeter of the triangle, sometimes called the semi-perimeter.

Example. Find the area of the triangle below using Heron’s formula.

Solution. First, we calculate ss.

s=a+b+c2s=10+15+72=16 \begin{array}{lrcl} & s &=& \tfrac{a+b+c}{2} \\[4pt] & s &=& \tfrac{10+15+7}{2}=16 \end{array}

Then we apply the formula.

Area=s(sa)(sb)(sc)Area=16(1610)(1615)(167)Area29.4 \begin{array}{lrcl} & \text{Area} &=& \sqrt{s(s-a)(s-b)(s-c)} \\[4pt] & \text{Area} &=& \sqrt{16(16-10)(16-15)(16-7)} \\[4pt] & \text{Area} &\approx& 29.4 \end{array}

The area is approximately 29.429.4 square units.

Use Heron’s formula to find the area of a triangle with sides of lengthsa=29.7 fta=29.7\ \text{ft},b=42.3 ftb=42.3\ \text{ft}, andc=38.4 ftc=38.4\ \text{ft}. Round to the nearest whole square foot.

Example. A Chicago city developer wants to construct a building consisting of artist’s lofts on a triangular lot bordered by Rush Street, Wabash Avenue, and Pearson Street. The frontage along Rush Street is approximately 62.462.4 meters, along Wabash Avenue it is approximately 43.543.5 meters, and along Pearson Street it is approximately 34.134.1 meters. How many square meters are available to the developer? See the figure below for a view of the city property.

Solution. Find the measurement for ss, which is one-half of the perimeter.

s=62.4+43.5+34.12s=70 m \begin{array}{lrcl} & s &=& \tfrac{62.4+43.5+34.1}{2} \\[4pt] & s &=& 70\ \text{m} \end{array}

Apply Heron’s formula.

Area=70(7062.4)(7043.5)(7034.1)Area=506,118.2Area711.4 \begin{array}{lrcl} & \text{Area} &=& \sqrt{70(70-62.4)(70-43.5)(70-34.1)} \\[4pt] & \text{Area} &=& \sqrt{506{,}118.2} \\[4pt] & \text{Area} &\approx& 711.4 \end{array}

The developer has about 711.4711.4 square meters.

Find the area of a triangle givena=4.38 fta=4.38\ \text{ft},b=3.79 ftb=3.79\ \text{ft}, andc=5.22 ftc=5.22\ \text{ft}. Round to the nearest hundredth.

Key equations

Law of Cosinesa2=b2+c22bccosαb2=a2+c22accosβc2=a2+b22abcosγ\begin{array}{l} a^2=b^2+c^2-2bc\cos\alpha \\ b^2=a^2+c^2-2ac\cos\beta \\ c^2=a^2+b^2-2ab\cos\gamma \end{array}
Heron’s formulaArea=s(sa)(sb)(sc)where s=a+b+c2\begin{array}{l} \text{Area}=\sqrt{s(s-a)(s-b)(s-c)} \\ \text{where}\ s=\tfrac{a+b+c}{2} \end{array}

Key concepts

  • The Law of Cosines defines the relationship among angle measurements and lengths of sides in oblique triangles.
  • The Generalized Pythagorean Theorem is the Law of Cosines for two cases of oblique triangles: SAS and SSS. Dropping an imaginary perpendicular splits the oblique triangle into two right triangles or forms one right triangle, which allows sides to be related and measurements to be calculated.
  • The Law of Cosines is useful for many types of applied problems. The first step in solving such problems is generally to draw a sketch of the problem presented. If the information given fits one of the three models (the three equations), then apply the Law of Cosines to find a solution.
  • Heron’s formula allows the calculation of area in oblique triangles. All three sides must be known to apply Heron’s formula.

Key terms

Law of Cosines — states that the square of any side of a triangle is equal to the sum of the squares of the other two sides minus twice the product of the other two sides and the cosine of the included angle. Generalized Pythagorean Theorem — an extension of the Law of Cosines; relates the sides of an oblique triangle and is used for SAS and SSS triangles.

Practice

Use the Law of Cosines to solve oblique triangles

If possible, solve the triangle for the unknown sidecc:γ=115\gamma=115^\circ,a=18a=18,b=23b=23. Round to the nearest tenth.

Use the Law of Cosines to solve for the missing angle of the oblique triangle witha=14a=14,b=13b=13,c=20c=20: find angleCC. Round to the nearest tenth of a degree.

If possible, solve the triangle for the unknown sideaa:γ=113\gamma=113^\circ,b=10b=10,c=32c=32. Round to the nearest tenth.

If possible, solve the triangle for the unknown sidecc:β=50\beta=50^\circ,a=105a=105,b=45b=45.

Solve applied problems using the Law of Cosines

A satellite calculates the distances and angle shown: two cities are370370km and350350km from the satellite, with an angle of2.12.1^\circbetween those two sightlines. Find the distance between the two cities. Round to the nearest tenth.

A pilot flies in a straight path for11hour3030minutes. She then makes a course correction, heading1010^\circto the right of her original course, and flies22hours in the new direction. If she maintains a constant speed of680680miles per hour, how far is she from her starting position? Round to the nearest mile.

Two boats depart at the same time from the same dock. The first boat travels at1818miles per hour at a heading of327327^\circ, and the second boat travels at44miles per hour at a heading of6060^\circ. Find the distance between the two boats after22hours. Round to the nearest tenth of a mile.

Use Heron’s formula to find the area of a triangle

Find the area of a triangle with sides of length1818in,2121in, and3232in. Round to the nearest hundredth.

Find the area of a triangle witha=1.6 yda=1.6\ \text{yd},b=2.6 ydb=2.6\ \text{yd}, andc=4.1 ydc=4.1\ \text{yd}. Round to the nearest hundredth.

Find the area of a triangle witha=12 ma=\tfrac12\ \text{m},b=13 mb=\tfrac13\ \text{m}, andc=14 mc=\tfrac14\ \text{m}. Round to the nearest hundredth.


This section is adapted from Precalculus 2e, Section 8.2: Non-right Triangles: Law of Cosines by Jay Abramson and OpenStax, © OpenStax, licensed under CC BY-NC-SA 4.0. Access the original for free at openstax.org. Changes: recreated all instructional figures as accessible spec-first SVGs built from exact Law-of-Cosines/coordinate computations (never traced) — the opening boat triangle (repeated verbatim at Example 4, matching the source’s own repetition); the coordinate-plane derivation triangle ABCABC with its dashed altitude and xcx-c/yy legs; the standard α,β,γ\alpha,\beta,\gamma/a,b,ca,b,c labeling triangle; the two worked-example triangles (SAS and SSS); the cell-tower triangle and its right-triangle decomposition; the Heron’s-formula example triangle labeled A,B,CA,B,C; and the Chicago building-lot triangle, whose decorative angled-street-grid background (no primitive in this engine’s figure spec draws city blocks) was simplified to a plain labeled triangle carrying the same three street names and frontages, since that information — not the map art — is what the problem uses. Omitted the decorative boat-hull, cell-tower, and antenna photo overlays, which carry no mathematics, and the “Access these online resources” media links. Every retained Try It became a real fillin component. Where a Try It’s printed solution mixes units the grader cannot compose in one answerForm (a decimal side alongside two degree-valued angles), a single quantity was asked instead of the full solved triangle, following the same adaptation used in Section 8.1: the first Try It (originally a14.9a\approx14.9, β23.8\beta\approx23.8^\circ, γ126.2\gamma\approx126.2^\circ) asks only for side aa, because computing β\beta from a rounded a=14.9a=14.9 grades 23.923.9^\circ — one tenth off the source’s own 23.823.8^\circ, which only the full-precision chain reproduces — so publishing β\beta as a second fillin here would have required pinning a rounded intermediate that does not actually match the printed key. The second Try It’s three angles compose cleanly into one answerForm="degrees" list because each is solved directly from the original aa, bb, cc with its own Law of Cosines formula, with no chained rounding step between them. Every degree-valued answer is keyed with answerForm="degrees" alone (never composed with decimal, which self-rejects a trailing ^\circ); every Heron’s-formula area is a decimal fillin. The Practice item drawn from the “solve for the unknown side” exercise set with β=50\beta=50^\circ, a=105a=105, b=45b=45 — whose Law of Cosines equation has no real solution for cc — is authored as a multiplechoice on the triangle count, since “not possible” is a categorical judgment, not a number. Adapted ten selected end-of-section exercises — four Algebraic (three Law of Cosines solves for a side or angle, one no-triangle recognition), three Real-World word problems, and three Heron’s-formula area computations — into a closing Practice block, one group per objective, every answer independently re-derived by running the Law of Cosines and Heron’s-formula arithmetic in Node rather than read off the source key. The area exercise with sides 1818 in, 2121 in, and 3232 in restates its own rounding instruction as “round to the nearest hundredth”: the source’s individual exercise text says “Round to the nearest tenth,” contradicting both the surrounding exercise group’s stated “Round to the nearest hundredth” and the source’s own printed answer key of 177.56 in2177.56\ \text{in}^2, which is precise to hundredths — logged as errata.