Law of Cosines Calculator
Use the law of cosines to solve any triangle when you know two sides and the included angle (SAS) or all three sides (SSS).
Solve for
°
Length of the side opposite the included angle
- 1
Angle C in radians
60° × π ÷ 180 = 1.047198 - 2
2ab·cos(C)
2 × 5 × 7 × 0.5 = 35 - 3
c²
a² + b² − 2ab·cos(C) = 25 + 49 − 35 = 39 - 4
Side c
√39 = 6.2450
How does this calculator work?
The law of cosines states c² = a² + b² − 2ab·cos(C). Enter two sides and the included angle to find the third side, or enter all three sides to find an angle as C = arccos((a² + b² − c²)/(2ab)). It works for every triangle and reduces to the Pythagorean theorem at 90°.
Formula
How this is calculated
The law of cosines generalizes the Pythagorean theorem to any triangle. In SAS mode you supply two sides a and b together with the included angle C (the angle between them, in degrees). The third side is found with c = √(a² + b² − 2ab·cos C). When C = 90° the cosine term vanishes and the formula reduces to the Pythagorean theorem.
In SSS mode you supply all three side lengths and the calculator returns angle C, the angle opposite side c, using C = arccos((a² + b² − c²) / (2ab)). The argument of arccos is always between −1 and 1 for a valid triangle, so an obtuse angle yields a negative cosine and an angle greater than 90°.
Angles are measured in degrees and sides share any consistent length unit. Inputs must be positive, the included angle must lie strictly between 0° and 180°, and three sides must satisfy the triangle inequality (each side less than the sum of the other two). The calculator also reports the remaining two angles by reapplying the same rule, so all three angles sum to 180°.
Frequently asked questions
Use the law of cosines when you know two sides and their included angle (SAS) or all three sides (SSS). The law of sines works best when you have an angle paired with its opposite side.
Angles are entered and reported in degrees. The calculator converts to radians internally because trigonometric functions expect radians.
The three lengths must form a valid triangle. If any side is greater than or equal to the sum of the other two, the triangle inequality fails and no angle exists.
Also known as
TG we-Calculate Editorial Team. (2026). Law of Cosines Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/law-of-cosines-calculator
TG we-Calculate Editorial Team. "Law of Cosines Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/law-of-cosines-calculator.
TG we-Calculate Editorial Team, "Law of Cosines Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/law-of-cosines-calculator
@misc{wecalculate_law_of_cosines_calculator, title = {Law of Cosines Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/law-of-cosines-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
