How to use the Law of Cosines Calculator
- Enter side a and side b.
- Enter angle C, the angle enclosed between those two sides.
- Read side c, the side opposite the entered angle.
- Read angles A and B, recovered from the completed triangle.
- Read the area, computed from the two sides and the included angle.
How the calculation works
The law of cosines generalises Pythagoras to triangles with no right angle. It states that c² equals a² plus b² minus twice ab times the cosine of the included angle. When that angle is 90° its cosine is zero, the correction term vanishes, and the formula collapses back to the Pythagorean theorem — which is the cleanest way to remember it.
The correction term also tells you the triangle's character at a glance. An acute included angle has a positive cosine, so the term is subtracted and c comes out shorter than the Pythagorean value. An obtuse angle has a negative cosine, the term is added, and c is longer. This is the side-angle-side case, and unlike the law of sines it never produces an ambiguous result.
Once all three sides are known, the same formula rearranged gives every angle, which makes it the standard route for the side-side-side case too. In navigation and robotics this is inverse kinematics in miniature: knowing two link lengths and the distance between endpoints, the law of cosines recovers the joint angle needed to reach a target.
c² = a² + b² − 2ab·cos C; cos A = (b² + c² − a²)/(2bc); area = ½ab·sin CSource: Law of cosines, generalising Euclid, Elements Book II, Propositions 12 and 13.
Worked example
Two guy wires leave a mast anchor 7 m and 9 m long with a 52° angle between them. How far apart are the anchor points?
- a = 7, b = 9, C = 52°, cos(52°) = 0.6157.
- a² + b² = 49 + 81 = 130.
- Correction: 2 × 7 × 9 × 0.6157 = 77.58.
- c = √(130 − 77.58) = √52.42 = 7.24 m.
7.24 m between the anchor points, enclosing a triangle of area ½ × 7 × 9 × sin(52°) = 24.8 m².
Frequently asked questions
Can I use it when I only know three sides?+
Yes — rearranged for the cosine of an angle, it recovers all three angles from three side lengths, which the law of sines cannot do alone.
Why is the law of cosines never ambiguous?+
Cosine is one-to-one across 0° to 180°, so each cosine value maps to exactly one angle in a triangle's range. Sine does not have that property.
What happens if my angle is exactly 90°?+
The cosine is zero and the formula reduces to Pythagoras, giving the same hypotenuse the right triangle calculator would.
Is the area formula independent of the third side?+
Yes. Half the product of two sides times the sine of the angle between them needs nothing else.
Last reviewed August 31, 2026. We review this page whenever the underlying formula, tax year, published rate or standard changes.