Law of Cosines

Definitionnoun phrase

What is the law of cosines?

The law of cosines relates the three sides of any triangle to one of its angles: c2 = a2 + b2 − 2ab cos C, where C is the angle across from side c. Use it to find the third side when you know two sides and the angle between them, or to find an angle when you know all three sides.

In Spanish
ley de cosenos
Also called
cosine rule, cosine law, law of cosines formula
Grade level
Precalculus
GeometryAlgebra 2PrecalculusCCSS HSG-SRT.D.10CCSS HSG-SRT.D.11SATACTACCUPLACER

Law of Cosines in a picture

The law of cosinesA triangle with sides a and b in blue meeting at angle C in green, and side c in orange across from C. The law of cosines: c squared equals a squared plus b squared minus 2ab cos C. When C is 90 degrees, cos C is 0 and the formula becomes the Pythagorean theorem.Cabcknow a, b and the angle C between them (SAS)c² = a² + b² − 2ab cos Cif C = 90°, cos C = 0 and this is a² + b² = c²C > 90°: cos C < 0, so c is longer than in a right triangle
The law of cosines is the Pythagorean theorem with a correction for the angle. At 90° the correction is 0.

Formal definition and notation

In a triangle with sides a, b, c opposite angles A, B, C: a2 = b2 + c2 − 2bc cos A, b2 = a2 + c2 − 2ac cos B and c2 = a2 + b2 − 2ab cos C. Solved for an angle, cos C = a2 + b2 − c22ab. When C = 90°, cos C = 0 and the law reduces to the Pythagorean theorem, so it generalizes that theorem to all triangles. It solves the SAS and SSS cases, where the law of sines cannot start.

Symbol Read it as Meaning
c2 c squared the square of the side across from angle C
cos C cosine of C the cosine of the angle between sides a and b
SAS, SSS side-angle-side, side-side-side the two cases the law of cosines solves directly

Key facts

  • It is the Pythagorean theorem plus a correction term, −2ab cos C.
  • If C is obtuse, cos C is negative, so c2 is larger than a2 + b2.
  • If C is acute, cos C is positive, so c2 is smaller than a2 + b2.
  • Finding an angle with cos−1 never has an ambiguous case, because cosine is different for every angle from 0° to 180°.
  • In SSS, find the largest angle first (across from the longest side); then the law of sines can finish the job.
  • The angle in the formula must be the one between the two sides you square.

Law of cosines

Law of cosines
c2 = a2 + b2 − 2ab cos C
a,b
the two sides that form angle C
C
the angle between them
c
the side across from C

For an angle from three sides: cos C = a2 + b2 − c22ab, then C = cos−1(…).

Law of Cosines examples, step by step

Example 1: Two sides and the included angle

Warm-up

In triangle ABC, a = 7, b = 9 and C = 60°. Find c to the nearest hundredth.

  1. c2 = 72 + 92 − 2(7)(9)cos 60°.
  2. cos 60° = 0.5, so c2 = 49 + 81 − 63 = 67.
  3. c = √67 ≈ 8.19.

Answer: c = √67 ≈ 8.19.

Example 2: Three sides: find the largest angle

Core

A triangle has sides 5, 7 and 9. Find its largest angle to the nearest tenth of a degree.

  1. The largest angle is across from the longest side, 9. Call it C.
  2. cos C = 52 + 72 − 922(5)(7), which is 25 + 49 − 8170 = −770 = −0.1.
  3. C = cos−1(−0.1) ≈ 95.7°. The negative cosine shows the angle is obtuse.

Answer: The largest angle is about 95.7 degrees.

Example 3: Two ships

Test-style

Two ships leave the same port. One sails 30 miles and the other 40 miles, and the angle between their paths is 110°. How far apart are they, to the nearest tenth of a mile?

  1. The paths are two sides with the 110° angle between them (SAS).
  2. d2 = 302 + 402 − 2(30)(40)cos 110°, so d2 = 2500 − 2400 cos 110°.
  3. cos 110° ≈ −0.3420, so d2 ≈ 2500 + 820.8 = 3320.8.
  4. d ≈ √3320.8 ≈ 57.6.

Answer: The ships are about 57.6 miles apart.

Common mistakes

✗ MistakeUsing an angle that is not between the two sides: with a = 7, b = 9, plugging in angle A.
✓ InsteadUse the angle formed by a and b, which is C: c2 = a2 + b2 − 2ab cos C.

The formula needs the included angle, the one across from the side you are finding.

✗ MistakeSubtracting before multiplying: c2 = (49 + 81 − 126) cos 60° = 2.
✓ InsteadMultiply 2ab cos C first: c2 = 130 − 126(0.5) = 67.

Order of operations: the product 2ab cos C is one term to subtract.

✗ MistakeForgetting the square root: c = 67.
✓ InsteadThe formula gives c2 = 67, so c = √67 ≈ 8.19.

Like the Pythagorean theorem, the law of cosines gives the square of the side.

Not to be confused with

Law of Cosinesvs.Law of sines

The law of sines needs a known angle and its opposite side. The law of cosines works from SAS or SSS, when no such pair is known.

Law of Cosinesvs.Pythagorean theorem

a2 + b2 = c2 holds only for right triangles. The law of cosines works for all triangles and becomes the Pythagorean theorem when C = 90°.

Quick check: 3 questions

Question 1 of 3

Which facts call for the law of cosines?

Show answer and explanation

Answer: C. SAS (and SSS) have no known angle-side pair, so the law of cosines is needed. The first two cases suit the law of sines, and a right triangle only needs SOH CAH TOA.

Question 2 of 3

In a triangle, a = 3, b = 5 and C = 120°. What is c?

Show answer and explanation

Answer: B. c2 = 9 + 25 − 2(3)(5)cos 120°, which is 34 − 30(−0.5) = 49, so c = 7. √19 uses cos 120° = +0.5, √34 ignores the angle, and 8 just adds the sides.

Question 3 of 3

If C = 90°, what does c2 = a2 + b2 − 2ab cos C become?

Show answer and explanation

Answer: D. cos 90° = 0, so the last term disappears and you get the Pythagorean theorem. The first choice uses cos 90° = 1, and the others drop the squares or change the sign.

Law of Cosines: frequently asked questions

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

Use the law of cosines when you know two sides and the angle between them (SAS) or all three sides (SSS). In those cases no angle is paired with its opposite side, so the law of sines has too many unknowns. After one use of the law of cosines, the law of sines can often finish the triangle.

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

It extends it. In c2 = a2 + b2 − 2ab cos C, the extra term corrects for the angle. When C = 90°, cos C = 0, the term vanishes, and you get c2 = a2 + b2. For an obtuse angle the term adds length; for an acute angle it takes length away.

Practice and tools

Sources

  1. OpenStax, Algebra and Trigonometry 2e, 10.2 Non-right Triangles: Law of Cosines
  2. Common Core State Standards, High School Geometry, Similarity, Right Triangles and Trigonometry (HSG-SRT.D.10, HSG-SRT.D.11)

Updated November 2026·Reviewed by the Effortless Math team·Standards: CCSS HSG-SRT.D.10, CCSS HSG-SRT.D.11

Cite this entry

Effortless Math Team. “Law of Cosines.” Effortless Math Dictionary. Updated November 2026. https://www.effortlessmath.com/math-dictionary/law-of-cosines/

Flashcard

TermLaw of Cosinesc2 = a2 + b2 − 2ab cos C
DefinitionFinds a side from SAS or an angle from SSS in any triangle. a = 3, b = 5, C = 120°: c2 = 34 + 15 = 49, so c = 7.
Study the full deck

Browse all terms in the Math Dictionary · More trigonometry terms · Random term