The Law of Cosines
The Law of Cosines (also called the Cosine Rule) is a powerful formula that relates the sides and angles of any triangle. It generalizes the Pythagorean Theorem to all triangles — not just right triangles — making it essential for solving triangles when the Law of Sines cannot be applied.
This guide covers the formula and all three variations, its connection to the Pythagorean Theorem, when to use it (SAS and SSS), step-by-step methods for finding sides and angles, five fully worked examples, real-world applications, and a practice quiz.
1Introduction
You already know the Pythagorean Theorem: a² + b² = c². But this only works when angle C is exactly 90°. What happens when the triangle doesn’t have a right angle? The Law of Cosines extends the Pythagorean Theorem by adding a correction term that accounts for the actual angle.
Together with the Law of Sines, the Law of Cosines gives you the tools to solve any triangle. While the Law of Sines handles AAS, ASA, and SSA cases, the Law of Cosines handles the remaining two: SAS (two sides and the included angle) and SSS (all three sides known).
Imagine two hikers leave the same campsite. One walks 5 km northeast, the other walks 8 km east. If the angle between their paths is 40°, how far apart are they? You know two sides and the angle between them (SAS) — the Law of Cosines gives you the answer directly.
The Law of Cosines is used in GPS technology, structural engineering, computer graphics, robotics, and physics. Any time you need to find a distance or angle in a non-right triangle where you know two sides and the included angle (or all three sides), this is the tool to use.
2Key Definitions
SAS (Side-Angle-Side)
Two sides and the included angle (the angle between the two known sides) are given. Always yields exactly one triangle.
SSS (Side-Side-Side)
All three side lengths are known. Used to find all three angles. Yields one triangle if the triangle inequality holds.
Included Angle
The angle formed between two known sides. In SAS, this is the angle “sandwiched” between the two given sides.
Opposite Side & Angle
Side a is opposite angle A, side b is opposite angle B, side c is opposite angle C.
Acute Triangle
All three angles are less than 90°. All cosine values for the angles are positive.
Obtuse Triangle
One angle is greater than 90°. The cosine of the obtuse angle is negative.
Inverse Cosine (arccos)
The function cos¹(x) that returns the angle whose cosine is x. Used to find angles in SSS problems.
Triangle Inequality
The sum of any two sides must be greater than the third side. If violated, no triangle exists.
3The Formula
The Law of Cosines has three equivalent forms, one for each side of the triangle. Each form relates one side to the other two sides and the angle opposite to the side being calculated.
Law of Cosines — Three Forms
a² = b² + c² − 2bc · cos(A)
b² = a² + c² − 2ac · cos(B)
c² = a² + b² − 2ab · cos(C)
Rearranged for Finding Angles
cos(A) = (b² + c² − a²) / (2bc)
cos(B) = (a² + c² − b²) / (2ac)
cos(C) = (a² + b² − c²) / (2ab)
Interactive Law of Cosines Explorer
Side c
7.21
Angle A
73.9°
Angle B
46.1°
Adjust the sliders to change the known values. The triangle and computed results update in real time.
Notice the pattern: the side being found (or isolated) always appears alone on the left, and the angle in the cosine term is always the angle opposite that side.
Each formula follows the same structure: (side)² = (other side)² + (other side)² − 2(other side)(other side) · cos(opposite angle). The two “other sides” and the angle always go together.
4Relationship to the Pythagorean Theorem
The Pythagorean Theorem is a special case of the Law of Cosines. Watch what happens when angle C equals 90°:
Start with: c² = a² + b² − 2ab · cos(C)
Substitute C = 90°: c² = a² + b² − 2ab · cos(90°)
Since cos(90°) = 0: c² = a² + b² − 2ab · 0
Result: c² = a² + b² ← the Pythagorean Theorem!
This connection is beautiful: the term −2ab·cos(C) is a “correction factor” that adjusts the Pythagorean Theorem for non-right triangles:
When C < 90° (acute angle)
cos(C) is positive, so −2ab·cos(C) is negative. This means c² < a² + b². The side opposite an acute angle is shorter than what the Pythagorean Theorem would predict.
When C = 90° (right angle)
cos(90°) = 0, so the correction term vanishes. We get the Pythagorean Theorem exactly.
When C > 90° (obtuse angle)
cos(C) is negative, so −2ab·cos(C) becomes positive. This means c² > a² + b². The side opposite an obtuse angle is longer than what the Pythagorean Theorem would predict.
5When to Use the Law of Cosines
The Law of Cosines is your go-to formula in two specific scenarios:
SAS (Side-Angle-Side) — Finding the Third Side
You know two sides and the included angle (the angle between them).
Strategy: Plug directly into the formula to find the missing side. Then use the Law of Sines (or Law of Cosines again) to find the remaining angles.
Always gives exactly 1 triangle. No ambiguity.
SSS (Side-Side-Side) — Finding All Angles
You know all three side lengths and need to find the angles.
Strategy: Rearrange the formula to solve for cos(A), then use arccos to find the angle. Repeat for the second angle, and find the third by subtraction.
Always gives exactly 1 triangle (assuming triangle inequality holds).
If you have AAS, ASA, or SSA, use the Law of Sines instead. The Law of Cosines is best when no complete side–angle pair is available, which happens with SAS and SSS.
6Finding Sides (SAS)
When you have two sides and the included angle, follow these steps to find the missing side:
Step 1: Identify the two known sides (say b and c) and the included angle (A).
Step 2: Write the formula: a² = b² + c² − 2bc · cos(A)
Step 3: Substitute the known values.
Step 4: Calculate the right side to get a².
Step 5: Take the square root to find a.
Make sure the angle is the included angle — the one between the two known sides. If the angle is not between the sides, you have SSA (not SAS), and should use the Law of Sines instead.
7Finding Angles (SSS)
When all three sides are known, rearrange the formula to solve for the angle:
Step 1: Choose the angle to find (start with the largest — opposite the longest side).
Step 2: Rearrange: cos(A) = (b² + c² − a²) / (2bc)
Step 3: Substitute the three known side lengths.
Step 4: Calculate the value of cos(A).
Step 5: Use inverse cosine: A = cos¹(result)
Step 6: Find remaining angles using the same method or angle sum (180°).
When solving SSS, find the largest angle first (opposite the longest side). Why? Because a triangle can have at most one obtuse angle, and it must be the largest. If cos(A) is negative, the angle is obtuse. Once you know the largest angle, the other two must be acute, so you can safely use the Law of Sines for them (no ambiguity).
8Worked Examples
Problem: In triangle ABC, b = 8, c = 11, and A = 37°. Find side a.
Step 1: Identify — SAS (two sides and included angle A)
Step 2: a² = b² + c² − 2bc · cos(A)
Step 3: a² = 8² + 11² − 2(8)(11) · cos(37°)
Step 4: a² = 64 + 121 − 176 · 0.7986
Step 5: a² = 185 − 140.56 = 44.44
Step 6: a = √44.44
Answer: a ≈ 6.67
Case: SAS — exactly one triangle
Problem: Triangle ABC has a = 7, b = 10, c = 12. Find all angles.
Step 1: Find largest angle C (opposite longest side c = 12)
Step 2: cos(C) = (a² + b² − c²) / (2ab)
Step 3: cos(C) = (49 + 100 − 144) / (2 · 7 · 10)
Step 4: cos(C) = 5/140 = 0.0357
Step 5: C = cos¹(0.0357) ≈ 87.95°
Step 6: cos(A) = (b² + c² − a²) / (2bc)
Step 7: cos(A) = (100 + 144 − 49) / (240) = 195/240 = 0.8125
Step 8: A = cos¹(0.8125) ≈ 35.66°
Step 9: B = 180° − 87.95° − 35.66°
Answer: A ≈ 35.66°, B ≈ 56.39°, C ≈ 87.95°
Case: SSS — all angles found using Law of Cosines
Problem: In triangle PQR, p = 6, r = 10, and Q = 120°. Find side q.
Step 1: Identify — SAS (sides p and r with included angle Q)
Step 2: q² = p² + r² − 2pr · cos(Q)
Step 3: q² = 36 + 100 − 2(6)(10) · cos(120°)
Step 4: cos(120°) = −0.5, so −2(60)(−0.5) = +60
Step 5: q² = 136 + 60 = 196
Answer: q = √196 = 14
Key insight: Negative cosine makes the correction term positive, increasing the side length
Problem: A triangle has sides 5, 7, and 11. Is it acute, right, or obtuse? Find the largest angle.
Step 1: Largest angle is opposite longest side (11). Call it C.
Step 2: cos(C) = (5² + 7² − 11²) / (2 · 5 · 7)
Step 3: cos(C) = (25 + 49 − 121) / 70
Step 4: cos(C) = −47/70 ≈ −0.6714
Step 5: Since cos(C) < 0, angle C is obtuse
Step 6: C = cos¹(−0.6714)
Answer: C ≈ 132.2° (obtuse triangle)
Key insight: Negative cosine confirms the angle is obtuse (> 90°)
Problem: A lighthouse sees Ship A at 8 km and Ship B at 12 km. The angle between the two lines of sight is 65°. How far apart are the ships?
Step 1: This is SAS — two distances and the included angle
Step 2: Let d = distance between ships
Step 3: d² = 8² + 12² − 2(8)(12) · cos(65°)
Step 4: d² = 64 + 144 − 192 · 0.4226
Step 5: d² = 208 − 81.14 = 126.86
Step 6: d = √126.86
Answer: The ships are approximately 11.26 km apart
Case: SAS applied to a real navigation problem
9Real-World Applications
GPS & Distance Calculations
GPS systems use a spherical version of the Law of Cosines to calculate distances between points on Earth’s surface given their latitudes and longitudes.
Structural Engineering
Engineers calculate forces in truss structures where members meet at non-right angles. The Law of Cosines determines the lengths and angles in these frameworks.
Computer Graphics & Game Development
3D rendering engines use the Law of Cosines for collision detection, calculating distances between objects, and determining angles between surfaces for lighting calculations.
Robotics & Kinematics
Robot arms use the Law of Cosines in inverse kinematics to calculate the joint angles needed to reach a target position in space.
Surveying & Mapping
Surveyors use the Law of Cosines to calculate distances when measuring irregular plots of land where all three boundaries are known but no right angles exist.
10Memory Aids
Think of the formula as the Pythagorean Theorem with an extra term: a² = b² + c² − 2bc·cos(A). The “cosine kick” corrects for the angle not being 90°.
The side you’re solving for is always alone on the left: a² = ... The angle in the cosine is always the angle opposite that lonely side.
Both SAS and SSS start with “S” and have the letter “S” appearing at least twice in a row. Think: “S-heavy = CoSines.”
If cos(A) comes out negative, the angle is obtuse. Don’t panic — this is normal. Just apply arccos to the negative value.
The formula gives you a², not a. Always remember to take the square root as the final step when finding a side.
11Common Mistakes to Avoid
Using the Wrong Angle
Wrong: Using a non-included angle for SAS (e.g., using angle B when you have sides a and b)
Right: The angle in the formula must be opposite the side you’re finding. For SAS, use the included angle between the two known sides.
Forgetting the Minus Sign
Wrong: Writing a² = b² + c² + 2bc·cos(A)
Right: The formula has a minus sign: a² = b² + c² − 2bc·cos(A). The minus is essential.
Forgetting to Take the Square Root
Wrong: Reporting a² = 44.44 as the final answer
Right: The formula gives a². Always take the square root: a = √44.44 ≈ 6.67.
Sign Errors with Obtuse Angles
Wrong: Assuming cos(120°) is positive, getting a² that’s too small
Right: cos(120°) = −0.5. The double negative (−2bc × −0.5) makes the term positive, increasing a².
Calculator in Radian Mode
Wrong: cos(60) = −0.952 (calculator in radian mode)
Right: cos(60°) = 0.5. Always ensure your calculator is in DEGREE mode.
Using Law of Cosines for AAS/ASA
Wrong: Attempting to use the Law of Cosines when you have two angles and a side
Right: AAS and ASA are solved more easily with the Law of Sines. Save the Law of Cosines for SAS and SSS.
12Quick Revision Summary
- Law of Cosines: a² = b² + c² − 2bc·cos(A).
- Three equivalent forms — one for each side of the triangle.
- Use for SAS (two sides + included angle) and SSS (all three sides).
- The Pythagorean Theorem is the special case when C = 90°.
- For SSS, rearrange to cos(A) = (b² + c² − a²) / (2bc) and use arccos.
- A negative cosine value means the angle is obtuse.
- For SSS, find the largest angle first (opposite the longest side).
- Don’t forget to take the square root when finding a side.
- For AAS, ASA, or SSA, use the Law of Sines instead.
- Always check your calculator is in DEGREE mode.
- SAS and SSS always give exactly one triangle (no ambiguity).
Frequently Asked Questions
How is the Law of Cosines related to the Pythagorean Theorem?
The Pythagorean Theorem is a special case of the Law of Cosines. When C = 90°, cos(90°) = 0, so the formula simplifies to c² = a² + b².
When do I use Law of Cosines vs. Law of Sines?
Use Law of Cosines for SAS (two sides and the included angle) or SSS (all three sides). Use Law of Sines for AAS, ASA, or SSA.
What if I get a negative value for cos(A)?
A negative cosine means the angle is obtuse (between 90° and 180°). This is perfectly valid for a triangle.
Can the Law of Cosines be used for right triangles?
Yes, but the Pythagorean Theorem is simpler. The Law of Cosines reduces to it when one angle is 90°.
Practice Quiz
Test your understanding — select the correct answer for each question.
1.Which information is NOT a primary case for using the Law of Cosines?
2.Which formula correctly solves for side a?
3.If angle C = 90°, the Law of Cosines simplifies to:
4.A triangle has sides x = 5, y = 6, and included angle Z = 60°. What is z²?
5.For triangle with d = 7, e = 8, f = 13, which expression gives cos(F)?
6.If cos(A) is negative, what does this tell you about angle A?
7.Which scenario most likely requires the Law of Cosines over Law of Sines?
8.A triangle has p = 10, q = 12, angle R = 45°. What is r²?
9.After calculating cos(angle) = X, the next step to find the angle is:
10.A boat travels 8 km East, then 10 km at 70° from its path. The distance from start is:
Study Tips
- Connect it to Pythagoras — always think of the Law of Cosines as the Pythagorean Theorem with a correction factor. This builds intuition.
- Classify before solving — determine if you have SAS or SSS before starting. This tells you whether you’re finding a side or an angle.
- Watch your signs — the most common error is mishandling the minus sign, especially with obtuse angles where cos is negative.
- Practice both directions — solve SAS problems (finding sides) AND SSS problems (finding angles). Both appear on exams.
- Combine with Law of Sines — after finding one element with the Law of Cosines, you can often switch to the Law of Sines for the remaining elements.