Skip to content

Law of cosines calculator

Solve the opposite side from SAS or a selected angle from three valid sides (SSS).

See the cosine rule in the triangleThe included angle C determines the opposite side c.ABCThe included angle C determines the opposite side c.

Triangle data

Processed in your browser.

Use any positive length unit consistently.

Use the same unit as side a.

SAS: angle C in degrees, strictly between 0° and 180°. SSS: positive side c.

Cosine rule result

Choose SAS or an SSS target, then enter three values.

How to use the law of cosines

Choose SAS or SSS

Choose SAS when you know sides a and b and their included angle C; enter C in the third field to find opposite side c. Choose an SSS target when all three side lengths are known; enter side c in the third field and select which angle should be the main result.

All sides must be positive and use the same unit. SSS inputs must satisfy the strict triangle inequalities. Any edit clears the confirmed result before another calculation.

Cosine rule formulas

For SAS, c = √(a² + b² − 2ab cos C). The angle must sit between the two entered sides; an SSA case uses different information and is intentionally outside this page.

For SSS, C = acos((a² + b² − c²)/(2ab)). Cyclic versions find A and B. The calculator computes all three angles as a consistency aid and highlights the selected one.

Validation and precision

Three sides form a non-degenerate triangle only if a + b > c, a + c > b and b + c > a. Equality describes a collapsed segment and is rejected. Zero, negatives, formulas, units in fields and non-finite results are also rejected.

Lengths retain full browser precision during the calculation. Ordinary displayed values use at most two decimals; tiny meaningful values retain significant digits.

Worked examples

SAS: 3, 4 and 90°

With a = 3, b = 4 and included C = 90°, c = √(9 + 16) = 5. This is the Pythagorean theorem as the right-angle special case.

SSS: sides 3, 4 and 5

Choose SSS — find angle C and enter a = 3, b = 4, c = 5. The result is C = 90°; A is about 36.87° and B about 53.13°.

Frequently asked questions

Which angle is C?

C is opposite side c. In SAS mode it is also the included angle between entered sides a and b.

Why is 1, 2, 3 rejected?

Because 1 + 2 equals 3, so the shape collapses and has no positive area.

Can I enter different units for each side?

No. Convert them first and use one consistent unit; the result uses that same unit.

Does this solve SSA or the law of sines?

No. This focused calculator supports SAS and SSS only.