Law of Cosines Calculator
Solve triangles using the law of cosines (SSS or SAS)
Result
—
Related Calculators
Frequently Asked Questions
What is the law of cosines?
For a triangle with sides a, b, c and angle C opposite side c: c^2 = a^2 + b^2 - 2ab*cos(C). This generalizes the Pythagorean theorem: when C = 90deg, cos(90) = 0 and c^2 = a^2 + b^2. Use it when you know SSS (three sides) or SAS (two sides + included angle).
When should I use the law of cosines vs law of sines?
Law of cosines: use for SSS (three sides) or SAS (two sides + included angle). Law of sines: use for AAS (two angles + one side) or ASA (two angles + included side). For SSA (two sides + non-included angle), law of sines has the ambiguous case — law of cosines may be clearer.
How does the law of cosines reduce to Pythagoras?
In a right triangle, the angle C at the right angle is 90 degrees. cos(90) = 0, so 2ab*cos(C) = 0. The law of cosines becomes: c^2 = a^2 + b^2 + 0 = a^2 + b^2. This is exactly the Pythagorean theorem! The law of cosines is the general case.
How do I find all angles of a triangle from three sides (SSS)?
Use the law of cosines to find each angle: cos(A) = (b^2+c^2-a^2)/(2bc), cos(B) = (a^2+c^2-b^2)/(2ac), cos(C) = (a^2+b^2-c^2)/(2ab). Take arccos() to get the angles in degrees. Verify: A + B + C = 180 degrees.
What is the triangle inequality?
For sides a, b, c to form a valid triangle: a + b > c, a + c > b, and b + c > a. All three conditions must hold. The law of cosines will give cos(C) outside [-1, 1] for invalid triangles, which this calculator detects. Examples: sides 3,4,5 valid; sides 1,2,10 invalid (1+2 < 10).
Triangle-Solving Decision Guide
Cosine Values to Remember
| Angle | cos(θ) |
|---|---|
| 0° | 1 |
| 30° | √3/2 ≈ 0.866 |
| 45° | √2/2 ≈ 0.707 |
| 60° | 1/2 = 0.5 |
| 90° | 0 |
| 120° | −0.5 |
| 180° | −1 |