method
Law of Cosines Calculator
Apply the Law of Cosines (c\u00B2 = a\u00B2 + b\u00B2 \u2212 2ab\u00B7cos C) to solve triangles from SSS or SAS inputs. Step-by-step solution with all derived properties.
More Math Calculators
Explore the category
Click to show tips
Pick a scenario to see how the calculator works, then adjust the values
A triangular park has paths of 120 m, 90 m, and 150 m. Find the angle at each corner.
Key values: a = 120 m · b = 90 m · c = 150 m
Two roads diverge at 55° — one is 8 km, the other is 12 km. What is the straight-line distance between their ends?
Key values: a = 8 km · b = 12 km · C = 55°
Select your known values (SSS, SAS, ASA, AAS, or SSA) and enter measurements to solve the triangle and compute area, perimeter, inradius, and more.
The law of cosines generalizes the Pythagorean theorem to any triangle:
When , the cosine term vanishes () and you recover . The law of cosines handles what the Pythagorean theorem cannot: oblique (non-right) triangles.
By symmetry, equivalent forms exist for each side:
Rearrange the formula to find an angle when all three sides are known:
Example: Triangle with sides a = 5, b = 7, c = 8:
Strategy: In SSS problems, find the largest angle first (opposite the longest side). If it turns out to be obtuse, the other two angles must be acute, which avoids the ambiguous case when using the law of sines afterward.
Given sides and with included angle , find the third side directly:
Example: Sides 10 and 12, included angle 50°:
| Situation | Use |
|---|---|
| SSS (three sides) | Law of Cosines |
| SAS (two sides + included angle) | Law of Cosines |
| ASA / AAS (two angles + one side) | Law of Sines |
| SSA (two sides + non-included angle) | Law of Sines (ambiguous case!) |
The law of cosines never produces an ambiguous case. The inverse cosine function returns a unique angle in , which is exactly the valid range for triangle angles. The law of sines can give two possible angles (the “ambiguous case”) because .
Place the triangle with vertex C at the origin and side along the x-axis. Then vertex A is at and vertex B is at . The distance formula gives:
which is exactly the law of cosines. This coordinate proof shows it is simply the distance formula applied to a triangle.
The law of cosines states that , where is the angle opposite side . It generalizes the Pythagorean theorem to all triangles. When , the cosine term vanishes and the formula reduces to .
Use the law of cosines for SSS (three sides known) and SAS (two sides and the included angle). Use the law of sines for ASA, AAS, and SSA cases. The law of cosines never produces an ambiguous case, making it the safer choice when applicable.
Rearrange to , then take the inverse cosine. For example, with sides 5, 7, and 8: , so .
The inverse cosine function returns a unique angle in , which is exactly the valid range for triangle angles. The law of sines can give two possible angles because , but cosine does not have this ambiguity.
Place vertex C at the origin with side along the x-axis. Vertex B is at . Applying the distance formula gives , which is the law of cosines.