Law of Cosines Calculator

c² = a² + b² − 2ab·cos(C). Solve any triangle given SAS or SSS.

Inputs

Result

Loading calculator…

How to use this calculator

  • Enter two sides and the included angle (SAS).
  • Read third side and other angles.

About this calculator

Law of cosines: c² = a² + b² − 2ab·cos(C). Generalizes Pythagorean theorem (when C = 90°, cos C = 0, giving c² = a² + b²). Used to solve SAS triangles (two sides + included angle) or SSS (three sides — solve for any angle: cos(A) = (b² + c² − a²)/(2bc)). Also gives triangle area via ½ab·sin(C).

Frequently asked

When does it match Pythagorean?+
When C = 90°, cos(C) = 0, so c² = a² + b² (the Pythagorean theorem).
When to use vs. law of sines?+
Cosines: SAS (two sides + included angle) or SSS (three sides). Sines: AAS / ASA where you have an angle-side pair.
Area from law of cosines?+
Once you have all three sides, use Heron's formula. Or with two sides + included angle: Area = ½ab sin(C).
How accurate?+
Limited by JS Number precision (~15 sig figs). For most engineering, more than enough.
Surveying use?+
Yes — when triangulating distances and you have side lengths and a measured angle.

Related calculators

More tools you might like

Hand-picked tools that pair well with this one — same audience, same intent.