Understanding the Law of Cosines

The law of cosines states a fundamental relationship in triangle geometry: when you know two sides of a triangle and the angle sandwiched between them, the third side follows a specific mathematical pattern. Unlike the Pythagorean theorem, which only applies to right triangles, the law of cosines works for any triangle—acute, obtuse, or right-angled.

At its core, the law of cosines is an extension of the Pythagorean theorem. For a right triangle where one angle is exactly 90°, the cosine of that angle equals zero, and the law of cosines collapses into the familiar a² = b² + c². For non-right triangles, the cosine term accounts for how the angle's size affects the relationship between the sides.

This makes the law of cosines invaluable whenever you encounter a triangle problem where:

  • You have two sides and need to find the third (SAS: side-angle-side)
  • You have all three sides and need the angles (SSS: side-side-side)
  • You know two sides and an angle opposite one of them (SSA: side-side-angle)

Law of Cosines Formulas

Three equivalent forms express the law of cosines, each solving for a different side or angle:

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

b² = a² + c² − 2ac × cos(β)

a² = b² + c² − 2bc × cos(α)

To find angles when all three sides are known, rearrange to solve for cosine:

cos(α) = (b² + c² − a²) ÷ (2bc)

cos(β) = (a² + c² − b²) ÷ (2ac)

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

  • a, b, c — The three sides of the triangle
  • α, β, γ — The angles opposite to sides a, b, and c respectively
  • cos(α), cos(β), cos(γ) — The cosine values of each angle

Solving Triangles: Side-Angle-Side (SAS)

When you know two sides and the angle between them, finding the third side is straightforward. Suppose you have sides a = 5 and b = 6, with the included angle γ = 30°. Plug these into the formula:

c² = 5² + 6² − 2(5)(6) × cos(30°)

c² = 25 + 36 − 60 × 0.866

c² ≈ 9.04

c ≈ 3.01

The key is ensuring you use the included angle—the one between your two known sides. Using an opposite angle will give you incorrect results. Always label your triangle carefully before substituting numbers into the formula.

Solving Triangles: All Sides Known (SSS)

Finding angles when you have all three sides requires the inverse cosine function. With sides a = 4, b = 5, and c = 6, you can find angle α:

cos(α) = (5² + 6² − 4²) ÷ (2 × 5 × 6)

cos(α) = (25 + 36 − 16) ÷ 60

cos(α) = 45 ÷ 60 = 0.75

α = arccos(0.75) ≈ 41.41°

Repeat this process for the other two angles. The sum of all angles in any triangle must equal 180°, which provides a useful check on your calculations. If your three angles don't sum to 180°, you've made an arithmetic error.

Common Pitfalls and Practical Tips

Avoid these frequent mistakes when applying the law of cosines:

  1. Mixing up angle positions — The angle in SAS must be between the two known sides. If you accidentally use an angle opposite one of your known sides, you'll solve the wrong problem. Always sketch your triangle and label clearly before substituting into the formula.
  2. Forgetting units or precision loss — Carry sufficient decimal places through intermediate steps; rounding too early introduces error. If your original measurements have units (metres, feet, etc.), propagate those units through and state them in your final answer.
  3. Inverse cosine domain issues — When solving for angles using arccos, ensure your intermediate value stays between −1 and 1. Values outside this range indicate either an arithmetic mistake or that the three sides cannot form a valid triangle (triangle inequality violated).
  4. Right triangle shortcuts — If you suspect one angle is 90°, verify using the law of cosines before defaulting to the Pythagorean theorem. While both methods work for right triangles, the law of cosines provides a unified approach for all triangle types, reducing the need to check special cases.

Frequently Asked Questions

How does the law of cosines differ from the Pythagorean theorem?

The law of cosines is a generalized form that works for any triangle; the Pythagorean theorem applies only to right triangles. When a triangle has a 90° angle, the cosine of that angle is zero, and the law of cosines simplifies to the Pythagorean formula. Conversely, you cannot use the Pythagorean theorem on non-right triangles—the law of cosines handles all cases.

What do I need to know to use the law of cosines?

You need either: (1) two sides and the angle between them (SAS), or (2) all three sides (SSS), or (3) two sides and an angle opposite one of them (SSA). In SAS mode, you find the missing side. In SSS mode, you find the missing angles. SSA is the trickiest case and sometimes yields two solutions or no solution at all.

Can the law of cosines find an angle if I know two sides and an angle opposite one of them?

Yes, but this is the ambiguous SSA case. You know two sides and an angle opposite one of them, and you can use the law of cosines to find a second angle. However, depending on the configuration, there might be zero, one, or two valid triangles satisfying those constraints. Always verify that your calculated sides and angles form a consistent triangle.

Why does the law of cosines reduce to the Pythagorean theorem for right triangles?

When one angle is exactly 90°, cos(90°) = 0. The term <code>−2ab × cos(90°)</code> vanishes, leaving <code>c² = a² + b²</code>. This is the Pythagorean theorem. The law of cosines generalizes the Pythagorean relation by accounting for how any angle (not just 90°) affects the relationship between the sides.

What are real-world applications of the law of cosines?

Surveyors use it to find distances across rivers or valleys when direct measurement is impossible. Navigation relies on it to calculate course corrections. Engineers apply it to analyse forces in non-orthogonal structures. Astronomy uses it to determine distances to stars using triangulation. Anywhere three-sided geometry arises without a right angle, the law of cosines is the natural tool.

How do I ensure my triangle is valid?

The triangle inequality states that the sum of any two sides must exceed the third side. Additionally, all angles must be positive and sum to 180°. If you calculate an angle greater than 180° or less than 0°, or if the sides violate the inequality, your input data do not form a valid triangle. Check for arithmetic errors or measurement mistakes in your original values.

More math calculators (see all)