Law of Cosines Calculator
Calculate the unknown side of any triangle when two sides and the included angle are known, using the Law of Cosines. Essential for navigation, land surveying, and geometry problems.
About this calculator
The Law of Cosines generalises the Pythagorean theorem to non-right triangles. It states: c² = a² + b² − 2ab·cos C, where a and b are the two known sides and C is the included angle between them. Solving for side c: c = √(a² + b² − 2ab·cos C). When C = 90°, cos C = 0 and the formula reduces to the Pythagorean theorem c = √(a² + b²). The law can also be rearranged to find an unknown angle when all three sides are known: cos C = (a² + b² − c²) / (2ab). Angles can be entered in degrees or radians; the calculator converts to radians internally before evaluating the cosine function. This formula applies to all triangle types: acute, obtuse, and right.
How to use
Find side c given a = 5, b = 8, and included angle C = 60°. Apply the formula: c = √(5² + 8² − 2·5·8·cos 60°) = √(25 + 64 − 80·0.5) = √(89 − 40) = √49 = 7. Enter sideA = 5, sideB = 8, angleC = 60, and select degrees. The calculator returns c = 7 exactly. Now try C = 90°: c = √(25 + 64 − 0) = √89 ≈ 9.434, confirming it matches the Pythagorean theorem for a right angle.
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 the included angle (SAS) or all three sides (SSS). The Law of Sines is more convenient when you know two angles and a side (AAS or ASA), because it involves simpler arithmetic. The Law of Cosines is necessary for SAS and SSS because the Law of Sines requires at least one angle-side opposite pair to set up its ratio. Starting with the Law of Cosines to find one side or angle often unlocks the remaining unknowns via the Law of Sines.
How do I use the Law of Cosines to find an unknown angle?
Rearrange the standard formula to isolate the cosine: cos C = (a² + b² − c²) / (2ab). Compute the right-hand side with your known side values, then apply the inverse cosine (arccos) to get angle C. For example, with a = 6, b = 8, c = 7: cos C = (36 + 64 − 49) / (96) = 51/96 ≈ 0.5313, so C = arccos(0.5313) ≈ 57.9°. Repeat the process for the other angles using different side combinations, or switch to the Law of Sines once one angle is known.
Does the Law of Cosines work for obtuse triangles?
Yes, the Law of Cosines works for all triangle types, including obtuse triangles where one angle exceeds 90°. The cosine of an obtuse angle is negative, so the term −2ab·cos C becomes a positive addition, correctly producing a longer side opposite the obtuse angle. For example, if C = 120°, cos(120°) = −0.5, so −2ab·(−0.5) = +ab, increasing c² beyond a² + b². This behaviour is physically intuitive: the side opposite a larger angle must itself be longer.