Geometry & Trigonometry
Intermediate

Law of Cosines

Generalizes Pythagoras to any triangle.

Formula

c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C

Variables

a, b, cSides
CAngle opposite c

Example

Sides a=5, b=7, angle C=60°: c² = 25+49−2·5·7·½ = 39, c ≈ 6.24.

How it works

The Law of Cosines gives the third side of any triangle when you know two sides and the included angle, or it lets you find an angle when all three sides are known. It works because a triangle can be split into right triangles, and the squared side length comes from combining the horizontal and vertical components of one side with the other side’s projection. When the angle is 90°, the cosine term becomes 0, so the formula reduces to the Pythagorean theorem.

When to use it

Use this formula in non-right triangles, especially when SAS information is given or when you need a side from two sides and the angle between them. It is common in surveying, navigation, engineering, and any geometry problem where triangles are not right-angled.

Worked example, step by step

Given a = 8, b = 11, and C = 40° Substitute into the formula: c^2 = a^2 + b^2 - 2ab cos C c^2 = 8^2 + 11^2 - 2(8)(11)cos 40° c^2 = 64 + 121 - 176(0.7660) c^2 = 185 - 134.82 c^2 ≈ 50.18 Take the square root: c ≈ √50.18 c ≈ 7.09 So the unknown side is about 7.09 units long.

Common mistakes to avoid

  • Using the angle opposite the wrong side; the angle C must be opposite side c
  • Forgetting that the cosine term is subtracted, not added
  • Plugging in degrees as if they were radians on a calculator set to the wrong mode

Did You Know?

The law of cosines is the Pythagorean theorem generalized to any triangle — the extra cosine term vanishes at 90°.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026