Law of Cosines Calculator Formula
Understand the math behind the law of cosines calculator. Each variable explained with a worked example.
Formulas Used
Side C
side_c = sqrt(pow(side_a, 2) + pow(side_b, 2) - 2 * side_a * side_b * cos(angle_c * pi / 180))Angle A
angle_a = acos((pow(side_b, 2) + pow(sqrt(pow(side_a, 2) + pow(side_b, 2) - 2 * side_a * side_b * cos(angle_c * pi / 180)), 2) - pow(side_a, 2)) / (2 * side_b * sqrt(pow(side_a, 2) + pow(side_b, 2) - 2 * side_a * side_b * cos(angle_c * pi / 180)))) * 180 / piVariables
| Variable | Description | Default |
|---|---|---|
side_a | Side a | 7 |
side_b | Side b | 10 |
angle_c | Included Angle C (degrees)(deg) | 60 |
How It Works
Law of Cosines
Formula
c² = a² + b² - 2ab × cos(C)
c = sqrt(a² + b² - 2ab × cos(C))
This generalizes the Pythagorean theorem. When C = 90°, cos(C) = 0, and it reduces to c² = a² + b².
When to Use
Worked Example
Find side c: a = 7, b = 10, angle C = 60°.
side_a = 7side_b = 10angle_c = 60
- 01c² = 49 + 100 - 2(7)(10)cos(60°)
- 02= 149 - 140 × 0.5
- 03= 149 - 70 = 79
- 04c = √79 ≈ 8.8882
Ready to run the numbers?
Open Law of Cosines Calculator