What does this calculator do?
The law of cosines extends the Pythagorean theorem to every triangle by correcting with the included angle: c² = a² + b² − 2ab·cos(C). Use it forwards to find the third side from two sides and the angle between them (SAS), or backwards to find any angle when all three sides are known (SSS). Use any length unit as long as all side inputs use the same one — side results come out in that same unit, and angles are entered and reported in degrees.
Formula
The same identity, solved in each direction:
c² = a² + b² − 2ab·cos(C) C = arccos((a² + b² − c²) ÷ 2ab)
How to use it
Pick the mode: for the side, enter a, b and the included angle C (0° < C < 180°); for the angle, enter the three sides (they must form a valid triangle). Angle C is always the one opposite side c.
Worked example
Sides a = 5, b = 7 with included angle C = 49°: c = √(25 + 49 − 70·cos 49°) = 5.2987. Reversed with c = 6, the sides 5, 7, 6 give C = arccos(38 ÷ 70) = 57.12°.
Frequently asked questions
How does this relate to the Pythagorean theorem?
Set C = 90°: cos(90°) = 0 and the correction term vanishes, leaving c² = a² + b². The law of cosines is the general case for any angle.
The angle must be the included one — why?
The formula pairs side c with the angle opposite it, which is the angle between a and b. Using a non-included angle answers a different problem (that is the law of sines territory).
Can the result be an obtuse angle?
Yes — in SSS mode, if a² + b² < c² the cosine is negative and C comes out between 90° and 180°. arccos handles the whole range without ambiguity.
Sources
- Standard Euclidean triangle geometry (Heron’s formula, the Pythagorean theorem, the law of cosines). Results are mathematically calculated from the supplied values, subject to input and display precision; the exact formula is shown on this page.
- OpenStax — Algebra and Trigonometry 2e (non-right triangles: law of cosines and Heron’s formula chapter)
- Khan Academy — Right triangles and trigonometry (kept as an accessible explainer, not the primary source)
- Reviewed: 2026-07-31
Related calculators
Last updated: 2026-07-31 · v1.0.0 · Report an error