Law of Cosines Formula

GEOMETRY

Law of cosines formula

The law of cosines finds a missing side or angle in any triangle, not just right triangles. It generalizes the Pythagorean theorem by adding a term that corrects for the angle between two sides.

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

What each symbol means

Symbol Meaning Units
a, b Two known sides any length unit
c Side opposite angle C same unit
C Angle between sides a and b degrees

Rearranged forms

Solve for side c: c = √(a² + b² − 2ab·cos C)
Solve for angle C: C = cos⁻¹[(a² + b² − c²) / (2ab)]

Worked example

Two sides measure 5 and 7 with a 60° angle between them. Find the third side.

  1. Start from c² = a² + b² − 2ab·cos C.
  2. Substitute a = 5, b = 7, C = 60° (cos 60° = 0.5).
  3. Compute: c² = 25 + 49 − 2·5·7·0.5.
  4. Simplify: c² = 74 − 35 = 39.
  5. Square root: c = √39.
c ≈ 6.24

Sides share one length unit; the angle is the one between the two known sides. When C = 90°, cos C = 0 and the formula collapses to the Pythagorean theorem. Use the law of sines instead when you already have an angle and its opposite side.

Have two sides and the included angle?

Enter your sides and angle and the Law of Cosines Calculator solves for the remaining side or angle.

How the law of cosines works

In a right triangle the Pythagorean theorem holds exactly. When the angle between two sides is not 90 degrees, the law of cosines subtracts 2ab times the cosine of that angle to correct for it. A wider angle stretches the opposite side; a narrower one shortens it.

Where it is used

It solves triangles in surveying, navigation, engineering, and physics whenever you know two sides and the included angle, or all three sides. It is the go-to tool for non-right triangles alongside the law of sines.

FAQ

When do I use the law of cosines?

When you know two sides and the angle between them to find the third side, or all three sides to find an angle. It works for any triangle.

How is it related to the Pythagorean theorem?

It is a generalization. When the included angle is 90°, its cosine is zero and the formula reduces to c² = a² + b².

Can it find an angle?

Yes. Rearranged, C = cos⁻¹[(a² + b² − c²) / (2ab)], which gives the angle from all three sides.

Spotted an error or have a suggestion for this calculator? Let us know →
Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.