Was this calculator helpful?
Sources & Formula Verification
What Is the Law of Cosines and When Do You Use It
You're staring at a triangle that doesn't have a right angle. The Pythagorean theorem doesn't work anymore. You know three sides but need an angle, or you know two sides and the angle between them but need the third side. That's exactly when the law of cosines becomes your tool.
The Two Cases Where Law of Cosines Works
SSS Case (Side-Side-Side): You know all three sides a, b, and c. You need to find the angles. Use the rearranged formula: cos(C) = (a² + b² - c²) / (2ab). Calculate that value, then take the inverse cosine to get angle C. Repeat for the other two angles.
Real example: sides are 5, 7, and 9. To find angle C (opposite side 9): cos(C) = (5² + 7² - 9²) / (2×5×7) = (25 + 49 - 81) / 70 = -7/70 = -0.1. Then C = arccos(-0.1) = 95.74°. That's an obtuse angle, which you can't solve with Pythagorean theorem.
SAS Case (Side-Angle-Side): You know two sides and the angle between them. You need the third side. Use c² = a² + b² - 2ab·cos(C) directly. If sides a = 5 and b = 7 with included angle C = 60°, then c² = 25 + 49 - 2(5)(7)·cos(60°) = 74 - 70(0.5) = 74 - 35 = 39. So c = √39 = 6.24.
Why Not Use Law of Sines Instead
Law of sines relates sides to their opposite angles. It works great when you know two angles and a side (ASA or AAS cases). But when you only know sides and no angles (SSS), or two sides and the included angle (SAS), law of sines doesn't give you a starting point. Law of cosines handles these cases because it relates sides to one angle directly without needing to know other angles first.
Another reason: law of sines can have ambiguous cases (the SSA scenario can produce two valid triangles). Law of cosines for SSS and SAS always produces one unique solution.
When You Actually Shouldn't Use Law of Cosines
Don't reach for it when you have a right triangle and know the legs. The Pythagorean theorem is faster: a² + b² = c². Don't use it when you know two angles — just subtract from 180° to get the third angle. And don't use it when you have an ASA or AAS case where law of sines is simpler. Law of cosines is specifically the tool for SSS and SAS scenarios.
How to Use Law of Cosines Step by Step
Solving an SSS Triangle (All Three Sides Known)
You have sides a = 8, b = 6, c = 10. Here's how to find all three angles:
- Pick one angle to find first. Start with the largest angle (opposite the longest side). Here that's angle C opposite side 10.
- Rearrange the law of cosines: cos(C) = (a² + b² - c²) / (2ab)
- Plug in the numbers: cos(C) = (8² + 6² - 10²) / (2×8×6) = (64 + 36 - 100) / 96 = 0 / 96 = 0
- Take inverse cosine: C = arccos(0) = 90°. This is a right triangle.
- Find the second angle the same way or use law of sines (which is now easier).
- Find the third angle by subtracting: 180° - 90° - (other angle).
Solving a SAS Triangle (Two Sides and Included Angle)
You have sides a = 5, b = 7, and included angle C = 45°. Find side c:
- Use the direct formula: c² = a² + b² - 2ab·cos(C)
- Plug in: c² = 5² + 7² - 2(5)(7)·cos(45°) = 25 + 49 - 70(0.707) = 74 - 49.5 = 24.5
- Square root: c = √24.5 = 4.95
- Now find the other angles using law of cosines again or switch to law of sines.
Triangle Validity Check — The Triangle Inequality Theorem
Before you calculate anything, verify the triangle is actually possible. The sum of any two sides must be greater than the third side. For sides 5, 7, and 9: 5 + 7 = 12 > 9 ✓, 5 + 9 = 14 > 7 ✓, 7 + 9 = 16 > 5 ✓. Valid triangle.
If you enter sides 2, 3, and 10, the triangle is impossible: 2 + 3 = 5 which is NOT greater than 10. The calculator will warn you before attempting to solve.
Real-World Applications of Law of Cosines
Navigation and GPS Calculations
A ship travels 40 nautical miles east, then changes course 60 degrees to the right and travels 50 nautical miles. How far is it from the starting point? This is an SAS triangle: sides 40 and 50 with included angle 120° (180° - 60° direction change). Using c² = 40² + 50² - 2(40)(50)·cos(120°), we get c = √(1600 + 2500 + 2000) = √6100 = 78.1 nautical miles. That's the straight-line distance home.
Surveying Inaccessible Distances
A surveyor can't measure directly across a lake. They measure 200 meters along the shore to point A, then 150 meters to point B, with a 75° angle at their position. The distance across the lake is found using law of cosines: d² = 200² + 150² - 2(200)(150)·cos(75°) = 40000 + 22500 - 15529 = 46971, so d = 217 meters.
Engineering Structural Analysis
Triangular trusses in bridges and roofs often aren't right triangles. Engineers use law of cosines to calculate forces and load distribution across non-right triangular frameworks. A roof truss with two rafters meeting at a non-90° angle requires law of cosines to determine the third member length and stress angles.
| Method | When to Use | What You Need |
|---|---|---|
| Pythagorean Theorem | Right triangles only | Two legs or one leg + hypotenuse |
| Law of Cosines | SSS or SAS cases | 3 sides OR 2 sides + included angle |
| Law of Sines | ASA or AAS cases | 2 angles + 1 side |