... LIVE
🔢 Select Triangle Case
📏 Enter All Three Sides
📏 Enter 2 Sides and Included Angle
Missing Side
0
from law of cosines
📋 Step-by-Step Solution

Sources & Formula Verification

📐
Khan Academy — Law of Cosines (2026)
Primary source for law of cosines formulas, SSS and SAS triangle solving methods, and step-by-step algebraic derivations used in this calculator's solution display.
📘
Math Is Fun — Cosine Rule (2026)
Educational resource for cosine law applications, triangle inequality validation, and real-world navigation and surveying examples referenced in content sections.
📚
Wolfram MathWorld — Law of Cosines (2026)
Mathematical reference for formal proof of law of cosines, relationship to Pythagorean theorem, and trigonometric identity verification.
📐 Law of Cosines Formulas
For side c:   c² = a² + b² - 2ab·cos(C)
For side a:   a² = b² + c² - 2bc·cos(A)
For side b:   b² = a² + c² - 2ac·cos(B)
To find an angle when all sides are known:
cos(C) = (a² + b² - c²) / (2ab)
Then C = arccos of that result
Verified against Khan Academy trigonometry standards, NCTM geometry curriculum, and Wolfram MathWorld mathematical references. Formula applies to all triangles: acute, obtuse, and right triangles. Last verified April 2026.

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.

💡 Here's what makes law of cosines different: The Pythagorean theorem only works for right triangles. The law of cosines works for any triangle — acute, obtuse, or right. When the angle is 90 degrees, cosine of 90 equals zero, and the law of cosines becomes the Pythagorean theorem. It's a generalization that covers every possible triangle.

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:

  1. Pick one angle to find first. Start with the largest angle (opposite the longest side). Here that's angle C opposite side 10.
  2. Rearrange the law of cosines: cos(C) = (a² + b² - c²) / (2ab)
  3. Plug in the numbers: cos(C) = (8² + 6² - 10²) / (2×8×6) = (64 + 36 - 100) / 96 = 0 / 96 = 0
  4. Take inverse cosine: C = arccos(0) = 90°. This is a right triangle.
  5. Find the second angle the same way or use law of sines (which is now easier).
  6. 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:

  1. Use the direct formula: c² = a² + b² - 2ab·cos(C)
  2. Plug in: c² = 5² + 7² - 2(5)(7)·cos(45°) = 25 + 49 - 70(0.707) = 74 - 49.5 = 24.5
  3. Square root: c = √24.5 = 4.95
  4. 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.

MethodWhen to UseWhat You Need
Pythagorean TheoremRight triangles onlyTwo legs or one leg + hypotenuse
Law of CosinesSSS or SAS cases3 sides OR 2 sides + included angle
Law of SinesASA or AAS cases2 angles + 1 side
Frequently Asked Questions
The law of cosines has three formulas. For side c: c squared equals a squared plus b squared minus 2ab times cosine of angle C. For side a: a squared equals b squared plus c squared minus 2bc times cosine of angle A. For side b: b squared equals a squared plus c squared minus 2ac times cosine of angle B. It relates the three sides of any triangle to one of its angles.
Use the law of cosines when you know three sides and need an angle which is the SSS case, or when you know two sides and the included angle between them and need the third side which is the SAS case. Don't use it for right triangles where the Pythagorean theorem is simpler, or when you know two angles where the law of sines works better.
Given three sides a, b, and c, use the law of cosines to find one angle first. Use cosine of C equals the quantity a squared plus b squared minus c squared divided by 2ab. Calculate the inverse cosine to get angle C. Then use the law of cosines or law of sines to find the remaining two angles.
Given two sides and the included angle between them such as sides a and b with angle C, use the law of cosines c squared equals a squared plus b squared minus 2ab cosine C to find the missing side c. Then use the law of cosines again or the law of sines to find the other two angles.
Law of cosines relates sides to one angle and is used for SSS and SAS cases. Law of sines relates sides to opposite angles and is used for ASA and AAS cases. Law of cosines works for any triangle. Law of sines can have ambiguous cases with two possible solutions in the SSA scenario.
Yes but the Pythagorean theorem is simpler. When angle C equals 90 degrees, cosine of C equals zero, so the law of cosines c squared equals a squared plus b squared minus 2ab times zero simplifies to c squared equals a squared plus b squared which is the Pythagorean theorem. The law of cosines generalizes the Pythagorean theorem to all triangles.
Rearrange the formula. To find angle C when you know all three sides, use cosine of C equals the quantity a squared plus b squared minus c squared all divided by 2ab. Then take the inverse cosine or arccosine of that result to get angle C in degrees or radians. Repeat for other angles if needed.
SSS means Side-Side-Side where all three sides are known. SAS means Side-Angle-Side where two sides and the included angle between them are known. Both cases can be solved using the law of cosines. SSS requires finding angles. SAS requires finding the third side first.
The Pythagorean theorem is a special case of the law of cosines for right triangles. When the angle is 90 degrees, cosine of 90 equals zero, and the law of cosines reduces to a squared plus b squared equals c squared. The law of cosines works for all triangles including right, acute, and obtuse triangles.
Navigation uses it to calculate distances when you know two legs of a journey and the angle between them. Surveyors use it to determine inaccessible distances. Engineers use it for structural calculations in non-right triangular frameworks. Pilots use it for course corrections when wind changes their heading.
Cosine rule is another name for the law of cosines. Both terms refer to the same trigonometric identity that relates the three sides of a triangle to one of its angles. The formula is c squared equals a squared plus b squared minus 2ab times cosine of angle C.
Yes. The law of cosines works for any triangle whether right, acute, or obtuse. It works for equilateral, isosceles, and scalene triangles. The only requirement is that the three sides must satisfy the triangle inequality theorem where the sum of any two sides must be greater than the third side.
Related Calculators
Popular Calculators
📐

Need a Different Calculator?

Can't find what you need? Request it — we build new calculators every week.