Law of cosines
Pythagoras for any triangle: the third side from two sides and the angle between them, or any angle from three sides.
Calculator
The live calculator needs JavaScript. The worked example below shows the same steps it would.
See it move
- Law of cosines: c = √(a² + b² − 2ab cos C) ≈ 6.245
- Angles: A ≈ 43.9°, B ≈ 76.1°, C = 60° (total 180°)
- Area = ½ab sin C ≈ 15.155
What the symbols mean
- the side opposite angle C
- one side next to angle C
- the other side next to angle C
- the angle between sides a and b
When to use it
Use it when you know two sides and the angle between them (SAS) and want the third side, or when you know all three sides (SSS) and want an angle. Those are the two cases the law of sines cannot start. With a right angle, and it becomes Pythagoras. Finding a side next to the known angle leads to a quadratic, which can have two positive answers (the ambiguous case again).
Worked example
Two sides of a triangle are 5 cm and 7 cm, and the angle between them is 60°. Find the third side.
Start from the formula.
Rearrange to make the subject: take the square root of both sides.
Substitute = , = , = and work it out.
Answer c ≈ 6.24 cm
Why it works
Drop a perpendicular from the far corner onto side b and apply Pythagoras to the two right triangles; the term is the correction for the angle not being 90°. It is positive when C is obtuse, making c longer than Pythagoras would say.
Common mistakes
- Computing . Only the last term is multiplied by cos C.
- Using an angle that is not between sides a and b.
- Forgetting the square root after finding .
- Three sides that break the triangle inequality (one longer than the other two together) give no triangle; the inverse cosine then has no answer.