Law of Cosines Calculator
The law of cosines solves any triangle from two sides and the included angle (SAS) or from all three sides (SSS). Enter your known values and get every triangle property at once: the missing side or angle, all three angles, area, perimeter, semi-perimeter, the inscribed circle radius, and the circumscribed circle radius.
Formula
Worked example
Sides a = 8, b = 11, included angle C = 37°: c² = 64 + 121 - 2·8·11·cos 37° = 185 - 176·0.79864 = 185 - 140.56 = 44.44, so c = 6.667. Then angle A = arccos((121 + 44.44 - 64)/(2·11·6.667)) = arccos(101.44/133.34) = arccos(0.7607) = 40.48°. Angle B = 180 - 37 - 40.48 = 102.52°. Area via Heron: s = (8 + 11 + 6.667)/2 = 12.834, Area = sqrt(12.834 · 4.834 · 1.834 · 6.167) = 26.55 sq units.
What the law of cosines does
The law of cosines connects the three side lengths of any triangle to the cosine of one of its angles, generalising the Pythagorean theorem to all triangles, not just right-angled ones. Written as c² = a² + b² - 2ab·cos(C), it says the square of one side equals the sum of the squares of the other two, minus a correction term that depends on the angle between them. When that angle is 90° its cosine is zero, the correction disappears, and the relation collapses to the familiar a² + b² = c². For acute angles the cosine is positive and the third side is shorter than the Pythagorean estimate; for obtuse angles the cosine is negative and the side is longer.
Two classic use cases: SAS and SSS
The formula serves two standard triangle-solving cases. In the side-angle-side (SAS) case you know two sides and the angle wedged between them, and you substitute directly to find the third side, this is what side mode does. In the side-side-side (SSS) case you know all three lengths and want an angle, so you rearrange to cos C = (a² + b² - c²) / (2ab) and take the inverse cosine. Because arccosine returns a unique value between 0° and 180°, the law of cosines never suffers the ambiguous case that can occur with the law of sines when two triangles share the same SSA data.
Full triangle solve: all angles, area, perimeter, inradius, and circumradius
Once the missing side or angle is found, this calculator applies the law of cosines a second and third time to recover all three angles. Area is then computed from Heron's formula: Area = sqrt(s·(s-a)·(s-b)·(s-c)) where s is the semi-perimeter (a + b + c) / 2. The inradius r = Area / s is the radius of the inscribed circle, the largest circle that fits entirely inside the triangle. The circumradius R = (a · b · c) / (4 · Area) is the radius of the circumscribed circle that passes through all three vertices. These quantities appear in structural engineering, navigation, surveying, and classical geometry.
Degrees vs. radians and unit-flexible side lengths
Switch the angle unit to radians if your workflow uses them; the calculator converts internally before computing and labels all angle results accordingly. Side inputs accept any consistent unit, whether centimetres, metres, feet, or inches. Because the law of cosines is scale-independent, the unit you enter for the sides is also the unit of the output side and perimeter, and the square of that unit applies to the area. Keep all three sides in the same unit for correct results.
How the included angle shapes the third side and the triangle type
| Angle C | cos C | Side c | Area | Triangle type |
|---|---|---|---|---|
| 30° | 0.866 | 5.71 | 22.00 | Acute |
| 60° | 0.500 | 9.85 | 38.11 | Acute |
| 90° | 0.000 | 13.60 | 44.00 | Right |
| 120° | -0.500 | 16.52 | 38.11 | Obtuse |
| 150° | -0.866 | 18.46 | 22.00 | Obtuse |
With a = 8 and b = 11 held fixed, the opposite side c and triangle properties change as the included angle C opens.
Frequently asked questions
Can this calculator solve all three angles of a triangle at once?
Yes. After finding the primary unknown (a side in SAS mode, or angle C in SSS mode), the calculator applies the law of cosines twice more to recover all three angles. It also reports area, perimeter, semi-perimeter, inradius, and circumradius so you get the complete picture of the triangle in one calculation.
When should I use the law of cosines instead of the law of sines?
Use the law of cosines when you know two sides and the included angle (SAS) or all three sides (SSS). Use the law of sines when you have an angle paired with its opposite side (ASA or AAS). The law of cosines also avoids the ambiguous case that can trip up the law of sines in the SSA configuration, since arccosine always returns a single angle between 0° and 180°.
How is the law of cosines related to the Pythagorean theorem?
It is a direct generalisation. When the included angle C is 90°, cos(90°) = 0, so the term -2ab·cos(C) vanishes and the equation becomes a² + b² = c², which is the Pythagorean theorem. For any other angle the cosine term adjusts the result up (obtuse) or down (acute), extending the theorem to all triangles.
What are the inradius and circumradius of a triangle?
The inradius (r) is the radius of the inscribed circle, the largest circle that fits inside the triangle touching all three sides. It equals the area divided by the semi-perimeter: r = Area / s. The circumradius (R) is the radius of the circumscribed circle that passes through all three vertices: R = (a·b·c) / (4·Area). Both appear in geometry, navigation, and structural calculations.
How do I use radians instead of degrees?
Switch the angle unit selector to Radians. The included angle input (in SAS mode) is then interpreted as radians, and all angle outputs are displayed in radians. The side lengths and area are unaffected by the angle unit choice.
What do the labels a, b, c and C mean here?
Lower-case a, b, c are the three side lengths. Capital A, B, C are the angles opposite those sides respectively, so angle C sits between sides a and b. In side mode you supply a, b and the included angle C to find c; in angle mode you supply all three sides to find angle C. The calculator then derives the remaining two angles, A and B, automatically.