The law of cosines lets you solve a triangle when you know two sides and the angle between them (SAS), or all three sides (SSS) — the two cases the law of sines can't handle directly, since neither gives you a ready-made angle-side pair. This calculator solves for the missing side or angle, then chains the same identity to fill in the rest of the triangle and its area.
How the Law of Cosines Calculator works
The law of cosines, c² = a² + b² − 2ab·cosC, relates a triangle's three sides to the cosine of the angle opposite side c. In SAS mode, C is the known included angle between sides a and b, so plugging directly into the formula gives side c. In SSS mode, all three sides are known and the formula is rearranged to solve for the angle instead: cosC = (a² + b² − c²) / (2ab).
Once one unknown is solved, the calculator finds the remaining two angles using the law of cosines again (not the law of sines) — for example, A = acos((b²+c²−a²)/(2bc)), then B = 180° − A − C. Using the law of cosines for every angle avoids the ambiguous-case problem that the law of sines has with its two-valued sine function: cosine's inverse is single-valued over a triangle's 0°–180° angle range, so there's never a second candidate angle to rule out.
Inputs and what they mean
In SAS mode, angle C must be the included angle — the one directly between sides a and b, not opposite one of them. Entering an angle that's opposite a side instead of between two sides is the SSA case, which the law of cosines can't solve directly (that needs the law of sines, and carries the ambiguous-case risk this calculator's SAS/SSS design avoids entirely).
In SSS mode, all three sides must satisfy the triangle inequality — every pair of sides must add up to more than the third side (a+b>c, a+c>b, b+c>a). If they don't, no triangle exists with those measurements and the calculator flags it rather than returning a meaningless result.
Limits and edge cases
This calculator solves plane (Euclidean) triangles with exact input values — it doesn't model measurement uncertainty or spherical geometry (used in some navigation and astronomy problems). If you instead know an angle-side pair plus one more value (ASA, AAS, or SSA), the law of cosines isn't the right tool — use the law of sines, which may also need to flag the SSA ambiguous case.
A triangle that barely satisfies the SSS inequality, or a SAS angle very close to 0° or 180°, produces a valid but nearly degenerate triangle — one so "flat" its area is close to zero. The calculator still solves these correctly rather than rejecting them, but flags the result so you can double-check your inputs if that's unexpected.