Law of Cosines Calculator
Solve triangles using the Law of Cosines: c² = a² + b² − 2ab·cos(C). Perfect for SAS (two sides + included angle) and SSS (three sides). Includes a live triangle diagram, smart validity checks, and student-friendly step-by-step.
Which method should I use?
Have SSS or SAS? → Law of Cosines ✅
Have ASA / AAS / SSA? → Law of Sines ✅ (SSA can be ambiguous)
Background
The Law of Cosines is a triangle-solving formula that generalizes the Pythagorean theorem to any triangle (not just right triangles). It connects three sides and an included angle: c² = a² + b² − 2ab·cos(C).
It’s the best tool when you have SAS (two sides + the included angle) or SSS (three sides). For ASA/AAS (two angles + a side) and most SSA cases, the Law of Sines is usually the better first move.
How to use this calculator
- Pick a mode: Find a side (SAS), Find an angle (SSS), or Solve the whole triangle.
- Choose degrees or radians, enter values, then click Calculate.
- Use the diagram to sanity check: bigger angle ↔ bigger opposite side.
How this calculator works
- Law of Cosines (side form): c² = a² + b² − 2ab·cos(C).
- Law of Cosines (angle form): cos(C) = (a² + b² − c²) / (2ab), then C = arccos(…).
- Triangle inequality (SSS): each pair of sides must sum to more than the third.
Formula & Equation Used
Side from SAS: c = √(a² + b² − 2ab·cos(C))
Angle from SSS: C = arccos((a² + b² − c²)/(2ab))
Angle sum: A + B + C = 180° (or π radians)
Example Problem & Step-by-Step Solution
Example 1 — SAS (find a side)
Given a=7, b=10, C=60°. Find c.
- Use Law of Cosines: c² = a² + b² − 2ab·cos(C).
- Plug in: c² = 7² + 10² − 2·7·10·cos(60°).
- Compute: c² = 49 + 100 − 140·0.5 = 79.
- So c = √79 ≈ 8.89.
Example 2 — SSS (find an angle)
Given a=7, b=8, c=9. Find angle C.
- Compute cos(C)=(a²+b²−c²)/(2ab).
- Plug in: cos(C)=(49+64−81)/(2·7·8)=32/112≈0.2857.
- Then C=arccos(0.2857)≈73.40°.
Example 3 — Solve whole triangle (SAS)
Given a=5, b=8, C=110°. Solve the triangle.
- Find c with Law of Cosines.
- Then use Law of Sines to compute A and B.
- Check: A+B+C=180°.
Frequently Asked Questions
Q: When should I use Law of Cosines?
When you have SSS or SAS. It’s the best “first move” in those cases.
Q: Why do you clamp the arccos input?
Because rounding can produce tiny values like 1.0000000002, which would break arccos. Clamping keeps it safe.
Q: Can I solve SSA with Law of Cosines?
Not reliably. SSA is usually a Law of Sines scenario and can be ambiguous (0/1/2 triangles).