Advertisement

Law of cosines calculator

Use SAS to calculate side c opposite the included angle C, or SSS to calculate all angles from three positive side lengths.

Calculator

Side a
3
Side b
4
Side c
5
Angle A (opposite a)
36.8699
Angle B (opposite b)
53.1301
Angle C (opposite c)
90
Triangle area
6
Perimeter
12

Advertisement

How this calculator works

The cosine term adjusts the Pythagorean relationship for the angle between two sides. It vanishes at a right angle, is positive for acute angles and is negative for obtuse angles. Three known sides uniquely determine the angles if the strict triangle inequality holds. Calculations retain full internal precision; choose degrees, radians or turns in the readout.

Formula

c²=a²+b²-2ab cos C; cos A=(b²+c²-a²)/(2bc); cos B=(a²+c²-b²)/(2ac); K=ab sin C/2.

Worked example

Sides a = 3 m, b = 4 m and C = 90° give c = 5 m and area 6 m². Equal sides a = b = 2 cm with C = 60° give c = 2 cm and area √3 cm².

Advertisement

Frequently asked questions

Why must C be the included angle?

The formula relates c to the angle between a and b. If the angle is opposite one of the known sides, use the law of sines and check for ambiguity.

What if the three sides cannot meet?

The calculator rejects zero lengths and lengths whose two shortest sides sum to no more than the longest.

Does the law work for an obtuse triangle?

Yes. The cosine becomes negative, so the opposite side squared exceeds the sum of the other two squares.

Sources

Advertisement