Law of Cosines
What is the Law of Cosines?
The Law of Cosines generalizes the Pythagorean theorem to work for any triangle, not just right triangles. When angle C = 90°, cos(90°) = 0, and the formula reduces exactly to c² = a² + b² — the familiar Pythagorean theorem is just the special case where the included angle happens to be a right angle, which is a good way to see the two formulas as one continuous idea rather than two unrelated ones.
It's the go-to formula when a triangle doesn't have a right angle to exploit, and you know either two sides plus the angle between them (SAS), or all three sides (SSS, to solve for an angle instead). The extra term, −2ab·cos(C), is what accounts for the angle not being 90°: when C is less than 90°, cosine is positive and that term shrinks c relative to a straightforward Pythagorean sum; when C is greater than 90° (an obtuse triangle), cosine goes negative and the term actually adds to the total, making c longer than the Pythagorean sum would suggest.
Because it can also be rearranged to solve for an angle given all three sides, the Law of Cosines is often the first formula reached for when a real-world triangle — a plot of land, a truss in a bridge, a triangulated GPS position — doesn't include a convenient right angle.
What Each Variable Means
When to Use It
- SAS — two sides and the included angle between them are known
- SSS — all three sides are known and you need to find an angle
- Any non-right triangle where the Pythagorean theorem alone doesn't apply
Step-by-Step Example
Problem: A triangle has sides a = 5, b = 7, and included angle C = 60°. Find side c.
Start from the Law of Cosines.
c² = a² + b² − 2ab·cos(C)Plug in a, b, and C.
c² = 25 + 49 − 2(5)(7)·cos(60°)Simplify the expression.
c² = 74 − 70(0.5) = 74 − 35 = 39Interactive Calculator
Common Mistakes
Mistake: Using the Law of Cosines when the Law of Sines would be simpler.
Fix: If you have an angle-side opposite pair (like AAS or ASA), the Law of Sines is more direct. Reach for the Law of Cosines specifically for SAS or SSS.
Mistake: Forgetting to take the square root at the end when solving for a side.
Fix: The formula gives c², not c directly — the final step is always to take the square root of the result.
Practice Questions
A triangle has sides a = 8, b = 10, and included angle C = 45°. Find side c.
Hint: c² = 64 + 100 − 160·cos(45°).
A triangle has sides a = 6, b = 6, and included angle C = 90°. Find side c.
Hint: This reduces to the Pythagorean theorem since cos(90°) = 0.
Frequently Asked Questions
How does the Law of Cosines relate to the Pythagorean theorem?
When the included angle C is 90°, cos(90°) = 0, and the formula reduces exactly to c² = a² + b² — the Pythagorean theorem is a special case of the Law of Cosines.
Can it be used to find an angle instead of a side?
Yes — rearrange to cos(C) = (a² + b² − c²) / 2ab, then take the inverse cosine, useful when all three sides (SSS) are known.
Related Formulas
Pythagorean Theorem
Relates the three sides of a right triangle, letting you find any one side from the other two.
Learn more →Law of Sines
Relates the sides of any triangle to the sines of their opposite angles — not just right triangles.
Learn more →Sine, Cosine & Tangent
The three fundamental trigonometric ratios for right triangles, remembered with SOH-CAH-TOA.
Learn more →