Geometry Lab formula guide

Law of cosines (cosine rule)

The law of cosines relates all three sides of a triangle to one of its angles: c² = a² + b² − 2ab cos C, where angle C is opposite side c. Use it to find the third side when you know two sides and the angle between them (SAS), or any angle when you know all three sides (SSS).

c² = a² + b² − 2ab cos C
Every version of the formula
Use it toFormula
Find side aa² = b² + c² − 2bc cos A
Find side bb² = a² + c² − 2ac cos B
Find side cc² = a² + b² − 2ab cos C
Find angle Acos A = (b² + c² − a²) / (2bc)
Find angle Ccos C = (a² + b² − c²) / (2ab)

What each letter means

a, b, c
The three side lengths, all in the same unit
A, B, C
The angles opposite sides a, b, and c
C
In c² = a² + b² − 2ab cos C, the angle between sides a and b (the included angle)
Try it with your own numbers

Law of cosines (cosine rule) calculator

The solver opens in SAS mode. Choose “Three sides (SSS)” to find every angle with the cosine rule.

Your triangle RIGHT TRIANGLEDrawn to scale
Lowercase letters = sides · uppercase letters = opposite angles

What do you know?

Each side must be shorter than the other two combined.

Follow the calculation

The idea

Use the cosine rule when you know two sides and the included angle, or when you know all three sides and want to find the angles. Side c is opposite angle C. The other two versions follow by rotating the labels.

When to use it

  • Two sides and the included angle (SAS): find the third side.
  • All three sides (SSS): find any angle, starting with the largest.
  • Not for two angles and a side (AAS or ASA): use the law of sines instead.
  • Right triangles: with C = 90°, cos C = 0 and the formula becomes a² + b² = c².

Worked examples

1Find a missing side (SAS)

  1. Known: a = 5, b = 8, and the included angle C = 60°.
  2. c² = 5² + 8² − 2 × 5 × 8 × cos 60°.
  3. c² = 25 + 64 − 80 × 0.5 = 89 − 40 = 49.
  4. c = √49 = 7.

Answer: c = 7 units.

2Find an angle from three sides (SSS)

  1. Known: a = 7, b = 8, c = 9. Find angle C, opposite the longest side.
  2. cos C = (a² + b² − c²) / (2ab) = (49 + 64 − 81) / (2 × 7 × 8) = 32 / 112 ≈ 0.2857.
  3. C = arccos(0.2857) ≈ 73.40°.
  4. Repeat with the other versions: A ≈ 48.19° and B ≈ 58.41°. The three angles total 180°.

Answer: C ≈ 73.40°, A ≈ 48.19°, B ≈ 58.41°.

3Spot an obtuse angle

  1. Known: a = 4, b = 6, c = 9.
  2. cos C = (16 + 36 − 81) / (2 × 4 × 6) = −29 / 48 ≈ −0.6042.
  3. A negative cosine means the angle is greater than 90°.
  4. C = arccos(−0.6042) ≈ 127.17°.

Answer: C ≈ 127.17°, so the triangle is obtuse.

Why the law of cosines works

  1. Place vertex C at the origin and side a along the x-axis, so B = (a, 0).
  2. Vertex A is b units from C at angle C, so A = (b cos C, b sin C).
  3. Use the distance formula for side c: c² = (b cos C − a)² + (b sin C)².
  4. Expand: c² = b² cos² C − 2ab cos C + a² + b² sin² C.
  5. Because sin² C + cos² C = 1, this simplifies to c² = a² + b² − 2ab cos C.

Common mistakes

  • Using an angle that is not between the two known sides. That is the SSA case, which can have two answers.
  • Leaving the calculator in radian mode while entering degrees.
  • Subtracting before multiplying: work out 2ab cos C first, then subtract it from a² + b².
  • An arccos input outside −1 to 1 means the three sides cannot form a triangle.

Make the formula move.

Open the full tool for a larger workspace.

Explore the cosine rule ↗
A little question. A clearer picture.

Law of cosines (cosine rule): common questions

Wondering about the why? Start here.

When do you use the law of cosines instead of the law of sines?

Use the law of cosines for SAS (two sides and the angle between them) and SSS (three sides). Use the law of sines when you know a side and its opposite angle, as in AAS, ASA, or SSA.

Read the law of sines
How do you find an angle with the law of cosines?

Rearrange it: cos C = (a² + b² − c²)/(2ab), then take the inverse cosine. For sides 7, 8, and 9, the angle opposite 9 is arccos(32/112) ≈ 73.40°. Find the largest angle first; its cosine shows whether the triangle is obtuse.

Solve an SSS triangle
Is the law of cosines the same as the cosine rule?

Yes. “Law of cosines” is common in the United States and “cosine rule” in the United Kingdom and elsewhere. Both name c² = a² + b² − 2ab cos C.

How is the law of cosines related to the Pythagorean theorem?

When the angle C is 90°, cos C = 0, so the 2ab cos C term disappears and the formula becomes c² = a² + b². The extra term corrects for angles that are not right angles.

Review the Pythagorean theorem