Law of Cosines Calculator: SSS & SAS Triangle Solver
Solve any triangle from three sides (SSS) or two sides and the included angle (SAS) using the law of cosines — get every side, angle, and the area.
Law of cosines formulas
The law of cosines relates a triangle's three sides to one of its angles — it works for ANY triangle, not just right triangles:
This calculator solves it both ways:
| Known | Solve for | Formula |
|---|---|---|
| Three sides (SSS) | Any angle | |
| Two sides + included angle (SAS) | The third side |
Solving SSS (three sides)
Example: sides a = 7, b = 8, c = 9
The same formula, rotated to each side, gives and (summing to 180°, as every triangle's angles must). With all three sides already known, Heron's formula gives the area directly: .
Solving SAS (two sides + included angle)
Example: sides a = 5, b = 7, included angle C = 60°
Once is known, the remaining two angles follow from the law of cosines again (or the law of sines, now that a side/angle pair exists), and the area comes from .
Common mistakes
- Using a non-included angle in the SAS formula. If the angle isn't the one between the two given sides, the law of cosines as written doesn't apply — that's the SSA case instead, handled by the law of sines (and possibly two solutions).
- Dropping the minus sign. Forgetting the term (or its sign) is the single most common algebra slip with this formula.
- Entering side lengths that fail the triangle inequality. Each side must be shorter than the sum of the other two — sides like 1, 1, 10 can't close into a triangle at all.
Where this shows up
- Surveying and navigation: finding a distance across an obstacle by measuring two legs and the angle between them.
- Physics: combining two vectors at an arbitrary angle — the resultant's magnitude is exactly a law-of-cosines problem.
- Engineering and construction: any layout problem with a known angle that isn't 90°, where the plain Pythagorean theorem doesn't apply.
The law of cosines is the direct generalization of the Pythagorean theorem to any triangle, and it shares the same underlying idea as the right triangle calculator's side-solving — just without requiring a 90° angle. Paired with the law of sines and the triangle angle-sum rule, it's one of the core tools for solving any triangle from partial information.
Frequently asked questions
- What is the law of cosines?
- A relationship between a triangle's three sides and one of its angles: (and the two sibling versions for and ). It generalizes the Pythagorean theorem to triangles that aren't right triangles.
- When do 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) — neither case gives you a side/angle pair to set up a law-of-sines ratio. The law of sines instead handles ASA/AAS/SSA.
- How do I find an angle from three known sides (SSS)?
- Rearrange the formula to solve for the angle: . For sides 7, 8, 9 this gives ; the other two angles follow the same way, and the third can also just be the other two.
- How do I find the third side from two sides and the included angle (SAS)?
- Use , where is the angle BETWEEN the two known sides and . For , , : .
- Why must the angle be the one BETWEEN the two given sides?
- The law of cosines derivation drops a perpendicular from the vertex between the two known sides — it only works when that vertex's angle is the one you plug in. Using a non-included angle with two sides is a different case (SSA), which the law of sines handles instead (and which can have zero, one, or two solutions).
- Why do some three side lengths not form a triangle at all?
- The triangle inequality: each side must be shorter than the sum of the other two. Sides 1, 1, and 10 fail this (10 ≥ 1+1), so no such triangle exists — the calculator flags it as invalid rather than returning a nonsensical angle.
- How is the area found once the triangle is solved?
- With all three sides known (SSS), Heron's formula gives the area directly from the sides and the semi-perimeter. With SAS, the simpler uses the two given sides and their included angle.
- Is the law of cosines related to the Pythagorean theorem?
- Yes — it's the general case. When the angle is exactly 90°, , and collapses to , exactly the Pythagorean theorem.