Skip to main content
Mathematics LibreTexts

27.34: Law of Cosines

  • Page ID
    248199
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\ket}[1]{\left| #1 \right>}\)
    \(\newcommand{\bra}[1]{\left< #1 \right|}\)
    \(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
    \(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
    \(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
    \(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
    \(\newcommand{\expect}[1]{\langle #1 \rangle}\)
    \(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Videos

    Lecture: The Law of Cosines - Theorem and Proof (level = trigonometry)

    Lecture: Using the Law of Cosines to Solve Triangles (level = trigonometry)

    Lecture: Applications Involving the Law of Cosines (level = trigonometry)

    Review: The Law of Cosines (level = precalculus)

    Review: Applications Involving the Law of Cosines (level = precalculus)

    Review: Navigation Applications Involving the Law of Cosines (level = precalculus)

    Definitions and Theorems

    Notation: Standard Labeling of a Triangle

    In \(\triangle ABC\), the lowercase letters \(a\), \(b\), and \(c\) denote the lengths of the sides opposite the vertices \(A\), \(B\), and \(C\), respectively. The Greek letters \(\alpha\), \(\beta\), and \(\gamma\) denote the measures of \(\angle A\), \(\angle B\), and \(\angle C\), respectively. Thus each angle and the side opposite it share a letter.

    263401.png

    Figure \(\PageIndex{1}\): \(\triangle ABC\). Side \(a\) is labeled on \(\overline{BC}\), side \(b\) on \(\overline{AC}\), and side \(c\) on \(\overline{AB}\); angle measures \(\alpha\), \(\beta\), and \(\gamma\) are labeled at \(A\), \(B\), and \(C\).
    Definition: Included Angle

    The included angle of two sides of a triangle is the angle formed by those two sides, that is, the angle whose vertex is the common endpoint of the two sides.

    Definition: Solving a Triangle

    To solve a triangle is to determine all three side lengths and all three angle measures from the subset of these values that is given.

    Notation: SAS and SSS

    Given data are abbreviated by listing sides (S) and angles (A) in the order they occur around the triangle. SAS denotes two sides and their included angle; SSS denotes all three sides.

    Theorem: Law of Cosines

    If the angles of a triangle are \(A\), \(B\), and \(C\), and the opposite sides are respectively \(a\), \(b\), and \(c\), then\[ \begin{array}{rcl}
    a^2 & = & b^2+c^2-2 b c \cos \left(A\right) \\[6pt] b^2 & = & a^2+c^2-2 a c \cos\left( B\right) \\[6pt] c^2 & = & a^2+b^2-2 a b \cos \left(C\right) \\[6pt] \end{array} \nonumber \]

    Proof

    Start with general triangles as seen in the figures below.

    Two general triangles, one acute (left) and one obtuse (right), with altitudes labeled as \( h \)
    8.2.2 Figure (Fixed).png

    We will perform the proof for the acute triangle (the proof associated with the obtuse triangle is similar).

    The acute triangle is comprised of two right triangles - \( \triangle ABD \) and \( \triangle BCD \). Let \( x \) be the length of the line segment \( \overline{AD} \). Then the length of the segment \( \overline{CD} \) is \( b - x \). We show these facts in the following figure, splitting the acute triangle into its two right triangle pieces.

    "Splitting" the acute triangle into two right triangles
    8.2.3 Figure.png

    With the leftmost triangle, we have the following:\[ \begin{array}{rrclcl}
    & \left( b - x \right)^2 + h^2 & = & a^2 & \quad & \left(\text{Pythagorean Theorem}\right) \\[6pt] \implies & b^2 - 2bx + x^2 + h^2 & = & a^2 & \quad & \left( \text{distributing} \right) \\[6pt] \end{array} \nonumber \]With the rightmost triangle, we have\[ x^2 + h^2 = c^2 \quad \left( \text{Pythagorean Theorem} \right) \nonumber \]Therefore,\[ b^2 - 2bx + x^2 + h^2 = a^2 \quad \text{and} \quad x^2 + h^2 = c^2. \nonumber \]Replace \( x^2 + h^2 \) in the first equation with \( c^2 \). Doing so yields the following:\[ b^2 - 2bx + c^2 = a^2 \implies b^2 + c^2 - 2bx = a^2. \nonumber \]From the rightmost triangle in the figure above, we see that \( \cos\left( A \right) = \frac{x}{c} \), and so \( c \, \cos\left( A \right) = x \). Hence, we have developed the following relationship between the sides of any triangle.\[ \begin{array}{rrclcl}
    & b^2 + c^2 - 2bx & = & a^2 & & \\[6pt] \implies & b^2 + c^2 - 2b\left( c \, \cos\left( A \right) \right) & = & a^2 & \quad & \left( \text{substitution} \right) \\[6pt] \implies & b^2 + c^2 - 2bc \, \cos\left( A \right) & = & a^2 & & \\[6pt] \end{array} \nonumber \]When \(A\) is a right angle, \(\cos\left( A \right) = \cos\left( 90^{\circ}\right)=0\), so the equation reduces to the Pythagorean Theorem.

    We can write similar equations involving the angles \(B\) or \(C\). In all cases, the angle within the cosine is opposite the side playing the role of the "hypotenuse" (really, a quasi-hypotenuse).

    Note: If \(A\) is obtuse, the foot \(D\) of the altitude lies on the extension of \(\overline{CA}\) beyond \(A\). With \(x = AD\), we have \(CD = b + x\) and \(\cos\left(A\right) = -\frac{x}{c}\), so \(a^2 = (b+x)^2 + h^2 = b^2 + 2bx + c^2 = b^2 + c^2 - 2bc\cos\left(A\right)\). Hence the Law of Cosines holds for every triangle.

    Theorem: Law of Cosines (Angle Form)

    In any triangle with standard labeling,\[\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}.\nonumber\]

    Note: Relationship to the Pythagorean Theorem

    If \(\gamma = 90^{\circ}\), then \(\cos\gamma = 0\), and the Law of Cosines reduces to the Pythagorean Theorem, \(c^2 = a^2 + b^2\). For any other angle, the term \(-2ab\cos\gamma\) corrects the Pythagorean relationship: \(c^2 \lt a^2 + b^2\) when \(\gamma\) is acute, and \(c^2 \gt a^2 + b^2\) when \(\gamma\) is obtuse.

    Tip for Success

    Use the Law of Cosines to find a missing side when you are given SAS, and use the angle form to find a missing angle when you are given SSS. Because \(\arccos\) returns a value in \((0^{\circ},180^{\circ})\) for every input in \((-1,1)\), the angle form identifies obtuse angles correctly—a negative cosine always indicates an obtuse angle.

    Caution: Order of Operations

    In \(a^2 + b^2 - 2ab\cos\gamma\), the product \(2ab\cos\gamma\) is computed first and then subtracted from \(a^2 + b^2\). A common error is to compute \(\left(a^2 + b^2 - 2ab\right)\cos\gamma\). Also confirm that your calculator is in degree mode, and carry unrounded values through intermediate steps; round only the final answers.

    Examples

    Example \(\PageIndex{1}\): Finding a Side (SAS)

    In \(\triangle ABC\), \(a = 8\), \(b = 11\), and \(\gamma = 37^{\circ}\). Find \(c\), rounded to two decimal places.

    Solution

    The given angle \(\gamma\) is included between sides \(a\) and \(b\), so this is the SAS case and the form of the Law of Cosines that involves \(\gamma\) applies:\[\begin{aligned} c^2 &= a^2 + b^2 - 2ab\cos\gamma \\ &= 8^2 + 11^2 - 2(8)(11)\cos 37^{\circ} \\ &= 185 - 176\cos 37^{\circ} \\ &\approx 185 - 140.5598 \\ &\approx 44.4402. \end{aligned}\nonumber\]Since \(c\) is a length, take the positive square root: \(c \approx \sqrt{44.4402} \approx 6.67\).

    Example \(\PageIndex{2}\): Finding a Side Exactly (SAS, Obtuse Angle)

    In \(\triangle ABC\), \(b = 5\), \(c = 7\), and \(\alpha = 120^{\circ}\). Find the exact value of \(a\), and then approximate it to two decimal places.

    Solution

    Angle \(\alpha\) is included between sides \(b\) and \(c\), so use the form involving \(\alpha\). Because \(120^{\circ}\) lies in Quadrant II with a reference angle of \(60^{\circ}\), \(\cos 120^{\circ} = -\frac{1}{2}\). Substituting,\[\begin{aligned} a^2 &= b^2 + c^2 - 2bc\cos\alpha \\ &= 5^2 + 7^2 - 2(5)(7)\left(-\dfrac{1}{2}\right) \\ &= 74 + 35 \\ &= 109. \end{aligned}\nonumber\]Taking the positive square root, \(a = \sqrt{109} \approx 10.44\). Notice that \(a^2 = 109 \gt b^2 + c^2 = 74\), as expected when the included angle is obtuse.

    Example \(\PageIndex{3}\): Finding an Angle (SSS)

    In \(\triangle ABC\), \(a = 5\), \(b = 7\), and \(c = 8\). Find \(\beta\).

    Solution

    All three sides are known (SSS), so use the angle form for \(\beta\), the angle opposite side \(b\):\[\cos\beta = \dfrac{a^2 + c^2 - b^2}{2ac} = \dfrac{5^2 + 8^2 - 7^2}{2(5)(8)} = \dfrac{40}{80} = \dfrac{1}{2}.\nonumber\]Since \(\beta\) is an angle of a triangle, \(0^{\circ} \lt \beta \lt 180^{\circ}\), and the only such angle with cosine \(\frac{1}{2}\) is \(\beta = \arccos\left(\frac{1}{2}\right) = 60^{\circ}\).

    Example \(\PageIndex{4}\): Solving a Triangle (SSS)

    Solve \(\triangle ABC\) given \(a = 4\), \(b = 6\), and \(c = 9\). Round angle measures to two decimal places.

    Solution

    Begin with \(\gamma\), the angle opposite the longest side. By the angle form,\[\cos\gamma = \dfrac{a^2 + b^2 - c^2}{2ab} = \dfrac{16 + 36 - 81}{2(4)(6)} = -\dfrac{29}{48},\nonumber\]so \(\gamma = \arccos\left(-\frac{29}{48}\right) \approx 127.17^{\circ}\). The negative cosine confirms that \(\gamma\) is obtuse.

    Next, find \(\alpha\) with the angle form:\[\cos\alpha = \dfrac{b^2 + c^2 - a^2}{2bc} = \dfrac{36 + 81 - 16}{2(6)(9)} = \dfrac{101}{108},\nonumber\]so \(\alpha = \arccos\left(\frac{101}{108}\right) \approx 20.74^{\circ}\).

    Finally, the angle measures of a triangle sum to \(180^{\circ}\), so \(\beta = 180^{\circ} - \gamma - \alpha \approx 32.09^{\circ}\). (As a check, \(\cos\beta = \frac{a^2 + c^2 - b^2}{2ac} = \frac{61}{72}\) gives the same value.)

    The solved triangle is \(a = 4\), \(b = 6\), \(c = 9\), \(\alpha \approx 20.74^{\circ}\), \(\beta \approx 32.09^{\circ}\), and \(\gamma \approx 127.17^{\circ}\).

    Example \(\PageIndex{5}\): Solving a Triangle (SAS)

    Solve \(\triangle ABC\) given \(a = 10\), \(c = 6\), and \(\beta = 52^{\circ}\). Round to two decimal places.

    Solution

    Angle \(\beta\) is included between sides \(a\) and \(c\), so first find \(b\):\[\begin{aligned} b^2 &= a^2 + c^2 - 2ac\cos\beta \\ &= 10^2 + 6^2 - 2(10)(6)\cos 52^{\circ} \\ &= 136 - 120\cos 52^{\circ} \\ &\approx 62.1206, \end{aligned}\nonumber\]so \(b \approx 7.8817\), or \(b \approx 7.88\) to two decimal places.

    Now all three sides are known, so find \(\alpha\) with the angle form, using the unrounded value of \(b\):\[\cos\alpha = \dfrac{b^2 + c^2 - a^2}{2bc} \approx \dfrac{62.1206 + 36 - 100}{2(7.8817)(6)} \approx -0.019871,\nonumber\]so \(\alpha \approx 91.14^{\circ}\). The cosine is negative, so \(\alpha\) is (slightly) obtuse.

    Finally, \(\gamma = 180^{\circ} - \alpha - \beta \approx 180^{\circ} - 91.14^{\circ} - 52^{\circ} = 36.86^{\circ}\).

    The solved triangle is \(a = 10\), \(b \approx 7.88\), \(c = 6\), \(\alpha \approx 91.14^{\circ}\), \(\beta = 52^{\circ}\), and \(\gamma \approx 36.86^{\circ}\).

    Example \(\PageIndex{6}\): Data That Do Not Form a Triangle

    Determine whether a triangle with side lengths \(a = 3\), \(b = 4\), and \(c = 8\) exists.

    Solution

    If such a triangle existed, the angle form would give the measure of \(\gamma\), the angle opposite the longest side:\[\cos\gamma = \dfrac{a^2 + b^2 - c^2}{2ab} = \dfrac{9 + 16 - 64}{2(3)(4)} = -\dfrac{39}{24} = -\dfrac{13}{8}.\nonumber\]The cosine of every angle lies in \([-1,1]\), but \(-\frac{13}{8} \lt -1\). No angle \(\gamma\) satisfies this equation, so no triangle with these side lengths exists. This agrees with the triangle inequality: \(a + b = 7\) is not greater than \(c = 8\).

    MyOpenMath Practice


    Sources

    Several parts of this text use modifications from the following source:

    This source is released under the Creative Commons Attribution-Share-Alike License 4.0.


    This page titled 27.34: Law of Cosines was last modified on Mon, 02 Nov 2026 20:23:03 GMT and is shared under a not declared license and was authored, remixed, and/or curated by Kristine Woods.