Law of Cosines Calculator
The law of cosines extends Pythagoras' theorem to any triangle. It finds a side from two sides and the angle between them, or any angle from three sides.
How to use the law of cosines calculator
Enter two sides, a and b, and the angle C between them. The calculator finds the third side, the other two angles and the area. You can also enter all three sides and press × on angle C to find the angles.
The law of cosines
c² = a² + b² − 2ab cos C
and for angles:
cos A = (b² + c² − a²) ÷ 2bc
Worked example
a = 7, b = 9, C = 50°:
- c² = 49 + 81 − 126 × cos 50° = 130 − 80.99 = 49.01
- c = 7.00
- Area = ½ × 7 × 9 × sin 50° = 24.13
Third side for different angles (a = 7, b = 9)
| Angle C | Side c |
|---|---|
| 10° | 2.43 |
| 30° | 4.57 |
| 60° | 8.19 |
| 90° | 11.40 |
| 120° | 13.89 |
| 150° | 15.46 |
| 170° | 15.94 |
As the angle opens, the third side grows from about b − a towards a + b.
Law of sines
a ÷ sin A = b ÷ sin B = c ÷ sin C
Use it with two angles and a side. Beware the ambiguous case (two sides and a non-included angle), which can have two solutions.
Real-world uses
- Surveying: distance across a lake from two measured sides and the angle between them.
- Navigation: distance between two ships from their bearings and distances.
- Engineering: forces in trusses and linkages.
Frequently asked questions
What is the law of cosines?
c² = a² + b² − 2ab·cos C. It relates the three sides of any triangle to one of its angles.
When do I use the law of cosines instead of the law of sines?
Use cosines when you know two sides and the angle between them (SAS) or all three sides (SSS). Use sines when you know two angles and a side, or two sides and a non-included angle.
How do I find an angle from three sides?
cos A = (b² + c² − a²) ÷ 2bc. In the calculator, enter a, b and c and press × on angle C.
Is the Pythagorean theorem a special case?
Yes. When C = 90°, cos C = 0 and the formula becomes c² = a² + b².