Mathwords logoReference LibraryMathwords

Law of Cosines

Law of Cosines

An equation relating the cosine of an interior angle and the lengths of the sides of a triangle.

Note: The Pythagorean theorem is a corollary of the law of cosines.

 

Triangle ABC with sides a, b, c opposite to angles A, B, C, and three formula versions: c²=a²+b²−2ab·cosC, b²=a²+c²−2ac·cosB,...

 

 

See also

Law of sines

Key Formula

c2=a2+b22abcos(C)c^2 = a^2 + b^2 - 2ab\cos(C)
Where:
  • aa = Length of one side of the triangle
  • bb = Length of another side of the triangle
  • cc = Length of the side opposite angle C
  • CC = The interior angle between sides a and b

Worked Example

Problem: In triangle ABC, side a = 5, side b = 7, and the included angle C = 60°. Find the length of side c.
Step 1: Write down the Law of Cosines with the known values substituted in.
c2=52+722(5)(7)cos(60°)c^2 = 5^2 + 7^2 - 2(5)(7)\cos(60°)
Step 2: Compute the squares and the product. Recall that cos(60°) = 0.5.
c2=25+492(5)(7)(0.5)c^2 = 25 + 49 - 2(5)(7)(0.5)
Step 3: Simplify the right-hand side. The product 2 × 5 × 7 × 0.5 equals 35.
c2=7435=39c^2 = 74 - 35 = 39
Step 4: Take the square root to find c.
c=396.24c = \sqrt{39} \approx 6.24
Answer: Side c ≈ 6.24 units.

Another Example

This example uses the Law of Cosines in reverse—finding an unknown angle instead of an unknown side. It also illustrates the connection to the Pythagorean theorem: when the angle is 90°, the cosine term vanishes and the formula reduces to a² + b² = c².

Problem: A triangle has sides a = 8, b = 6, and c = 10. Find angle C (the angle opposite the side of length 10).
Step 1: Start with the Law of Cosines and solve for cos(C).
c2=a2+b22abcos(C)    cos(C)=a2+b2c22abc^2 = a^2 + b^2 - 2ab\cos(C) \implies \cos(C) = \frac{a^2 + b^2 - c^2}{2ab}
Step 2: Substitute the known side lengths.
cos(C)=82+621022(8)(6)=64+3610096\cos(C) = \frac{8^2 + 6^2 - 10^2}{2(8)(6)} = \frac{64 + 36 - 100}{96}
Step 3: Simplify the numerator and the fraction.
cos(C)=096=0\cos(C) = \frac{0}{96} = 0
Step 4: Find the angle whose cosine is 0.
C=cos1(0)=90°C = \cos^{-1}(0) = 90°
Answer: Angle C = 90°. This confirms the triangle is a right triangle (since 6² + 8² = 10²).

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 included angle (SAS) or all three sides (SSS). The Law of Sines is better suited for situations where you know two angles and a side (AAS or ASA) or two sides and a non-included angle (SSA). If you try to use the Law of Sines in an SAS or SSS case, you won't have enough information to set up the proportion.
How is the Law of Cosines related to the Pythagorean theorem?
The Pythagorean theorem is a special case of the Law of Cosines. When angle C equals 90°, cos(90°) = 0, so the term −2ab cos(C) disappears entirely. The formula then simplifies to c² = a² + b², which is exactly the Pythagorean theorem. This is why the Pythagorean theorem is called a corollary of the Law of Cosines.
Can the Law of Cosines give a negative value for cos(C)?
Yes. If the angle C is obtuse (greater than 90°), then cos(C) is negative. This makes the −2ab cos(C) term positive, which increases c². A negative cosine value simply means the angle opposite that side is obtuse, and the formula handles it correctly without any special adjustments.

Law of Cosines vs. Law of Sines

Law of CosinesLaw of Sines
Formulac² = a² + b² − 2ab cos(C)a/sin(A) = b/sin(B) = c/sin(C)
Use when you knowTwo sides and the included angle (SAS), or all three sides (SSS)Two angles and a side (AAS/ASA), or two sides and a non-included angle (SSA)
What it findsA missing side or any angleA missing side or a missing angle
Ambiguous case?No — always gives a unique answerYes — the SSA case can produce 0, 1, or 2 valid triangles
Special case connectionReduces to the Pythagorean theorem when the angle is 90°No direct connection to the Pythagorean theorem

Why It Matters

The Law of Cosines appears throughout trigonometry, precalculus, and physics courses whenever you need to solve oblique (non-right) triangles. It is essential in navigation, surveying, and engineering for calculating distances and angles that cannot be measured directly. Many standardized tests—including the SAT and ACT—include problems that require the Law of Cosines, especially in SAS and SSS triangle scenarios.

Common Mistakes

Mistake: Placing the cosine term on the wrong angle. For example, writing c² = a² + b² − 2ab cos(A) instead of cos(C).
Correction: The angle inside the cosine must always be the angle opposite the side you are solving for (or the side on the left of the equation). Side c is opposite angle C, side a is opposite angle A, and so on.
Mistake: Forgetting to subtract the 2ab cos(C) term — accidentally adding it instead.
Correction: The formula has a minus sign: c² = a² + b² − 2ab cos(C). If the angle is obtuse, cos(C) is already negative, and the double negative will increase c² automatically. Do not change the sign yourself.

Related Terms