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°.
- 01c² = 49 + 100 - 2(7)(10)cos(60°)
- 02= 149 - 140 × 0.5
- 03= 149 - 70 = 79
- 04c = √79 ≈ 8.8882
Frequently Asked Questions
What is the law of cosines?
The law of cosines relates the three sides of a triangle to one of its angles: c² = a² + b² - 2ab cos(C). It generalizes the Pythagorean theorem.
How is this related to the Pythagorean theorem?
When angle C is 90°, cos(90°) = 0, so the formula becomes c² = a² + b², which is the Pythagorean theorem. The law of cosines works for all triangles, not just right triangles.
Can I find an angle using the law of cosines?
Yes, rearrange to: cos(C) = (a² + b² - c²) / (2ab). Then take the arccos to find the angle.
Learn More
Guide
Trigonometry Basics - Complete Guide
Learn the fundamentals of trigonometry including sine, cosine, tangent, the unit circle, identities, and the laws of sines and cosines with practical examples.
Ready to run the numbers?
Open Law of Cosines Calculator