Skip to content
LoveToCalc

Theorem — what does that mean?

The law of cosines

Pythagoras with a correction term for the angle — and the direct route through a triangle where you know two sides and the angle between them.

In Swedish: Cosinussatsen

The law of cosines

The relation

c²=a²+b²−2ab cos(C)

The third side of any triangle from the other two and the angle between them — Pythagoras with a correction term for the angle.

A triangle with no right angle. Sides a and b meet at the corner where angle C sits, and side c lies opposite that corner.
Solve for
Solved for c

c=a²+b²−2ab cos(C)

Show how the formula is rearranged
  1. c²=a²+b²−2ab cos(C)
  2. Take the square root of both sides. These are lengths, so only the positive root counts.

    c=a²+b²−2ab cos(C)

c=7cm

c equals the square root of ((5 squared plus 8 squared) minus ((2 times (5 times 8)) times the cosine of (60 degrees))), equals the square root of ((25 plus 64) minus ((2 times 40) times 0.5)), equals the square root of (89 minus (80 times 0.5)), equals the square root of (89 minus 40), equals the square root of (49), equals 7 cm

Working6 steps

Practice questions

You are given

  • a=7cm
  • b=20cm
  • C=65°

Round to 1 decimal.

Pick the unit your lengths are in. Areas are then labelled in square units and volumes in cubic units; nothing is converted.

What the law of cosines says

In any triangle,

c² = a² + b² − 2ab · cos C

where C is the angle between sides a and b, and c is the side opposite that angle.

Look at the right-hand side again. The first two terms are Pythagoras’ theorem. The third is the correction for the angle not being a right angle: at C = 90°, cos 90° = 0, the term vanishes, and what is left is c² = a² + b². So the law of cosines is not a second theorem standing beside Pythagoras but the general form of it — Pythagoras is the special case.

The sign of the correction follows the angle. When C is acute the cosine is positive, the term is subtracted, and c comes out shorter than Pythagoras would give. When C is obtuse the cosine is negative, the minus becomes a plus, and c comes out longer. That matches the figure: open the angle between two sticks and their far ends move apart.

Where it comes from

Drop a perpendicular from the corner at B onto side b. It splits the triangle into two right-angled ones, and in the one containing angle C the height is a · sin C and the leg along the base is a · cos C. The other triangle’s base is then b − a · cos C, and Pythagoras on it gives

c² = (a · sin C)² + (b − a · cos C)² c² = a² sin²C + b² − 2ab · cos C + a² cos²C

Sine squared plus cosine squared is 1, so a² sin²C + a² cos²C is a², and the theorem is left standing. The same working holds when C is obtuse: the foot of the perpendicular then falls outside the side, a · cos C goes negative, and the subtraction takes care of itself.

Worked examples

The third side. Two sides are 5 cm and 8 cm with a 60° angle between them.

Compare with Pythagoras: without the correction the answer would have been √89 = 9.4 cm. An angle of 60° instead of 90° pulls the triangle in by 2.4 cm.

The angle from three sides. The same triangle backwards, given sides 5, 8 and 7:

This arrangement is useful in practice. Three sides are what a tape measure gives you, and the law of cosines is the direct route from three lengths to an angle.

Two answers. Now the awkward case: b = 8, c = 7 and C = 60°, with a unknown. Substitute and collect:

So a = 5 or a = 3. Both are real triangles. Check the smaller one: 9 + 64 − 2 · 3 · 8 · 0.5 = 73 − 24 = 49, as it should. Two different triangles share the same 60° angle and the same opposite side of 7 — they differ only in how far the unknown side reaches — and nothing you were told decides between them. The card above works out both and prints the second answer beside the first.

With an acute angle C, this happens when the opposite side c is shorter than the known side b but longer than the height b · sin C. Here the height is 8 · sin 60° = 6.93, and 7 sits between 6.93 and 8. If c is shorter than the height the side never reaches and there is no triangle; if c is longer than b there is exactly one.

Common mistakes

Frequently asked questions

When do I use the law of cosines and when the law of sines? The law of cosines when you have two sides and the angle between them, or all three sides. The law of sines when you have a side and the angle opposite it, plus one more thing. The rule of thumb: the law of sines needs a pair — a side and its opposite angle — and if you have no such pair, the law of cosines is your way in. Often you start with the law of cosines to get the first pair and continue with the law of sines.

Can I use the law of cosines on a right triangle? Yes, and you get Pythagoras back. Put C = 90°: cos 90° = 0, the last term is zero, and c² = a² + b². Nothing wrong with doing it, just more keystrokes than you need.

Why do I sometimes get two answers and sometimes one? Because the formula is a quadratic when the unknown side is one of the two that meet at the angle. The square root can be added or subtracted, and both are triangles as long as both are positive lengths. Solve instead for the opposite side c or the angle C and there is never more than one answer — those arrangements are not quadratics.

Looking for another letter? The formula solved for each one
Solved for each letter
Solve forRearrangedWith the numbersComes to
ab cos(C)+c²−(b sin(C))²8 cos(60°)+7²−(8 sin(60°))²5 cm
ba cos(C)+c²−(a sin(C))²5 cos(60°)+7²−(5 sin(60°))²8 cm
Carccos(a²+b²−c²2ab)arccos(5²+8²−7²2·5·8)60°
ca²+b²−2ab cos(C)5²+8²−2·5·8 cos(60°)7 cm

Last reviewed October 6, 2026 ·How pages are reviewed

Calculate it in practice

Ready-made worksheets with this formula

Sheets that ask this formula, with their answer keys. Open one to see the questions or print it.

High school

  • Sine and cosine rule

    Six questions with the sine rule, six with the cosine rule and four on the area of a triangle with sine. Calculator allowed.

More about the triangle

The same drawing, measured in the other ways it can be measured.

TrigonometryAll formulas

Put this formula on your site

Copy the code into your page where the formula card should appear. It loads from lovetocalc.com, so it stays current on its own — all we ask is that the credit line comes with it.