Pi day logo horizontal Pi day logo vertical

Law of Cosines Calculator

Go back to Calculators page

One method to find the lengths of the sides and measures of angles in a triangle is through the law of cosines. The law of cosines calculator uses this method to find the desired properties of a triangle quickly and efficiently.

What is the law of cosines?

Recall that the Pythagorean theorem enables one to find the lengths of the sides of a right triangle, using the formula \(a^{2}+b^{2}=c^{2}\), where a and b are sides and c is the hypotenuse of a right triangle. The Law of cosines is really a form of the Pythagorean theorem, modified for use of non-right triangles.  It describes the association between the lengths of the sides of any triangle.

For a triangle with sides a, b, c and corresponding angles  α, β, and  γ, the law of cosines states that

\(a^{2}=b^{2}+c^{2}-(2bc)\cos (\alpha)\)


\(b^{2}=a^{2}+c^{2}-(2ac)\cos (\beta)\)


\(c^{2}=a^{2}+b^{2}-(2ab)\cos (\gamma)\)


Now we can use the law of cosines for a variety of things involving a triangle. First, you can obtain the length of the third side of a triangle knowing the other two side lengths and the angle between them.

Just solve the above equations for a, b, or c, depending on which side you need to obtain. This is simply done by taking the square root of the right side of the equation.

If you know two sides and the angle opposite one of them, you can obtain the length of the third side. Similarly, it is possible to find the angles of the triangle knowing all three sides and solving the formula for the angles as follows:

\(\alpha = \arccos (\frac{b^{2}+c^{2}-a^{2}}{2bc})\)


\(\beta = \arccos (\frac{a^{2}+c^{2}-b^{2}}{2ac})\)


\(\gamma = \arccos (\frac{a^{2}+b^{2}-c^{2}}{2ab})\)


While these calculations can certainly be done manually with a little time and effort, the Law of cosines calculator does this for you quickly. Simply enter the information you know about the sides and/or angles and let the calculator do the rest!