Trigonometry
Intermediate

Law of Cosines

Generalises 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

a=3,b=4,C=90° ⇒ c=5

How it works

The Law of Cosines lets you find an unknown side or angle in any triangle, not just right triangles. It works because if you drop an altitude and split the triangle into two right triangles, the horizontal parts involve cosines; combining those pieces produces the extra "-2ab\cos C" term. When C is 90°, cos C = 0, so the formula becomes the Pythagorean theorem.

When to use it

Use this when you know two sides and the included angle and want the third side, or when you know all three sides and need an angle. It is especially useful in surveying, navigation, physics, and any triangle that is not a right triangle.

Worked example, step by step

Suppose a = 7, b = 10, and C = 60°. Use c^2 = a^2 + b^2 - 2ab\cos C c^2 = 7^2 + 10^2 - 2(7)(10)\cos 60° c^2 = 49 + 100 - 140(0.5) c^2 = 149 - 70 c^2 = 79 c = \sqrt{79} c \approx 8.89 So the third side is about 8.9 units.

Common mistakes to avoid

  • Using the angle opposite the wrong side in the cosine term
  • Forgetting that the formula uses the included angle between sides a and b
  • Calculating cos in degrees/radians incorrectly for the given angle

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