Skip to content

The law of cosines

The law of cosines

The law

In a triangle, the square of a side is the sum of the squares of the other two sides, less twice their product times the cosine of the angle between them:

c2\displaystyle c^2 =\displaystyle = a2+b2−2abcos⁡γ\displaystyle a^2+b^2-2ab\cos\gamma

γ\displaystyle \gamma – the angle between a\displaystyle a and b\displaystyle b, opposite c\displaystyle c. When γ=90∘\displaystyle {\gamma}={90^{\circ}}, cos⁡γ=0\displaystyle {\cos\gamma}={0}, and this is Pythagoras’ theorem: the law of cosines extends it to every triangle.

A proof with coordinates

The proof below places the triangle on axes, C\displaystyle C at the origin and CA\displaystyle CA on the x\displaystyle x-axis, and works out c=AB\displaystyle {c}={AB} by the distance formula.

  • A=(b,0)\displaystyle {A}={(b,0)}.
  • B\displaystyle B is at distance a\displaystyle a from the origin, at the angle γ\displaystyle \gamma from the x\displaystyle x-axis: the point (cos⁡γ,sin⁡γ)\displaystyle (\cos\gamma,\sin\gamma) of the unit circle, enlarged a\displaystyle a times – B=(acos⁡γ, asin⁡γ)\displaystyle {B}={(a\cos\gamma,\ a\sin\gamma)}.
  • c2=(acos⁡γ−b)2+(asin⁡γ)2=a2cos⁡2γ−2abcos⁡γ+b2+a2sin⁡2γ\displaystyle {c^2}={(a\cos\gamma-b)^2+(a\sin\gamma)^2}={a^2\cos^2\gamma-2ab\cos\gamma+b^2+a^2\sin^2\gamma}.
  • cos⁡2γ+sin⁡2γ=1\displaystyle {\cos^2\gamma+\sin^2\gamma}={1}, so c2=a2+b2−2abcos⁡γ\displaystyle {c^2}={a^2+b^2-2ab\cos\gamma}.

The definition on the unit circle holds for every angle, so the proof holds when γ\displaystyle \gamma is obtuse too.

An angle from three sides

When all three sides are known, isolate cos⁡γ\displaystyle \cos\gamma:

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

The sign of the numerator fixes the kind of angle opposite c\displaystyle c:

  • c2<a2+b2\displaystyle c^2<a^2+b^2 – cos⁡γ>0\displaystyle \cos\gamma>0, the angle is acute;
  • c2=a2+b2\displaystyle {c^2}={a^2+b^2} – the angle is right;
  • c2>a2+b2\displaystyle c^2>a^2+b^2 – cos⁡γ<0\displaystyle \cos\gamma<0, the angle is obtuse.

Every cosine between −1\displaystyle -1 and 1\displaystyle 1 has one angle only between 0∘\displaystyle 0^{\circ} and 180∘\displaystyle 180^{\circ}, so here – unlike the law of sines – there are no two possibilities.

A side not opposite the angle

When the known angle is not between the two known sides, the missing side is one of the sides at the angle, and the law of cosines gives a quadratic equation in it.

The example below has, in triangle ABC\displaystyle ABC: AC=5\displaystyle {AC}={5}, BC=7\displaystyle {BC}={7}, ∠A=60∘\displaystyle {\angle A}={60^{\circ}}, and finds AB=x\displaystyle {AB}={x}.

  • BC\displaystyle BC is opposite ∠A\displaystyle \angle A: 49=x2+25−2⋅5xcos⁡60∘=x2+25−5x\displaystyle {49}={x^2+25-2\cdot5x\cos60^{\circ}}={x^2+25-5x};
  • x2−5x−24=0\displaystyle {x^2-5x-24}={0}, so x=8\displaystyle {x}={8} or x=−3\displaystyle {x}={-3};
  • a length is positive: AB=8\displaystyle {AB}={8}.

An equation with two positive solutions means two different triangles with the same data.

Exercise 1

Work out the third side c\displaystyle c.

a

a=5\displaystyle {a}={5}, b=8\displaystyle {b}={8}, γ=60∘\displaystyle {\gamma}={60^{\circ}}.

    / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

    / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power

    b

    a=3\displaystyle {a}={3}, b=5\displaystyle {b}={5}, γ=120∘\displaystyle {\gamma}={120^{\circ}}.

      / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

      / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power

      Exercise 2

      The sides of a triangle are 5\displaystyle 5, 7\displaystyle 7 and 8\displaystyle 8.
      Work out the angle opposite the side 7\displaystyle 7, in degrees.

        / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

        / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power

        Exercise 3

        The sides of a triangle are 4\displaystyle 4, 5\displaystyle 5 and 8\displaystyle 8.

        a

        Without working out an angle: is the triangle acute, right-angled or obtuse? Explain.

        b

        Work out the largest angle of the triangle. Round to two decimal places.

          / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

          / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power

          Exercise 4

          In triangle ABC\displaystyle ABC: AC=3\displaystyle {AC}={3}, BC=7\displaystyle {BC}={7}, and ∠A=60∘\displaystyle {\angle A}={60^{\circ}}.
          x=AB\displaystyle {x}={AB}. Solve the equation the law of cosines gives.

            Exercise 5

            The sides of a parallelogram are 6\displaystyle 6 and 10\displaystyle 10, and the angle between them is 60∘\displaystyle 60^{\circ}.
            Work out the diagonals, as exact values.

            a
            The short diagonal

              / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

              / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power

              b
              The long diagonal

                / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – check and a new line · * – times · ^ – power, ↓ – end of the power

                / – fraction bar · Tab or the arrows – between numerator and denominator, then a note above or below · Enter – a new line · * – times · ^ – power, ↓ – end of the power