Kolton Ndoj

Law of cosines

Pythagoras with a correction term that depends on how far the angle is from a right angle.

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

What the symbols mean

a,ba,b
two sides you know
CC
the angle between them
cc
the side opposite C

Why it works — the picture

Hinge two sticks of lengths a and b at a pivot and swing them open. At 90 degrees you get Pythagoras. Open wider and the far ends get farther apart; close them and they come together. The extra term -2ab cos C is exactly that adjustment: positive when the angle is acute (cos positive, subtracts), negative when obtuse (adds).

Graph for Law of cosines 03.14100
Distance between the stick ends as the angle t opens from 0 to 180 degrees. At t = 90 degrees (1.5708) it is 5 for sticks 3 and 4. (drawn with the default slider values — move the sliders live)

Try it yourself

Where it’s used in real life

Navigation, triangulation, and the vector-length calculation in physics engines.

Related

Play with it live →

Math · Trigonometry · Intermediate