The cosine rule
Two shuttles leave the station. One is now 8 kilometres away, the other 3 kilometres, and seen from the station, the angle between their directions is 60°. How far apart are they?
The station and the two shuttles make a triangle. With a right angle at the station, Pythagoras would give the answer, but the angle is 60°. The cosine rule is Pythagoras with a correction for the angle.
The rule
Call the angle at the station A, the two sides that meet there b and c, and the side across from it a. Then
For the shuttles:
With cosine of 60 degrees as 1 over 2, that is 64 plus 9 minus 24, so a squared equals 49. The equation a squared equals 49 has the answers 7 and minus 7, but a distance can't be negative, so only the positive root counts: the shuttles are 7 kilometres apart.
The cosine rule: a squared equals b squared plus c squared minus 2 b c times cosine of A, where a is the side across from the angle A.
Pythagoras with a correction
At A equals 90 degrees, cosine of 90 degrees is 0, the correction vanishes, and what is left is Pythagoras: a squared equals b squared plus c squared.
For an angle under 90°, cos A is positive, so the correction makes a shorter than with a right angle: the shuttles are closer together when their directions are close. For an angle over 90°, cos A is negative, so minus the correction adds to a squared. With 120° between the sides 5 and 3:
and with cosine of 120 degrees as minus 1 over 2, that is 25 plus 9 plus 15, which is 49, so a is 7.
Where it comes from
Drop the height h from the end of c onto b. The height splits b into a part c times cosine of A next to A, and the rest, b minus c times cosine of A. The height itself is c times sine of A. Pythagoras in the right-angled triangle on the far side gives
Multiplying out, and using that sine of A squared plus cosine of A squared equals 1 (Pythagoras in the triangle with hypotenuse 1), everything but b squared plus c squared minus 2 b c times cosine of A cancels.
Put the two sides and the angle between them into the rule, and take the positive root.
Practise Trigonometry in triangles