Law of Cosines Calculator

TRIGONOMETRY
Area
Side a
Side b
Side c
Angle A
Angle B
Angle C
Perimeter
Law of cosines: the included angle
ABCabc
c² = a² + b² − 2ab·cos C. Angle C is enclosed by sides a and b; side c sits opposite it. Use this when you know two sides and the angle between them, or all three sides.

The law of cosines

The law of cosines generalizes the Pythagorean theorem to any triangle: c squared = a squared plus b squared minus 2ab times the cosine of the included angle C. This calculator uses it two ways — from two sides and the angle between them (SAS), or from all three sides (SSS) — to find every remaining side and angle, plus the area and perimeter.

How it solves

In the SAS case, the formula gives the third side directly, then each angle follows by rearranging the same law: cos A = (b squared plus c squared minus a squared) divided by 2bc. In the SSS case, all three angles come straight from that rearrangement, with the area from Herons formula.

When to use it instead of the law of sines

The law of cosines handles exactly the cases the law of sines cannot start from — two sides with the included angle, or three sides — and it never suffers the ambiguous-case problem, making it the safer choice for side-heavy data.

Related tools

For two angles and a side, use the law of sines calculator; for 90-degree triangles, the right triangle calculator.

Worked example

Sides a = 5, b = 7 with included angle C = 60 give c = the square root of (25 + 49 – 35) = the square root of 39, about 6.24, with an area near 15.16.

FAQ

Which angle is the included one?

In SAS mode, angle C sits between sides a and b, and the side opposite it, c, is the one solved first.

What if three sides cannot form a triangle?

If the longest side meets or exceeds the sum of the other two, no triangle exists and the calculator flags it.

Spotted an error or have a suggestion for this calculator? Let us know →
Related formula: Law of Cosines Formula
Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.