Law of Cosines Calculator

Solve triangles from three sides (SSS) or two sides and the included angle (SAS). Returns all missing parts with step-by-step working.

📐 Law of Cosines Calculator

Enter all three side lengths to find every angle.

Enter two sides and the included angle C between them.

°
Angle A
Angle B
Angle C
Side a
Side b
Side c
Area
Perimeter
Step-by-step working

What is the Law of Cosines?

The Law of Cosines is a fundamental theorem of trigonometry that relates the lengths of the three sides of any triangle to the cosine of one of its angles. The full statement is:

  • c² = a² + b² − 2ab cos(C)
  • a² = b² + c² − 2bc cos(A)
  • b² = a² + c² − 2ac cos(B)

where a, b, c are side lengths and A, B, C are the angles opposite to those respective sides.

The Law of Cosines is a direct generalization of the Pythagorean theorem: when angle C equals 90°, cos(C) = 0, and the formula reduces to c² = a² + b². For acute angles (C < 90°), the correction term is negative, making c smaller than the Pythagorean hypotenuse; for obtuse angles (C > 90°), the correction term is positive, making c larger.

The formula was known to ancient Greek mathematicians and is sometimes called the cosine rule in British usage. It appears explicitly in Euclid’s Elements as Propositions II.12 and II.13, though without the modern trigonometric notation. The modern form using cosines was developed in the 15th and 16th centuries.

Formula

The primary form used for finding a missing side (SAS mode):

c² = a² + b² − 2ab cos(C)

Rearranged to find a missing angle from three known sides (SSS mode):

cos(A) = (b² + c² − a²) / (2bc)

cos(B) = (a² + c² − b²) / (2ac)

cos(C) = (a² + b² − c²) / (2ab)

Variables:

  • a, b, c — the three side lengths of the triangle
  • A — angle opposite side a
  • B — angle opposite side b
  • C — angle opposite side c (the included angle in SAS mode)

Area formula (used after the triangle is fully solved): Area = ½ × a × b × sin(C)

How to Use

  1. Choose your mode — select SSS if you know all three sides, or SAS if you know two sides and the angle between them (the included angle).
  2. Enter your values — for SSS, enter sides a, b, c; for SAS, enter sides a, b and included angle C in degrees.
  3. Click Calculate — the calculator shows all three angles, all three sides, area, perimeter, and full step-by-step working.
  4. Check the steps — the working panel shows every cosine and arccos computation so you can follow the method.
  5. Switch modes — use SSS for structural problems where you know distances; use SAS for navigation and force vector problems where you know two distances and the angle between them.

Example Calculations

Example 1 — SSS: Find All Angles from Three Sides

Triangle with sides a = 7, b = 10, c = 8

1
Find A: cos(A) = (b² + c² − a²) / (2bc) = (100 + 64 − 49) / (2 × 10 × 8) = 115/160 = 0.71875
2
A = arccos(0.71875) = 44.05°
3
Find B: cos(B) = (a² + c² − b²) / (2ac) = (49 + 64 − 100) / (2 × 7 × 8) = 13/112 = 0.11607 → B = arccos(0.11607) = 83.33°
4
C = 180° − 44.05° − 83.33° = 52.62°
Angles: A ≈ 44.05°, B ≈ 83.33°, C ≈ 52.62°  |  Area = ½ × 7 × 10 × sin(52.62°) ≈ 27.81
Try this example →

Example 2 — SAS: Find Missing Side and Angles

Triangle with a = 5, b = 8, C = 60°

1
c² = a² + b² − 2ab·cos(C) = 25 + 64 − 2 × 5 × 8 × cos(60°) = 89 − 80 × 0.5 = 89 − 40 = 49
2
c = √49 = 7
3
cos(A) = (b² + c² − a²) / (2bc) = (64 + 49 − 25) / (2 × 8 × 7) = 88/112 ≈ 0.7857 → A ≈ 38.21°
4
B = 180° − 60° − 38.21° = 81.79°
c = 7, A ≈ 38.21°, B ≈ 81.79°  |  Area = ½ × 5 × 8 × sin(60°) = 20 × 0.8660 ≈ 17.32
Try this example →

Example 3 — SAS: Obtuse Included Angle

Triangle with a = 6, b = 9, C = 120°

1
c² = 36 + 81 − 2 × 6 × 9 × cos(120°) = 117 − 108 × (−0.5) = 117 + 54 = 171
2
c = √171 ≈ 13.077
3
cos(A) = (81 + 171 − 36) / (2 × 9 × 13.077) = 216/235.39 ≈ 0.9177 → A ≈ 23.41°
4
B = 180° − 120° − 23.41° = 36.59°
c ≈ 13.077, A ≈ 23.41°, B ≈ 36.59°  |  Area = ½ × 6 × 9 × sin(120°) ≈ 23.38
Try this example →

❓ Frequently Asked Questions

What is the Law of Cosines?+
The Law of Cosines states that for any triangle with sides a, b, c opposite angles A, B, C: c² = a² + b² − 2ab cos(C). It can be written for any side-angle pair. It is a generalization of the Pythagorean theorem — when C = 90°, cos(C) = 0 and c² = a² + b². The law holds for all triangles: acute, right, and obtuse.
When should I use the Law of Cosines vs the Law of Sines?+
Use the Law of Cosines for SSS (all three sides known) and SAS (two sides and the included angle). Use the Law of Sines for SAA/AAS (one side and two angles) and SSA (two sides and a non-included angle, the ambiguous case). If you have an angle-side pair plus one more value, the Law of Sines applies. For SAS or SSS, reach for the Law of Cosines.
How do you find an angle from three sides?+
Rearrange the Law of Cosines: cos(A) = (b² + c² − a²) / (2bc), then A = arccos of that value. Since arccos always returns a value between 0° and 180°, there is no ambiguity in SSS — each set of valid sides yields exactly one triangle. Find all three angles this way, then verify they sum to 180°.
What is the triangle inequality?+
The triangle inequality states that each side must be less than the sum of the other two: a < b + c, b < a + c, c < a + b. If any side equals or exceeds the sum of the other two, no triangle can be formed. In the Law of Cosines, a violation causes the cosine expression to exceed 1 in absolute value, making arccos undefined. This calculator detects this and reports an error.
Why does the Law of Cosines reduce to the Pythagorean theorem for right triangles?+
When C = 90°, cos(90°) = 0, so the term −2ab cos(C) vanishes. The formula becomes c² = a² + b² + 0 = a² + b², which is exactly the Pythagorean theorem. The Law of Cosines can be seen as the Pythagorean theorem with a correction factor that accounts for the angle not being 90°.
What is the SAS configuration?+
SAS stands for Side-Angle-Side: two known sides with the angle between them (the included angle). For example, sides a = 5, b = 8 with included angle C = 60°. The Law of Cosines finds the third side c directly: c² = 5² + 8² − 2(5)(8)cos(60°) = 49, so c = 7. The remaining angles follow from further applications of the cosine rule.
Can the Law of Cosines be used for obtuse triangles?+
Yes. For an obtuse angle C (between 90° and 180°), cos(C) is negative, making the term −2ab cos(C) positive. This correctly yields a larger side c opposite the obtuse angle. The formula gives valid results for all triangles satisfying the triangle inequality, whether they have acute, right, or obtuse angles.
How is triangle area calculated?+
Once the full triangle is solved (all sides and angles known), area = ½ × a × b × sin(C), where C is the included angle between sides a and b. This follows from the fact that the height h of the triangle from vertex C is b sin(A), and area = ½ base × height = ½ × a × b sin(C). The formula works for any pair of sides and their included angle.
What real-world problems use the Law of Cosines?+
Navigation: finding the distance between two points given two known distances and the bearing angle between them. Surveying: triangulating an inaccessible location from two known points. Structural engineering: resolving force triangles where two force magnitudes and the angle between them are known. Computer graphics: computing interior angles of mesh triangles. Astronomy: finding the distance to a star using parallax measurements from opposite sides of Earth's orbit.
How do you verify a Law of Cosines result?+
Three verification checks: (1) A + B + C = 180°. (2) All sides and angles are positive. (3) Plug computed values back: c² should equal a² + b² − 2ab cos(C) to within rounding. You can also cross-verify with the Law of Sines: a/sin(A) = b/sin(B) = c/sin(C) should be a consistent ratio. Matching area from two different formula arrangements (e.g., ½ab sin C and ½ac sin B) also confirms correctness.