Law of Cosines Calculator

Use the law of cosines to find the third side from two sides and the included angle, or all three angles from the three sides.

Third side c

How to Use the Law of Cosines

Choose what you know: two sides and the angle between them, or all three sides.

1

Two sides + included angle

On the SAS tab, enter two sides and the angle between them to find the third side with c² = a² + b² − 2ab·cos(C).

2

Three sides

On the SSS tab, enter all three sides to find every angle by rearranging the law of cosines.

3

Read the result

The unknown side or the three angles appear immediately; the angles always sum to 180°.

Frequently Asked Questions

What is the law of cosines?
The law of cosines relates the three sides of any triangle to one of its angles: c² = a² + b² − 2ab·cos(C), where C is the angle opposite side c. It generalises the Pythagorean theorem, which is the special case C = 90° where cos(C) = 0. For a = 5, b = 7 and C = 60°, c² = 25 + 49 − 35 = 39, so c is about 6.245. The same relation holds for each of the three angles in turn.
When do you use the law of cosines?
Use the law of cosines when you know two sides and the included angle (SAS), to find the third side, or all three sides (SSS), to find any angle. Those are exactly the two cases the law of sines cannot start from. For two angles and a side, or two sides and a non-included angle, use the law of sines instead. A common approach is to find the third side with the cosine rule and then finish the triangle with the sine rule.
How do you find an angle from three sides?
Rearrange the law of cosines to cos(C) = (a² + b² − c²) ⁄ (2ab), then take the inverse cosine. For the 3-4-5 triangle, cos(C) = (9 + 16 − 25) ⁄ 24 = 0, so C = 90° as expected. This calculator does that for all three angles and checks that they sum to 180°. A negative cosine simply means the angle is obtuse.
Is my data sent anywhere?
Your figures stay on your device when you use the law of cosines calculator. The law of cosines calculator works in the browser using JavaScript, with no server round-trip at any point, so your sides and angles are never transmitted. Nothing is logged, stored or shared with a third party. That also means the tool keeps working offline.