What is a law of cosines calculator?
The law of cosines calculator solves a triangle when you know two of its sides and the angle between them (the “side-angle-side” case). You enter side , side , and the included angle , and the calculator returns the length of the third side along with the two remaining angles and .
The law of cosines is a generalization of the Pythagorean theorem. When the included angle is exactly the cosine term vanishes and the formula collapses back to , the familiar relation for a right triangle.
How does it work?
The third side comes directly from the law of cosines:
Taking the square root gives :
Once all three sides are known, the angle opposite side is recovered by rearranging the same law:
Because the three interior angles of any triangle sum to , the last angle follows immediately:
The included angle must lie strictly between and , and both given sides must be positive, for the triangle to exist.
Worked examples
Right triangle. With , , and , the cosine term drops out, so . The remaining angles are and , recovering the classic 3-4-5 triangle.
Oblique triangle. With , , and , we get .
Practical notes
The law of cosines is most useful when the law of sines cannot start a solution — specifically in the side-angle-side and side-side-side cases, where no side and its opposite angle are known together. Surveyors, navigators, and engineers rely on it to compute distances across a baseline when only two legs and the angle between them can be measured.
If instead you know two angles and a side, or two sides and a non-included angle, the law of sines is the more direct tool. For the special right-triangle case you can also use the hypotenuse calculator, and to evaluate the cosine of the included angle on its own, see the trigonometry calculator.