Law of Cosines — Generalized Pythagorean Theorem
c² = a² + b² - 2ab·cos(C). Solve any triangle given SAS (two sides + included angle) or SSS (all three sides). Reduces to Pythagorean theorem when C = 90°.
Did our AI summary help? Let us know.
Why: Understanding law of cosines helps you make better, data-driven decisions.
How: Enter Solve Mode, Side a, Side b to calculate results.
Run the calculator when you are ready.
Examples — Click to Load
Triangle Dimensions
Side Lengths
Angle Proportions
Calculation Breakdown
For educational and informational purposes only. Verify with a qualified professional.
Key Takeaways
- • c² = a² + b² - 2ab·cos(C) — generalizes the Pythagorean theorem to any triangle
- • Use for SAS (two sides + included angle) or SSS (all three sides)
- • When C = 90°, cos(C) = 0 and it reduces to c² = a² + b²
- • For obtuse angles, cos(C) < 0 so c² > a² + b²
- • Area = ½·a·b·sin(C) uses the included angle
Did You Know?
How It Works
Finding Side c (SAS)
Given sides a, b and included angle C: c² = a² + b² - 2ab·cos(C). Take the square root. The -2ab·cos(C) term adjusts for the angle — when C=90° it vanishes.
Finding Angle C (SSS)
Given all three sides: cos(C) = (a² + b² - c²) / (2ab). Then C = arccos(...). Use the angle opposite the side you are solving for.
When to Use vs Law of Sines
Law of Cosines: SAS, SSS. Law of Sines: AAS, ASA, SSA. Prefer Cosines when you have sides and an included angle.
Expert Tips
C is the Included Angle
For SAS, angle C must be between sides a and b. The side you find (c) is opposite angle C.
Check Triangle Inequality
For SSS, verify a+b>c, a+c>b, b+c>a before solving. Otherwise no triangle exists.
Obtuse Angles
When C>90°, cos(C)<0 so c² > a²+b². The "correction" term adds to the sum. See Cosine Calculator.
Area Formula
Area = ½·a·b·sin(C) uses the same two sides and included angle. No need to find c first.
Comparison: Law of Cosines vs Other Methods
| Feature | Law of Cosines | Law of Sines | Pythagorean |
|---|---|---|---|
| Best for | SAS, SSS | AAS, ASA, SSA | Right triangles |
| Requires | Sides + angle or 3 sides | 2 angles + side | 2 sides, 90° |
| Ambiguous case | No | Yes (SSA) | No |
| Formula | Quadratic in c | Linear ratio | c²=a²+b² |
| When C=90° | → Pythagorean | Still works | Direct |
| Area | ½ab·sin(C) | Via sides | ½ab |
| Derivation | Coordinate geometry | Area formula | Similar triangles |
| 3D extension | Spherical version | Spherical version | N/A |
Frequently Asked Questions
How does the Law of Cosines relate to the Pythagorean theorem?
When angle C = 90°, cos(C) = 0, so c² = a² + b² - 0 = a² + b². The Law of Cosines is the generalization for any angle.
When should I use Law of Cosines vs Law of Sines?
Use Law of Cosines for SAS (two sides + included angle) or SSS (all three sides). Use Law of Sines for AAS, ASA, or SSA.
What if c² is negative?
No triangle exists with those measurements. The angle may be impossible, or you may have swapped sides. Check your inputs.
Can I find all three angles with SSS?
Yes. Find one angle with the Law of Cosines, then use the Law of Sines for the others, or apply the Law of Cosines twice more.
How is the Law of Cosines derived?
Place the triangle in the coordinate plane with one vertex at the origin. Use the distance formula and the definition of cosine. The -2ab·cos(C) term comes from the dot product.
What about obtuse triangles?
The Law of Cosines works for all triangles. For obtuse C, cos(C) < 0, so the correction term is positive and c² > a² + b².
What units for sides and angles?
Sides can be any length unit. Angles in degrees or radians — ensure consistency. The calculator uses your chosen unit.
Is there a spherical Law of Cosines?
Yes. For spherical triangles (e.g., on Earth's surface), different formulas apply. Used in navigation and astronomy.
Law of Cosines by the Numbers
Official & Educational Sources
Disclaimer: Results for educational use. Verify triangle validity for engineering applications.
Related Calculators
Law of Sines Calculator
Solve triangles using a/sin(A) = b/sin(B) = c/sin(C). Supports ASA, AAS, and SSA cases with step-by-step solutions, all sides, angles, and area.
MathematicsCofunction Calculator
Verify cofunction identities: sin(θ)=cos(90°-θ), tan(θ)=cot(90°-θ), sec(θ)=csc(90°-θ). Step-by-step.
MathematicsHyperbolic Cosine (cosh) Calculator
Calculate the hyperbolic cosine cosh(x) = (e^x + e^(-x))/2. Get cosh, sinh, and tanh values with Bar and Doughnut charts, and step-by-step solutions.
MathematicsPhase Shift Calculator
Analyze y = A sin(Bx + C) + D. Period, frequency, phase shift in degrees. Step-by-step.
MathematicsPower Reduction Calculator
Reduce sin²θ, cos²θ, tan²θ to simpler forms. sin²θ=(1-cos2θ)/2, cos²θ=(1+cos2θ)/2, tan²θ=(1-cos2θ)/(1+cos2θ). Step-by-step.
MathematicsHyperbolic Sine (sinh) Calculator
Calculate the hyperbolic sine sinh(x) = (e^x - e^(-x))/2. Get sinh, cosh, and tanh values with Bar and Doughnut charts, and step-by-step solutions.
Mathematics