Law of Cosines Calculator - Solve Any Triangle (SAS/SSS)

Solve any triangle using the law of cosines. Find a missing side with SAS or a missing angle with SSS.

Select whether you want to find a missing side (SAS) or angle (SSS), enter the known values, and get the result instantly.

Law of Cosines Calculator - Solve Any Triangle (SAS/SSS)
Solve any triangle using the law of cosines. Find a missing side with SAS or a missing angle with SSS.

Law of Cosines Examples

Four typical scenarios covering SAS and SSS configurations including an obtuse triangle.

Known ValuesResultConfiguration
a=5, b=7, C=45° (SAS)c ≈ 4.950c² = 25 + 49 − 2(5)(7)cos(45°) = 74 − 49.497 ≈ 24.503, c ≈ 4.950.
a=8, b=6, c=10 (SSS)C = 90°cos(C) = (64+36−100)/(2×48) = 0/96 = 0, so C = arccos(0) = 90° (right triangle).
a=10, b=12, C=120° (SAS, obtuse)c ≈ 19.08c² = 100+144−2(10)(12)cos(120°) = 244+120 = 364, c = √364 ≈ 19.08.
a=9, b=9, c=6 (SSS, isosceles)C ≈ 38.94°cos(C) = (81+81−36)/(2×81) = 126/162 ≈ 0.7778, C = arccos(0.7778) ≈ 38.94°.

About the Law of Cosines Calculator

The law of cosines is a fundamental theorem in trigonometry that generalizes the Pythagorean theorem to any triangle, not just right triangles. Given a triangle with sides a, b, and c opposite to angles A, B, and C respectively, the law states: c² = a² + b² − 2ab⋅cos(C). When angle C = 90°, cos(C) = 0 and the formula reduces to the familiar Pythagorean theorem c² = a² + b². The law of cosines is used in two main configurations. In the Side-Angle-Side (SAS) configuration, you know two sides and the included angle (the angle between those two sides) and want to find the third side. In the Side-Side-Side (SSS) configuration, you know all three sides and want to find one of the angles. By rearranging the formula, the SSS case becomes: cos(C) = (a² + b² − c²) / (2ab), and C = arccos of that value. The law of cosines is closely related to the law of sines, but applies in situations where the law of sines cannot be used directly. Specifically, the law of sines requires either two angles and a side (AAS/ASA) or two sides and a non-included angle (SSA, which has the ambiguous case). The law of cosines handles SAS and SSS cleanly, with a unique solution in every case (assuming the inputs define a real triangle). Practical applications are abundant in surveying, navigation, architecture, engineering, and physics. Surveyors use the law of cosines to compute distances between points when direct measurement is obstructed. Navigation software calculates bearing and distance between two GPS coordinates using spherical versions of the same formula. Structural engineers compute truss member forces that depend on triangle geometry. Computer graphics pipelines use cosine-rule calculations to determine angles between mesh edges. For an obtuse triangle, one angle exceeds 90° and its cosine is negative, which makes c² > a² + b². The law of cosines handles this seamlessly because the formula accommodates both positive and negative cosine values. This is one advantage over simpler methods that assume right angles. This calculator handles both SAS and SSS cases. For SAS, enter sides a and b and the included angle C; the tool computes side c. For SSS, enter all three sides a, b, and c; the tool computes angle C. Results are shown with the formula used so you can verify the arithmetic manually.

How to Use the Law of Cosines Calculator

  1. Choose the calculation mode: “Find Side (SAS)” if you know two sides and the angle between them, or “Find Angle (SSS)” if you know all three sides.
  2. For SAS, enter the lengths of sides a and b and the included angle C (in degrees).
  3. For SSS, enter the lengths of all three sides a, b, and c.
  4. Click Calculate. The tool applies the law of cosines formula and displays the missing side or angle.
  5. Click Reset to clear all fields and solve a different triangle.

Frequently Asked Questions

What is the law of cosines?
The law of cosines states that for any triangle with sides a, b, c and opposite angles A, B, C: c² = a² + b² − 2ab⋅cos(C). It extends the Pythagorean theorem to non-right triangles, where the cosine term corrects for the deviation from a right angle. When C = 90°, cos(C) = 0 and the familiar Pythagorean theorem is recovered.
When should I use the law of cosines instead of the law of sines?
Use the law of cosines when you have the SAS (two sides and the included angle) or SSS (three sides) configuration. The law of sines is preferable for AAS and ASA cases. For SSA, the law of sines works but introduces the ambiguous case; the law of cosines avoids ambiguity by solving a quadratic, though one solution may be extraneous.
Can the law of cosines handle obtuse triangles?
Yes. For an obtuse triangle, the angle greater than 90° has a negative cosine. The formula c² = a² + b² − 2ab⋅cos(C) still holds; the negative cosine makes c² larger than a² + b², correctly reflecting that side c is the longest side opposite the obtuse angle.
How do I find all angles of a triangle from three sides?
Apply the law of cosines three times using different letter assignments. First find C = arccos((a²+b²−c²)/(2ab)), then find B = arccos((a²+c²−b²)/(2ac)), and finally A = 180° − B − C. Alternatively, once two angles are known the third follows from the angle-sum property.
What happens if the inputs do not form a valid triangle?
For SSS, the triangle inequality must hold: each side must be less than the sum of the other two. If this is violated, there is no valid triangle and the formula gives |cos(C)| > 1, which has no real arccos. This calculator detects that case and shows an error message.
Is the law of cosines the same as the cosine rule?
Yes, the law of cosines and the cosine rule are two names for the same theorem. “Cosine rule” is common in British educational contexts while “law of cosines” is more common in American textbooks. The formula and its applications are identical.