Key takeaways
- c² = a² + b² - 2ab·cos(C) finds the side opposite the known angle C.
- C must be the angle squeezed between the two known sides a and b.
- It works for every triangle, not just right triangles.
- When C = 90°, cos(C) = 0 and the formula collapses to the Pythagorean theorem.
In this guide
What is the Law of Cosines used for here?
This calculator solves the SAS case: you know two Sides and the Angle between them, and you want the third side. It works for every triangle, not just right triangles, which is why it's more powerful than the Pythagorean theorem alone.
Why does the Law of Cosines matter?
Most real triangles aren't right triangles. Anytime you know two straight-line distances and the turn or angle between them, you need a formula that works for any angle, not just 90°. That's exactly what the Law of Cosines gives you.
The Pythagorean theorem only ever handles right triangles. The Law of Cosines handles all of them, and quietly turns back into the Pythagorean theorem the moment the angle happens to be 90°.
The formula
| Symbol | What it means | Example |
|---|---|---|
| a, b | The two sides you already know | 8 m, 10 m |
| C | The angle between sides a and b, in degrees (0° to 180°) | 50° |
| c | The missing third side, opposite angle C | 7.82 m |
How to find the missing side step by step
- 1Square side a and square side b, then add them.
a² + b². - 2Multiply 2 × a × b, then multiply by cos(C).
- 3Subtract that from a² + b² to get c².
- 4Take the square root of c² to get the length of side c.
Enter your own two sides and included angle below to see side c calculated step by step.
Try it yourself
Pre-filled with the example — change any value.
Common mistakes to avoid
- Forgetting to switch your calculator to degrees (or radians, depending on your tool) before finding cos(C).
- Expecting a right angle. Unlike the Pythagorean theorem, C doesn't need to be 90° — the
-2ab·cos(C)term is exactly what adjusts for that. - Skipping the square root. The formula gives c², not c — don't forget the last step.
Tips and tricks
- If instead you know a side and two angles, use the sine rule calculator.
- To find the same triangle's area from the same two sides and angle, see the SAS triangle area calculator.
- For a right-angle-only shortcut, the Pythagorean theorem calculator is faster when C really is 90°.
Where you'll use it in real life
- Hiking and orienteering: finding a direct return distance after two legs at an angle.
- Navigation: calculating the straight-line distance between two positions reached along different bearings.
- Construction: bracing and framing where two known lengths meet at a non-right angle.
- Sports fields: working out diagonal distances on triangular sections of a field or course.
Quick summary
The Law of Cosines finds a missing triangle side from two known sides and the angle between them, and it works for any triangle. Square and add the known sides, subtract the cosine term, then take the square root. Try the calculator above with your own triangle.
Worked example
You hike 8 km along one trail from camp, then turn and hike 10 km along a second trail, with a 50° angle between the two trails. How far is the straight-line distance back to camp?
- 01c² = a² + b² - 2ab cos(C)
- 02c² = 8² + 10² - 2(8)(10)cos(50°)
- 03c² = 64 + 100 - 160(0.643)
- 04c² = 164 - 102.85
- 05c² = 61.15
- 06c = 7.82
These numbers are pre-filled in the calculator above.
Frequently asked questions
When should I use the Law of Cosines instead of the Pythagorean theorem?
Use the Law of Cosines whenever the triangle doesn't have a right angle. The Pythagorean theorem only works for right triangles; the Law of Cosines works for any triangle.
What does SAS mean here?
SAS stands for Side-Angle-Side: you know two sides of the triangle and the angle that sits directly between them, and you're solving for the third side.
Does the angle have to be the included angle?
Yes. The formula only works when C is the angle between the two known sides a and b, not one of the other angles.
What if C is 90°?
cos(90°) = 0, so the formula simplifies to c² = a² + b² — exactly the Pythagorean theorem, since the Law of Cosines is a generalized version of it.


