Law of Cosines: The Generalized Pythagorean Theorem
The Law of Cosines generalizes the Pythagorean Theorem to any triangle. See when to use it in SAS and SSS cases, how to calculate sides and angles, and practical applications.
Renato Freitas
Updated on May 5, 2026
Statement and connection to the Pythagorean Theorem
The Law of Cosines states that in a triangle with sides a, b, c and angle C opposite side c: c² = a² + b² − 2ab · cos C.
When C = 90°, cos 90° = 0 and the formula reduces to c² = a² + b², exactly the Pythagorean Theorem. Therefore, the Law of Cosines is the generalized version of the Pythagorean Theorem that works for any triangle, not just right triangles.
The term −2ab · cos C acts as a correction: when C < 90° (acute angle), cos C > 0 and c² is less than a² + b²; when C > 90° (obtuse angle), cos C < 0 and the subtraction becomes addition, making c² greater than a² + b².
🧮 Try it yourself — CalcSim
Want more features? Download CalcSim IA app
When to use the Law of Cosines
The Law of Cosines is the right tool in two cases: SAS (two sides and the angle between them are known) and SSS (all three sides are known).
In the SAS case, apply the formula directly to find the opposite side. In the SSS case, isolate the cosine to find an angle: cos C = (a² + b² − c²) / (2ab), then use arccos.
The Law of Sines does not work in these cases because, in SAS, you do not have a complete side-angle pair, and in SSS you have no initial angle at all. The Law of Cosines fills exactly these gaps.
- SAS: two sides + included angle → find the third side
- SSS: three known sides → find any angle
- AAS, ASA, SSA → prefer the Law of Sines
Calculating the unknown side (SAS case)
Example: a = 8, b = 6, C = 60°. Then c² = 8² + 6² − 2 × 8 × 6 × cos 60° = 64 + 36 − 96 × 0.5 = 100 − 48 = 52. So c = √52 = 2√13 ≈ 7.21.
Steps: (1) Identify the two sides and the angle between them. (2) Substitute into c² = a² + b² − 2ab cos C. (3) Compute the numerical value of c². (4) Extract the square root.
Once c is found, you can determine the remaining angles using the Law of Sines (now a complete side-angle pair exists) or by applying the Law of Cosines again for each angle.
Calculating the unknown angle (SSS case)
Example: a = 5, b = 7, c = 9. To find C (opposite c = 9): cos C = (5² + 7² − 9²) / (2 × 5 × 7) = (25 + 49 − 81) / 70 = −7/70 = −0.1. So C = arccos(−0.1) ≈ 95.74°.
The negative cosine indicates that C is obtuse (greater than 90°), which is expected since c = 9 is the longest side. This reasoning is useful for checking that the result makes sense.
With one angle determined, the other two can be calculated using the Law of Sines or by repeating the Law of Cosines. Always sum all three angles at the end to confirm they equal 180°.
Law of Sines vs Law of Cosines: when to use each
The simple rule: if you have a side-angle pair and need more information, use the Law of Sines. If you do not have that pair — that is, your data is SAS or SSS — use the Law of Cosines.
In problems with two angles (AAS or ASA), the Law of Sines is faster. In the ambiguous SSA case, the Law of Sines also applies, but requires extra care. The Law of Cosines avoids the ambiguous case: in SAS, the solution is always unique.
In engineering and navigation applications, both laws are used together: the Law of Cosines for the first triangle, and the Law of Sines for subsequent ones, alternating based on available data.
Frequently asked questions
Can I use the Law of Cosines in any triangle, including obtuse ones?
Yes, the formula holds for acute, right, and obtuse triangles without any modification. When angle C is obtuse, cos C is negative, and the term −2ab cos C becomes positive, reflecting that c is larger than it would be in a right triangle.
Why not use the Law of Sines in the SAS case?
In the SAS case you know two sides and the angle between them, but you do not have the angle opposite either of the two known sides — and the Law of Sines requires a complete side-angle pair. Without that pair, the proportion cannot be set up.
Can the calculator give arccos of values outside −1 to 1?
No. If the calculation results in cos C > 1 or cos C < −1, there was a calculation error or the given values do not form a valid triangle. The triangle inequality requires each side to be less than the sum of the other two.
How do I know which version of the Law of Cosines to use — for the side or for the angle?
It depends on what is unknown. If you want the side, use c² = a² + b² − 2ab cos C directly. If you want the angle and know all three sides, isolate the cosine: cos C = (a² + b² − c²) / (2ab) and apply arccos.
Is there a version of the Law of Cosines for angles in radians?
The formula is identical; only the numerical value of the cosine changes with the unit. cos(π/3) in radians equals cos 60° = 0.5. The law works in any unit as long as the calculator is set correctly.
Was this article helpful?
Rate with stars to help us improve the content.
Sign in to rate this article.
Still have questions?
The AI Professor explains step by step
Ask a question in natural language and get a personalised explanation about Trigonometry — or any other topic.
Prefer to solve it on your phone?
Download the free app →Keep learning