law of cosines calculator

Triangle Law of Cosines Calculator

Use this tool to solve triangles with the Law of Cosines. Choose whether you want to find a missing side (SAS case) or a missing angle (SSS case).

Angle must be greater than 0° and less than 180°.

What is the Law of Cosines?

The Law of Cosines is a trigonometry formula used to solve triangles when you know either:

  • Two sides and the included angle (SAS), or
  • All three sides (SSS).

It extends the Pythagorean theorem to any triangle, not just right triangles.

Main formulas

To find side c when sides a, b, and included angle C are known:

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

To find angle C when sides a, b, and c are known:

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

How to use this calculator

Mode 1: Find a missing side

  • Select Find side c.
  • Enter side a, side b, and angle C in degrees.
  • Click Calculate.

Mode 2: Find a missing angle

  • Select Find angle C.
  • Enter sides a, b, and c.
  • Click Calculate.

The calculator also returns extra values such as perimeter, area, and the remaining angles when possible.

Worked examples

Example 1 (SAS)

If a = 7, b = 10, and C = 40°, then:

c² = 7² + 10² − 2(7)(10)cos(40°)

c ≈ 6.49

Example 2 (SSS)

If a = 8, b = 9, and c = 12, then:

cos(C) = (8² + 9² − 12²)/(2·8·9) = 1/144

C ≈ 89.60°

Common mistakes to avoid

  • Using degrees when your calculator is in radians (or vice versa).
  • Entering a non-included angle for the SAS version of the formula.
  • Ignoring triangle inequality in SSS problems.
  • Rounding too early and carrying errors through later steps.

Where this is used in real life

The Law of Cosines appears in navigation, surveying, architecture, engineering, robotics, and computer graphics. Any time you need distance or angle data in non-right triangles, this formula is a core tool.

Quick FAQ

Is this different from the Pythagorean theorem?

Yes. The Pythagorean theorem works only for right triangles. The Law of Cosines works for all triangles and reduces to the Pythagorean theorem when C = 90°.

Can I find all angles of a triangle with this?

Yes. Once enough side/angle data is known, the remaining angles can be computed using the Law of Cosines again.

What units should I use for sides?

Any consistent unit is fine: meters, feet, inches, etc. The output side and perimeter use the same unit you input.

🔗 Related Calculators