Home/Calculators/Math/Law of Cosines Calculator

Law of Cosines Calculator

Find the third side of a triangle from two sides and the included angle — instant and free.

law-of-cosines-calculator
Result
—
In summary: The law of cosines gives c = √(a² + b² − 2ab·cos C). For sides a = 3, b = 4 and included angle C = 90°, c = √(9 + 16 − 0) = 5.

What is the law of cosines

The law of cosines finds the third side of any triangle from two sides and the angle between them: c = √(a² + b² − 2ab·cos C). For a = 3, b = 4 and C = 90°, cos 90° = 0, so c = √(9 + 16) = 5.

Think of the −2ab·cos C term as a correction to the Pythagorean theorem: when C is acute the term subtracts and c comes out shorter, and when C is obtuse it adds and c grows longer. Solving the rearranged formula for an unknown angle means taking an inverse cosine, which is what the arccosine calculator does.

How to use this calculator

Enter the two known sides and the included angle C (in degrees) between them. The result is the side opposite that angle. When C = 90° the formula reduces to the Pythagorean theorem.

The word included matters: C must be the angle between sides a and b, not one of the other corners. Both sides should be in the same unit, and the answer comes back in that unit.

Right triangles and beyond

The law of cosines works for any triangle, not just right ones, and is the companion of the law of sines. The cosine term comes from the cosine of the included angle.

A quick check on any result is the triangle inequality: the answer must be smaller than a + b and larger than the difference between a and b. With a = 3 and b = 4 that means c has to sit between 1 and 7, and the answer of 5 comfortably does.

Frequently asked questions

What is the law of cosines formula?
c = √(a² + b² − 2ab·cos C), where C is the angle between sides a and b.
What is the third side when a = 3, b = 4, C = 90°?
c = 5, because cos 90° = 0 and the formula reduces to √(3² + 4²).
Does the law of cosines work for any triangle?
Yes, it applies to all triangles. For a 90° angle it becomes the Pythagorean theorem.
What units does the angle use?
Enter the included angle C in degrees; it is converted to radians internally.
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 angle between them, or all three sides. The law of sines needs a known side paired with its opposite angle, so it cannot start from that information.
How this tool works

The formula behind this tool is written out in full in the sections above, so you can check the maths yourself. Every calculator on Calculorium is verified against worked examples with automated tests before it is published, and pages are reviewed as formulas or standards change. Nothing you type is sent anywhere — the calculation runs entirely in your browser. Read how we build and check these tools.

Last updated: July 27, 2026 · Calculations run in your browser. Estimates for information only.