Cosine Triangle Calculator — Law of Cosines
Use the law of cosines to solve any triangle: find a missing side from two sides and their included angle (SAS), or find all three angles from three known sides (SSS). Area and perimeter are computed automatically.
Solve mode
°
Third side computed by the law of cosines: c² = a² + b² − 2ab·cos(C)
- 1
cos(C)
cos(60°) = 0.5 - 2
c² = a² + b² − 2ab·cos(C)
5² + 7² − 2 × 5 × 7 × 0.5 = 39 - 3
Side c = √(c²)
√39 = 6.2450
How does this calculator work?
The law of cosines, c² = a² + b² − 2ab·cos(C), finds a missing side from two sides and their included angle (SAS), or finds all angles from three sides (SSS) by rearranging to C = arccos((a²+b²−c²)/(2ab)). Area follows from Heron's formula. Works for acute, right and obtuse triangles.
Formula
How this is calculated
The law of cosines generalises the Pythagorean theorem to all triangles. For a triangle with sides a, b, c and opposite angles A, B, C the rule states c² = a² + b² − 2ab·cos(C). When angle C is 90° the cosine term vanishes and you recover the familiar a² + b² = c²; for obtuse triangles (C > 90°) the cosine is negative so c² exceeds a² + b².
In SAS mode you provide two sides (a, b) and their included angle (C). The calculator plugs them into the formula to get c, then applies the cosine rule again to find angle A = arccos((b² + c² − a²) / (2bc)) and derives B = 180° − A − C. In SSS mode all three sides are known, so each angle is solved by rearranging: cosA = (b² + c² − a²) / (2bc), cosB = (a² + c² − b²) / (2ac), and C = 180° − A − B.
The area is calculated with Heron's formula, Area = √(s(s−a)(s−b)(s−c)) where s = (a+b+c)/2, which is numerically stable for all triangle types. The calculator rejects inputs that violate the triangle inequality (a + b > c, a + c > b, b + c > a); if the three sides cannot form a closed triangle, no result is shown.
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 is simpler for AAS and ASA cases, but produces an ambiguous result for SSA. The cosine rule always gives a unique, unambiguous answer for SAS and SSS.
A valid (non-degenerate) triangle requires that the sum of any two sides exceeds the third: a + b > c, a + c > b, and b + c > a. If any inequality fails the three lengths cannot form a closed triangle and the calculator shows a warning.
Yes. For a right triangle (one angle = 90°) the cosine term is zero and the formula reduces to the Pythagorean theorem. For obtuse triangles (one angle > 90°) the cosine is negative, making the opposite side longer than the Pythagorean prediction. The calculator handles all cases identically.
TG we-Calculate Editorial Team. (2026). Cosine Triangle Calculator — Law of Cosines [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/cosine-triangle-calculator
TG we-Calculate Editorial Team. "Cosine Triangle Calculator — Law of Cosines." TG we-Calculate. 2026. https://we-calculate.com/calculator/cosine-triangle-calculator.
TG we-Calculate Editorial Team, "Cosine Triangle Calculator — Law of Cosines," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/cosine-triangle-calculator
@misc{wecalculate_cosine_triangle_calculator, title = {Cosine Triangle Calculator — Law of Cosines}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/cosine-triangle-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
