Lably
Skip to content

Law of cosines

Generalization of Pythagorean theorem

  • 14 min read
  • 8 chapters

Related on Lably

Through Trigonometry, Triangle and Sine and cosine

c2=a2+b2−2abcos⁡γ,a2=b2+c2−2bccos⁡α,b2=a2+c2−2accos⁡β.

The law of cosines generalizes the Pythagorean theorem, which holds only for right triangles: if ⁠γ⁠ is a right angle then ⁠cos⁡γ=0⁠, and the law of cosines reduces to ⁠c2=a2+b2⁠.

The law of cosines is useful for solving a triangle when all three sides or two sides and their included angle are given.

Use in solving triangles

The theorem is used in solution of triangles, i.e., to find (see Figure 3):

  • the third side of a triangle if two sides and the angle between them is known: c=a2+b2−2abcos⁡γ;
  • the angles of a triangle if the three sides are known: γ=arccos⁡(a2+b2−c22ab);
  • the third side of a triangle if two sides and an angle opposite to one of them is known (this side can also be found by two applications of the law of sines): a=bcos⁡γ±c2−b2sin2⁡γ.

These formulas produce high round-off errors in floating point calculations if the triangle is very acute, i.e., if c is small relative to a and b or γ is small compared to 1. It is even possible to obtain a result slightly greater than one for the cosine of an angle.

The third formula shown is the result of solving for a in the quadratic equation a2 − 2ab cos γ + b2 − c2 = 0. This equation can have 2, 1, or 0 positive solutions corresponding to the number of possible triangles given the data. It will have two positive solutions if b sin γ < c < b, only one positive solution if c = b sin γ, and no solution if c < b sin γ. These different cases are also explained by the side-side-angle congruence ambiguity.

Sign in to keep reading

7 more chapters are free with a Lably account.

More in Geometry