How the law of cosines works
Pythagoras is a wonderful theorem with one strict condition attached: the triangle has to contain a right angle. Tilt that corner even slightly and a2 = b2 + c2 stops being true. For centuries that left a real gap, because most triangles in the world are not right angled. Surveyors, navigators and astronomers all needed the general case.
The law of cosines fills it, and it does so in the most satisfying way possible: by keeping Pythagoras completely intact and bolting a correction term onto the end. That term measures exactly how much the triangle's opening angle has thrown the old formula off. Close the angle below 90 degrees and the far side comes in shorter than Pythagoras predicts. Open it past 90 and the far side stretches longer. At exactly 90 the correction is worth nothing at all and the familiar formula reappears untouched.
The formula
Here a, b and c are the three side lengths, and A is the angle sitting opposite side a, which is the same as the angle squeezed between sides b and c. Rearranged to hunt for an angle instead of a side, it becomes:
That second form is the one that unlocks a triangle where you know all three sides and none of the angles. Run it once for each corner and the whole shape falls out.
Worked example
Two sides and the angle between them. A plot of land has two boundaries meeting at a corner: one runs 5 metres, the other runs 7 metres, and the corner between them opens to 60 degrees. How far apart are the far ends?
a2 = 52 + 72 − 2 × 5 × 7 × cos 60°
a2 = 25 + 49 − 70 × 0.5
a2 = 74 − 35 = 39
a = √39 = 6.24 metres
Now look at what the correction did. If that corner had been a right angle, the answer would have been √74, or 8.60 metres. Pulling the corner in from 90 degrees to 60 degrees pulled the far ends more than two metres closer together, and the entire difference is carried by that one 2bc cos A term.
The triangle's other numbers follow: the remaining angles come to 43.90 and 76.10 degrees, the perimeter is 18.24 metres, and the area is 15.16 square metres.
Pythagoras is hiding inside this formula
Set A to 90 degrees. The cosine of 90 degrees is exactly zero, so the term 2bc cos A becomes 2bc × 0, which is nothing at all. What survives is a2 = b2 + c2.
This is not a coincidence or a neat trick of notation. The law of cosines genuinely contains Pythagoras as one specific case out of infinitely many, which means you have not really been learning a second, competing formula. You have been learning the full version of the one you already knew. Every triangle you ever solved with Pythagoras, this law would have solved too.
The sign of that correction term is worth carrying around in your head, because it is a free sanity check on any answer:
- Angle under 90 degrees: cos A is positive, so you subtract something real, and a comes out shorter than Pythagoras would say.
- Angle exactly 90 degrees: cos A is zero, and a lands precisely on the Pythagorean answer.
- Angle over 90 degrees: cos A turns negative, so subtracting it adds, and a comes out longer.
If your answer falls on the wrong side of √(b2 + c2) for the angle you typed, something has gone astray. The calculator reports this comparison on every SAS answer so you can see it rather than take our word for it.
The one thing this law does that the law of sines cannot
Both laws will happily find you a missing angle, so it is fair to ask why anyone keeps two of them. The answer is obtuse angles.
Inverse sine has no way to distinguish 40 degrees from 140 degrees, because both have the same sine. Hand it a value and it always returns the acute option, leaving you to work out whether the obtuse one was the answer you actually wanted. That is the whole origin of the ambiguous case, where one set of measurements can describe two genuinely different triangles.
Inverse cosine has no such blind spot. Cosine is positive for acute angles and negative for obtuse ones, so the sign of your answer carries the information and the angle comes back unambiguously anywhere from 0 to 180 degrees. When you solve a triangle from its three sides, there is exactly one answer and this law finds it.
So the division of labour is clean. If the angle you know sits between the two sides you know, or if you know no angles at all, this is your law. Otherwise reach for the law of sines, which is easier arithmetic when it applies. If you would rather not choose, the triangle calculator takes any valid combination and picks the right law for you.