Law of Cosines Calculator
Solve SAS and SSS triangle problems using the Law of Cosines, with side, angle, and validity checks shown step by step. This page is written for students who need both a fast answer and a clear explanation of the method, so it includes the formula, steps, examples, common mistakes, and practical notes.
When the Law of Cosines is the better choice
The Law of Cosines is usually the cleaner method for SAS and SSS triangle problems. If you know two sides and the included angle, it finds the third side directly. If you know all three sides, it finds an angle without needing to create an artificial right triangle. The OpenStax Law of Cosines lesson for non-right triangles presents the same relationship as a direct extension of the Pythagorean theorem for non-right triangles.
Formula and example
The angle in the formula must be the included angle between the two known sides. If the known angle is not between the two sides, the problem may be an SSA case and the Law of Sines may be more appropriate.
Common questions
-
The Law of Cosines relates all three sides of a triangle to one included angle. It is commonly written as c² = a² + b² − 2ab cos(C), where angle C is opposite side c. It works for right triangles and non-right triangles, but it is most useful when the triangle is not right.
-
Use the Law of Cosines when you have SAS or SSS information. That means either two sides and the included angle, or all three side lengths. Use the Law of Sines when you have a known angle-opposite side pair and need another opposite side or angle.
-
Yes. If you know all three sides, rearrange the formula to find the cosine of the angle. For example, cos(C) = (a² + b² − c²) ÷ (2ab). The calculator does this and then applies inverse cosine to return the angle in degrees.
-
Three positive numbers are not always the sides of a triangle. The two shortest sides must add to more than the longest side. If they do not, the Law of Cosines formula may still produce a number, but that number would not represent a real triangle.