Law of Cosines Calculator
Solve triangles with the law of cosines.
About this tool
Enter two sides and the angle between them to get the third side, or enter all three sides to get the angle. Sides 5 and 6 with C = 60° give c = 5.56776.
How to use
How it works
The law of cosines extends Pythagoras to any triangle. With C = 90° the cosine term is 0 and it reduces to c² = a² + b², so sides 3 and 4 give 5. To get an angle, rearrange to cos C = (a² + b² − c²) ÷ 2ab. Three sides only form a triangle if each is shorter than the sum of the other two.
c² = a² + b² − 2ab·cos C cos C = (a² + b² − c²) ÷ 2ab
Worked example
Find an angle from three sides
- Input
- a = 7, b = 8, c = 9
- Output
- C = 73.3985°
- Walkthrough
- cos C = (49 + 64 − 81) ÷ 112 = 0.285714, and arccos(0.285714) = 73.3985°.
Limitations
- Angles are in degrees.
- Impossible triangles are rejected: sides 1, 2, 10 return the error "Impossible triangle: each side must be shorter than the sum of the other two".
Questions
What is c if a = 5, b = 6 and C = 60°?
What is c if a = 3, b = 4 and C = 90°?
What is angle C if the sides are 7, 8 and 9?
What happens with sides 1, 2 and 10?
Features
- Side or angle
- Reduces to Pythagoras at 90°
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Rectangle area as product of dimensions
Khan Academy
Connects unit squares to length × width for area tools.
Watch on YouTubeFinding mean, median, and mode
Khan Academy
Descriptive stats used across statistics tools.
Watch on YouTube
- Heron's Formula
Math is Fun
Area from three sides when height is unknown.
- Pythagoras Theorem
Math is Fun
Legs and hypotenuse examples for right-triangle pages.