Calculate any missing side or angle of a triangle from the Law of Cosines.
Law of Cosines Formula
The Law of Cosines relates the three sides of a triangle to the cosine of one of its angles. It works for any triangle, not just right triangles. The calculator uses two forms depending on what you are solving for.
To find a missing side when you know two sides and the angle between them (SAS):
a = sqrt(b^2 + c^2 - 2*b*c*cos(A))
To find a missing angle when you know all three sides (SSS):
A = arccos((b^2 + c^2 - a^2) / (2*b*c))
- a, b, c = the lengths of the three sides of the triangle
- A = the angle opposite side a, measured in degrees or radians
- arccos = the inverse cosine function, which returns the angle whose cosine is the given value
When you choose the SAS side mode, you enter two sides and the included angle between them, and the calculator returns the third side using the first formula. When you choose the SSS angle mode, you enter all three sides and the calculator returns the angle you select using the second formula. The full triangle modes apply these formulas repeatedly: from three sides (SSS) it finds all three angles, and from two sides plus the included angle (SAS) it finds the third side and then the two remaining angles. If you turn on extra triangle facts, the calculator also reports the perimeter, the area using Heron's formula, and the circumradius and inradius.
Choosing the Right Method for Your Triangle
The Law of Cosines is the correct tool only for the SSS and SAS cases. The table below shows which inputs match which method so you know when this calculator applies.
| Known information | Case | Method |
|---|---|---|
| Three sides | SSS | Law of Cosines |
| Two sides and the included angle | SAS | Law of Cosines |
| Two angles and one side | AAS or ASA | Law of Sines |
| Two sides and a non-included angle | SSA | Law of Sines (ambiguous case) |
The sign of the result tells you the type of angle. The next table shows how the cosine value maps to the angle classification.
| Value of cos(A) | Angle A | Triangle type at A |
|---|---|---|
| Positive | Less than 90 degrees | Acute |
| Zero | Exactly 90 degrees | Right |
| Negative | More than 90 degrees | Obtuse |
Example Problems
Example 1: Find a missing side (SAS). A triangle has sides b = 5 and c = 7 with an included angle A = 60 degrees. Using a = sqrt(b^2 + c^2 - 2*b*c*cos(A)), you get a = sqrt(25 + 49 - 2*5*7*0.5) = sqrt(74 - 35) = sqrt(39), so a is about 6.24.
Example 2: Find a missing angle (SSS). A triangle has sides a = 8, b = 6, and c = 5. Using A = arccos((b^2 + c^2 - a^2) / (2*b*c)), you get A = arccos((36 + 25 - 64) / (2*6*5)) = arccos(-3 / 60) = arccos(-0.05), so A is about 92.87 degrees, an obtuse angle.
Frequently Asked Questions
When should I use the Law of Cosines instead of the Law of Sines? Use the Law of Cosines when you know all three sides (SSS) or two sides and the angle between them (SAS). Use the Law of Sines when you know two angles and a side, or two sides and an angle that is not between them. The Law of Cosines is the only one that can start from three sides alone.
Can the Law of Cosines find an obtuse angle? Yes. The inverse cosine returns angles from 0 to 180 degrees, so it correctly identifies obtuse angles. When the term (b^2 + c^2 - a^2) is negative, the cosine is negative and the angle is greater than 90 degrees.
Does the Law of Cosines work for right triangles? Yes. If the angle is 90 degrees its cosine is zero, so the last term drops out and the formula reduces to a^2 = b^2 + c^2, which is the Pythagorean theorem. The Law of Cosines is a general version that holds for every triangle.
