Law of Cosines Calculator
Enter two sides and the angle between them to find the third side of any triangle — the law of cosines works where the Pythagorean theorem stops.
Any triangle, any angle
Give two sides and the angle between them and the calculator returns the third side using c = √(a² + b² − 2ab·cos(C)).
Angle in degrees
The included angle is entered in degrees and must be greater than 0° and less than 180° — the two sides share that vertex.
What is the law of cosines?
The third side of a triangle
The law of cosines is the rule that lets you find the missing third side of a triangle when you know two sides and the angle between them. This law of cosines calculator takes two sides, a and b, and the included angle C, and returns the side c that lies opposite that angle. It is the tool surveyors, navigators, and engineers reach for when a triangle is not right-angled and the simple Pythagorean theorem no longer applies.
Enter two sides and the angle between them to get the third side instantly.
The third side equals the square root of the sum of the squares of the two known sides, minus twice their product times the cosine of the included angle.
c = √(a² + b² − 2ab·cos(C))The cosine term is what bends the formula to fit any angle. When C is 90° its cosine is zero, the last term vanishes, and the expression collapses to the Pythagorean theorem c = √(a² + b²). A larger, obtuse angle makes the cosine negative, which adds to the total and lengthens the third side; a smaller, acute angle shortens it.
Suppose two sides measure 5 and 7, with an angle of 60° between them.
Square the two sides
5² + 7² = 25 + 49 = 74 — the sum of the squares.
Subtract the cosine term
2 × 5 × 7 × cos(60°) = 70 × 0.5 = 35, so 74 − 35 = 39.
Take the square root
√39 ≈ 6.244998 — the length of the third side c.
The number you get is the length of the side opposite the angle you entered, in whatever unit you used for the two sides. The angle is the lever that moves the result: keep the two sides fixed and a wider angle spreads them apart, producing a longer third side, while a narrower angle folds them together for a shorter one. At exactly 90° the result matches the hypotenuse you would get from the Pythagorean theorem, which is why the law of cosines is often described as its generalisation. This is the everyday reason the rule matters — it measures distances across triangles that have no right angle, from the gap between two landmarks seen from a single point to the closing side of a surveyed plot.
The formula is exact, but a couple of practical points are worth keeping in mind.
Angle in degrees, between the two sides
Enter the included angle in degrees, not radians, and keep it strictly between 0° and 180° — an angle of 0° or 180° collapses the triangle to a line. The angle must be the one between the two sides you enter; using a different angle gives a different side. At exactly 90° the law of cosines reduces to the Pythagorean theorem, so both methods agree there.