Updated Math

Law of Cosines Calculator

Solve SSS and SAS triangles with the Law of Cosines. Get missing sides and angles, a validity check, area and perimeter, plus history with CSV export.

SSS / SAS Degrees / Radians Area + Perimeter History + CSV

Triangle Solver (Law of Cosines)

Enter SSS (a, b, c) or SAS (two sides and the included angle). Leave unknown fields blank.

Labels: side a opposite angle A, b opposite B, c opposite C. Included angle for sides a & b is C.
Tip: For SAS, enter sides a and b plus included angle C. For SSS, enter a, b, c. The calculator solves all angles.
Case What you know What you compute Key formula
SSS a, b, c A, B, C cos(C) = (a² + b² − c²)/(2ab)
SAS a, b, C (included) c, then A and B c² = a² + b² − 2ab·cos(C)
Area (SAS) a, b, C Area Area = (1/2)ab·sin(C)
Triangle inequality a, b, c Validity a+b>c, a+c>b, b+c>a

Quick Steps

  1. Choose SSS if you know all three sides, or SAS if you know two sides and the included angle.
  2. Select degrees or radians to match your problem.
  3. Enter your values and click Calculate.
  4. Review solved sides/angles and check the Status message.
  5. Export your history to CSV if you want to save your runs.
In SSS, angles are found using arccos. Small rounding differences can push the cosine slightly outside −1 to 1; this tool clamps safely and reports invalid cases clearly.
Your calculation history will appear here after you run the solver.

What Is the Law of Cosines?

The Law of Cosines is a triangle-solving formula that generalizes the Pythagorean theorem to any triangle, not just right triangles. It connects three elements at a time: two sides, the included angle between them, and the opposite side. In the standard labeling system (side a opposite angle A, side b opposite B, side c opposite C), one form is:

c² = a² + b² − 2ab·cos(C)

The same pattern works for the other sides by cycling letters. This is why the Law of Cosines is the go-to method for SAS (two sides and the included angle) and SSS (three sides). In those cases, the Law of Sines doesn’t help immediately because you don’t start with an opposite side–angle pair.

When Should You Use It?

If you’re deciding between triangle tools, the quickest rule is: use Law of Cosines for SSS and SAS, and use Law of Sines for ASA, AAS, and SSA. SSS and SAS show up in construction layouts, navigation legs, engineering diagrams, and geometry problems where lengths are easier to measure than angles.

Included Angle in SAS: What Does It Mean?

In an SAS triangle, the included angle is the angle formed by the two known sides. This matters because the cosine term uses the angle between those sides. For example, if you know sides a and b, the included angle is C, and the formula gives you side c directly. If you accidentally enter a non-included angle, you’re not solving SAS anymore, and the computed results may be wrong or impossible.

How the Calculator Solves SAS

In SAS, the calculator typically works in a clean two-stage process:

  • Step 1: Compute the third side using c² = a² + b² − 2ab·cos(C).
  • Step 2: Compute the remaining angles using arccos formulas, then confirm A + B + C equals 180° (or π radians).

Once all three sides are known, the problem becomes SSS and can be completed consistently.

How the Calculator Solves SSS

With three sides known, the triangle is determined (if it exists). The key is converting side lengths into angles. The Law of Cosines can be rearranged into an arccos form:

cos(C) = (a² + b² − c²) / (2ab)

Then C = arccos( … ). The calculator repeats this for A and B using the appropriate side pairs. It also performs a triangle inequality check first, because if the sides don’t satisfy the inequality, no real triangle can be formed.

Triangle Inequality: The Fastest Validity Check

Three sides only form a triangle if each pair sums to more than the third side: a + b > c, a + c > b, and b + c > a. If any of these fail, the “triangle” collapses into a straight line or becomes impossible. This tool reports that clearly in the Status output.

Degrees vs Radians

Most geometry and measurement problems use degrees, while many physics and calculus formulas use radians. This calculator accepts either. Choose the unit that matches your inputs and the source you’re working from, and the results will be presented in the same unit.

Area and Perimeter

Once a triangle is solved, perimeter is simply a + b + c. Area can be computed in multiple ways. In SAS, area is especially convenient: Area = (1/2)ab·sin(C). In SSS, the calculator can also compute area reliably using Heron’s formula after solving.

Why arccos Can Produce “Domain” Issues

arccos only accepts values from −1 to 1. In a perfectly valid triangle, the computed cosine ratios land inside that range. But rounding, measurement noise, or invalid side sets can push the value just outside. This calculator clamps tiny floating-point drift and still flags truly invalid geometry with a clear error message.

Common Real-World Uses

The Law of Cosines is used anywhere non-right triangles appear: land surveying, structural layouts, robotics linkages, navigation, and even computer graphics. When you know two segment lengths and the angle between them, you can compute the missing span directly. When you know all sides, you can infer angles to align components correctly.

How to Avoid Mistakes

  • For SAS, ensure the angle you enter is truly the included angle between your two known sides.
  • For SSS, confirm the triangle inequality before trusting the result.
  • Stick to one unit system: degrees or radians, not both.
  • Use consistent labels: a ↔ A, b ↔ B, c ↔ C.

FAQ

Law of Cosines Calculator – Frequently Asked Questions

Answers to common questions about SSS/SAS solving, included angles, unit choices, and validity checks.

The Law of Cosines relates the sides and angles of any triangle: c² = a² + b² − 2ab·cos(C) (and similarly for the other sides/angles). It is most useful for SSS and SAS triangle cases.

Use the Law of Cosines for SSS (three sides) or SAS (two sides and the included angle). Use the Law of Sines for ASA, AAS, or SSA when you have an opposite side–angle pair.

The included angle is the angle between the two known sides. For example, if you know sides a and b, the included angle is C (the angle between a and b).

It can sometimes be used as part of a solution, but SSA is typically handled with the Law of Sines and can be ambiguous. The Law of Cosines is the standard tool for SSS and SAS.

They must satisfy the triangle inequality: a + b > c, a + c > b, and b + c > a. If not, no real triangle exists.

Choose degrees for most geometry problems and radians for calculus/physics formulas. This calculator accepts either and returns angles in the same unit you select.

arccos requires inputs between −1 and 1. If rounding or impossible side/angle values push the computed cosine outside this range, the triangle is invalid or the numbers need correction.

Yes. If you have SAS inputs, it uses area = (1/2)ab·sin(C). If you have SSS inputs, it can use Heron’s formula after solving.

No. All calculations run in your browser. Inputs and results are not saved on a server.

Relabel consistently so that side a is opposite angle A, side b opposite B, and side c opposite C. The formulas depend on the matching opposite pairs.

Results are for education and planning. Verify triangle labeling, unit selection, and measurement accuracy. If your sides fail the triangle inequality or your inputs are inconsistent, no real triangle exists.