Law of Cosines
Finds the third side of a triangle from two sides and the angle between them.
a² = b² + c² − 2bc cos A
When A = 90°, cos A = 0 and it becomes the Pythagorean theorem.
From three sides you can also get an angle: cos A = (b² + c² − a²) ÷ 2bc.
Calculator
Change a value and the result and picture update instantly.
Result
Side a
Animated picture
The picture follows your values. Some points and shapes can be dragged.
Use in game development
Two-bone inverse kinematics — bending an arm or leg to reach a point — uses it.
Code example (JavaScript)
const a = Math.sqrt(b*b + c*c - 2*b*c*Math.cos(A));
What the symbols mean
| Symbol | Meaning |
|---|---|
b | Side b |
c | Side c |
A | Angle A between them (°) |
a | Side a |
More formulas in this category
Frequently asked questions
- What is the formula for Law of Cosines?
- The formula for Law of Cosines is a² = b² + c² − 2bc cos A. Finds the third side of a triangle from two sides and the angle between them.
Math Formula Quiz Trigonometry
Sources
Checked: 2026-11-29