Law of Cosines Calculator
Enter any 3 of the 4 values (sides a, b, c and angle C) to solve for the unknown.
This tool is for informational and educational purposes only. It is not a substitute for professional financial, medical, legal, or engineering advice. See Terms of Service.
Can't find what you need?
Request a ToolHow to Use the Law of Cosines Calculator
This calculator applies the law of cosines formula to solve for a missing side or angle in a triangle.
- Enter 3 known values. Fill in any 3 of the 4 fields: sides a, b, c and angle C (in degrees). Leave the unknown field empty.
- Read the result. The calculator instantly solves for the missing value and shows the formula used.
- Share or copy. Generate a shareable link or copy the answer.
The law of cosines is most useful when you know two sides and the included angle (SAS) or all three sides (SSS). It generalizes the Pythagorean theorem to non-right triangles.
About the Law of Cosines
The law of cosines states that c^2 = a^2 + b^2 - 2ab*cos(C), where c is the side opposite angle C. When angle C is 90 degrees, cos(90) = 0, and the formula reduces to the Pythagorean theorem: c^2 = a^2 + b^2. This formula works for any triangle and is one of the two fundamental tools (along with the law of sines) for solving oblique triangles. It can be rearranged to solve for the angle when all three sides are known: C = arccos((a^2 + b^2 - c^2) / (2ab)).
Frequently Asked Questions
When should I use the law of cosines vs the law of sines?
Use the law of cosines when you know two sides and the included angle (SAS), or all three sides (SSS). Use the law of sines when you know a side-angle pair plus one additional value (AAS, ASA, or SSA configurations). The law of cosines is generally more straightforward and avoids the ambiguous case that can occur with the law of sines.
How is the law of cosines related to the Pythagorean theorem?
The Pythagorean theorem is a special case of the law of cosines. When angle C is exactly 90 degrees, cos(90) equals zero, so the -2ab*cos(C) term disappears. The formula then simplifies to c^2 = a^2 + b^2, which is the Pythagorean theorem.
Can the law of cosines give no solution?
Yes. When solving for an angle, if the expression inside the arccos function falls outside the range [-1, 1], no valid triangle exists with those side lengths. This happens when the three sides violate the triangle inequality (e.g., one side is longer than the sum of the other two).