Law of Cosines Calculator
Find a missing side from two sides and the included angle (SAS), or a missing angle from three sides (SSS). When the included angle is 90°, the law of cosines is the Pythagorean theorem.
a = 8, b = 6, c = 7.21110255093
- The law of cosines: c² = a² + b² − 2ab cos C.
- c² = 64 + 36 − 96 × 0.5 = 52.
- c = √52 ≈ 7.211.
Embed Law of Cosines Calculator
Copy this iframe code into a page that permits embeds.
All calculations run locally in your browser. Your entered values are not sent to an external service.
How to Use the Law of Cosines Calculator
Choose SAS if you know two sides and the angle between them. Choose SSS if you know all three sides and want the angle opposite side c. The tool also returns the other two angles and the area.
- Pick Find side c (SAS) or Find angle C (SSS).
- Enter two sides and either the included angle or the third side. Angle C is opposite c.
- Read c or C, then A, B, the area, and whether the triangle is acute, right, or obtuse.
A right triangle with two known sides belongs on the Pythagorean Theorem Calculator. AAS or the ambiguous SSA case belongs on the Law of Sines Calculator. Area alone from base and height or Heron belongs on the Triangle Area Calculator.
The Law of Cosines
Drop an altitude from A to side a, or expand |b − c|² in vectors: the extra term is twice the product of the sides times the cosine of the included angle. When C is acute, cos C is positive and c is shorter than it would be in a right triangle with the same legs. When C is obtuse, cos C is negative and subtracting a negative number makes c longer.
The same identity written for A or B finds the other angles: cos A = (b² + c² − a²) / (2bc). The area is ½ab sin C once C is known.
Law of Cosines Examples
SAS: sides 8 and 6, included 60°
c² = 64 + 36 − 2×8×6×cos 60° = 100 − 48 = 52. c = √52 ≈ 7.211. Area = ½ × 8 × 6 × sin 60° = 24 × (√3/2) ≈ 20.785.
SAS that is right: 3, 4, 90°
cos 90° = 0, so c² = 9 + 16 = 25 and c = 5. The law of cosines has become a² + b² = c².
SSS: 3-4-5
cos C = (9 + 16 − 25) / 24 = 0, so C = 90°. Kind is right.
SSS isosceles 5, 5, 6
cos C = (25 + 25 − 36) / 50 = 0.28. C = arccos(0.28) ≈ 73.740°. The triangle is acute.
Degenerate 1, 2, 3
1 + 2 = 3. cos C = (1 + 4 − 9) / 4 = −1, so C = 180° and the area is 0. The points are collinear.
Impossible 1, 1, 3
1 + 1 is less than 3. The cosine formula would leave |cos C| greater than 1. The calculator stops with the triangle inequality.
How This Relates to Pythagoras
The Pythagorean theorem is the law of cosines at C = 90°. You do not need a separate cosine term because that term is zero. If a homework figure is clearly right-angled and you only need one missing side, the Pythagorean Theorem Calculator is the shorter page. Use this page when the given angle is not 90°, or when three sides are known and you need to test whether the triangle is right, acute, or obtuse.
Common Law of Cosines Mistakes
Using a non-included angle in SAS
C must sit between sides a and b. An angle that is not between those sides needs the law of sines after you find another pair, or a relabel so the known angle is included.
Forgetting the minus sign
The formula is a² + b² minus 2ab cos C. Dropping the minus sign, or treating cosine as always positive, gives the wrong side.
Taking arccos of a value outside [−1, 1]
That means the sides fail the triangle inequality. Do not clamp the cosine and invent an angle.
Using this page for AAS or SSA
Two angles and a non-included side, or two sides and a non-included angle, belong on the Law of Sines Calculator. SSA can have two triangles.
Calling every 3-4-5 a cosine problem
If you already know it is right, Pythagoras is enough. This page still works; it just does extra arithmetic that cancels.
Law of Cosines Calculator FAQs
What is the law of cosines?
c² = a² + b² − 2ab cos C, where C is the angle between sides a and b and c is the opposite side. Rearranged, it finds an angle from three sides.
When do you use the law of cosines instead of sines?
Use cosines for SAS (two sides and the included angle) or SSS (three sides). Use sines for AAS, ASA, and the ambiguous SSA case.
Does it work for a right triangle?
Yes. If C = 90°, cos C = 0 and you recover a² + b² = c². The Pythagorean calculator is the shorter path when you already know the right angle.
Can three sides give a 180° angle?
Yes, when a + b = c. That is a degenerate (flat) triangle with area 0.
Does this find area?
Yes, as ½ab sin C after C is known. For base and height or Heron without angles, use the Triangle Area Calculator.
Are my numbers sent to a server?
No. The calculation runs locally in your browser.
Related Calculators
Explore More Geometry Tools
Continue with triangle, coordinate, and trigonometry tools in the SolverCalc collection.
Reviewed by Prof. Dr. Khalil Mudassar (PhD) · Last updated: [mc_modified_date]
Sources
View mathematical references
Disclaimer
This calculator is intended for general educational and practical use. Review important results before relying on them in professional work.