Law of Cosines Calculator
Given two sides and the included angle, find the third side of any triangle with the law of cosines, plus the remaining angles.
How it works
c² = a² + b² − 2ab·cos(C) · then A = arccos((b² + c² − a²)/(2bc))
The law of cosines generalises the Pythagorean theorem to any triangle. Given two sides and the angle between them (the included angle), it finds the third side directly. When that angle is exactly 90°, cos(90°) = 0 and the formula collapses to c² = a² + b² — the Pythagorean theorem. Once the third side is known, the remaining angles follow from the rearranged cosine rule.
Worked example
For a = 5, b = 7 and included angle C = 60°: c² = 25 + 49 − 2·5·7·cos60° = 74 − 70·0.5 = 39, so c = √39 ≈ 6.245. Then angle A ≈ 43.9° and B = 180 − 60 − 43.9 ≈ 76.1°.
Sources: Law of cosines — Wikipedia
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 better when you have an angle paired with its opposite side.
How does it relate to the Pythagorean theorem?
They are the same when the included angle is 90°. Since cos(90°) = 0, the −2ab·cos(C) term vanishes and you are left with c² = a² + b².
Can the included angle be obtuse?
Yes. For angles above 90° the cosine is negative, which makes the −2ab·cos(C) term positive and produces a longer third side, exactly as expected for an obtuse triangle.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.