Law of Cosines Calculator
°
Side c5.0000
Angle A36.87°
Angle B53.13°
Angle C90.00°
The Law of Cosines Calculator solves oblique (non-right) triangles in two directions. Give it two sides and the angle wedged between them and it returns the opposite third side (the SAS case); give it all three side lengths and it returns every interior angle (the SSS case). The relation generalizes the Pythagorean theorem, reducing to it exactly when the included angle is 90 degrees.
Formula
c² = a² + b² − 2ab·cos(C)
- a, b
- The two known sides that bracket angle C
- c
- Side opposite the included angle C
- C
- Included angle between sides a and b (degrees)
How it works
- Pick a mode: "Find Side (SAS)" when you know two sides and the angle between them, or "Find Angle (SSS)" when you know all three sides.
- In SAS mode, enter sides a and b plus the included angle C; the calculator computes c = sqrt(a² + b² − 2ab·cos C), then derives the remaining two angles.
- In SSS mode, enter all three sides; each angle is recovered by rearranging the formula to cos C = (a² + b² − c²) / (2ab), and the third angle is found from the 180-degree sum.
Worked example
SAS: two sides measure 8 and 11 with an included angle of 37.5 degrees.
- c² = 8² + 11² − 2·8·11·cos(37.5°) = 64 + 121 − 176·0.7934.
- c² = 185 − 139.63 = 45.37, so c = sqrt(45.37) = 6.7357.
- Angle A = arccos((11² + 6.7357² − 8²) / (2·11·6.7357)) = 46.30°, and B = 180 − 46.30 − 37.5 = 96.20°.
Side c = 6.7357, angle A = 46.30°, angle B = 96.20°.
Frequently asked questions
- 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 their included angle (SAS) or all three sides (SSS). The law of sines is the better choice when you have an angle paired with its opposite side, such as AAS, ASA, or SSA.
- How does the law of cosines relate to the Pythagorean theorem?
- When the included angle C is 90 degrees, cos(C) equals zero, so the −2ab·cos(C) term vanishes and the formula collapses to c² = a² + b², which is exactly the Pythagorean theorem.
- Can three side lengths fail to form a triangle?
- Yes. The sum of any two sides must strictly exceed the third (the triangle inequality). The calculator rejects inputs that violate this rule because no real triangle exists for them.
- Does the SSS case ever have more than one answer?
- No. Three fixed side lengths determine a single triangle shape, so the angles are unique. Only the SSA configuration solved with the law of sines produces the ambiguous two-triangle case.