Geometry • Trigonometric Triangle Solver

Law of Cosines Calculator

Solve any oblique triangle for missing sides, angles, perimeter, and area using the Law of Cosines. Supports SAS and SSS configurations with dynamic 2D geometric triangle plots.

|
Last Updated: September 2026
|
Verified Mathematical Solution
Looking for AAS, ASA or SSA Triangles?

If you have two angles (AAS/ASA) or two sides and a non-included angle (SSA), use our companion Law of Sines solver.

Open Law of Sines Solver
Switch to Law of Sines (AAS / SSA)
SAS Given Parameters (Side-Angle-Side)
Preset Examples:
Solved Triangle Metrics Valid Triangle
Solved Opposite Side c
c = 6.66 | A = 46.38° | B = 96.62°
c² = a² + b² − 2ab·cos(C) = 44.33
Angle A 46.38°
Angle B 96.62°
Perimeter 25.66
Heron Area 26.48

Geometry Plot & Oblique Triangle

c² = a² + b² − 2ab·cos(C)
A (Vertex)
B (Vertex)
C (Vertex)

Step-by-Step Law of Cosines Derivation Formula: c² = a² + b² − 2ab·cos(C)

Direct Answer & Overview
Verified Educational Guide

How to Solve a Triangle Using the Law of Cosines

To solve an oblique triangle using the Law of Cosines, choose the formula variant matching your known data. For SAS (two sides a, b and included angle C), compute the opposite side c = √[a² + b² - 2ab·cos(C)]. For SSS (three known sides), solve any angle by isolating the cosine: cos(A) = (b² + c² - a²) / (2bc) and applying arccos. Find the second angle via the Law of Sines/Cosines, then subtract from 180° for the third angle.

Primary Mathematical Formula Standard Mathematical Model
Standard Equation
ƒ(x)
Q.E.D.
c² = a² + b² - 2ab·cos(C) | cos(A) = (b² + c² - a²) / (2bc) | Area = √[s(s-a)(s-b)(s-c)]
Evaluated with exact mathematical formulation • Rigorously verified
Exact Formula
Input Parameters
Required
1
SAS Mode: Two side lengths (a, b) and their included angle (C)
2
SSS Mode: All three side lengths (a, b, c) satisfying triangle inequalities
Expected Outputs
Calculated
Missing Side (c): Computed exact length opposite to included angle
Missing Angles (A, B, C): Internal angles in degrees summing to exactly 180°
Perimeter: Total boundary length P = a + b + c
Heron's Area: Exact area computed via semi-perimeter s = (a+b+c)/2
Worked Numerical Example
Instant Verification
Solve triangle with a = 8, b = 11, C = 37°
→ c² = 8² + 11² - 2(8)(11)cos(37°) = 64 + 121 - 176(0.7986) = 185 - 140.56 = 44.44. c = √44.44 = 6.67
Side c = 6.67 | Angle A = 46.38° | Angle B = 96.62° | Area = 26.48 sq units

The Law of Cosines Formula & Generalized Pythagorean Theorem

The Law of Cosines (also known as the cosine rule) connects the three sides of any triangle with the cosine of one of its angles:

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

Solving Side-Angle-Side (SAS) Triangles

In an SAS triangle, you know two sides and the angle trapped between them:

  1. Step 1: Apply the Law of Cosines to find the third opposite side: $c = \sqrt{a^2 + b^2 - 2ab\cos(C)}$.
  2. Step 2: Use the Law of Cosines or Sines to find the smaller of the remaining two angles (always acute).
  3. Step 3: Find the final angle via $B = 180^\circ - A - C$.

Solving Side-Side-Side (SSS) Triangles

When all three side lengths $a, b, c$ are given, isolate the cosines:

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

Tip: Always solve for the largest angle first (opposite the longest side). If $\cos(\text{Angle}) < 0$, the angle is obtuse; the remaining two angles are guaranteed to be acute.

Computing Area with Heron's Formula & Sine Area

Once the triangle is solved, the area can be computed using either method:

Sine Area Formula
Area = ½ ab sin(C)

Fastest for SAS configurations.

Heron's Formula
Area = √[s(s−a)(s−b)(s−c)]

Where semi-perimeter $s = (a+b+c)/2$.

Comparing Law of Sines vs Law of Cosines

The two laws complement each other perfectly:

  • Law of Cosines: Handles SSS and SAS where no angle-opposite-side pair is known initially.
  • Law of Sines: Handles AAS, ASA, and SSA where at least one matching angle-side pair is known.

Step-by-Step Worked Examples (SAS & SSS Cases)

Side-Angle-Side (SAS) Solution Level: Intermediate

Solve triangle with a = 8, b = 11, C = 37°.

1. c² = 8² + 11² − 2(8)(11) cos(37°) = 64 + 121 − 176(0.7986) = 185 − 140.56 = 44.44.

2. c = √44.44 ≈ 6.67.

3. cos(A) = (11² + 6.67² − 8²) / (2 × 11 × 6.67) = (121 + 44.44 − 64) / 146.74 = 101.44 / 146.74 ≈ 0.6913 → A = 46.26°.

4. B = 180° − 46.26° − 37° = 96.74°.

Common Pitfalls & Negative Cosine Evaluation

Pitfall 1: Order of Operations

In $a^2 + b^2 - 2ab\cos(C)$, do NOT compute $(a^2 + b^2 - 2ab) \times \cos(C)$. Multiplication has higher precedence; compute $(2ab\cos C)$ first before subtracting from $(a^2 + b^2)$.

Pitfall 2: Negative Cosine in Obtuse Angles

If an angle is obtuse ($C > 90^\circ$), $\cos(C)$ is negative. The $-2ab\cos(C)$ term becomes a positive addition: $c^2 = a^2 + b^2 + 2ab|\cos C|$.

Fact-Checked & Verified • Computational Accuracy Standards
Updated July 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

What is the Law of Cosines?
The Law of Cosines generalizes the Pythagorean theorem to any oblique triangle: c² = a² + b² - 2ab·cos(C). It relates the lengths of all three sides to the cosine of one of the angles.
When should I use the Law of Cosines?
Use the Law of Cosines when you are given: (1) Two sides and the included angle between them (SAS) to find the third side, or (2) Three side lengths (SSS) to find all three internal angles.
How is the Law of Cosines related to the Pythagorean theorem?
If angle C is a right angle (90°), cos(90°) = 0, so the term -2ab·cos(90°) vanishes, simplifying the formula directly to c² = a² + b². Thus, the Pythagorean theorem is a special case of the Law of Cosines.
How do you find angles given three sides (SSS)?
Rearrange the formula to isolate the cosine of the angle: cos(A) = (b² + c² - a²) / (2bc). Then take the inverse cosine: A = arccos((b² + c² - a²) / (2bc)). Repeat for angle B, then find C = 180° - A - B.
Why is there no ambiguous case for the Law of Cosines?
Unlike the arcsine function (which cannot distinguish between acute θ and obtuse 180° - θ because sin(θ) = sin(180° - θ)), the arccosine function has a unique 1-to-1 mapping across the entire range [0°, 180°]. A positive cosine indicates an acute angle, while a negative cosine uniquely indicates an obtuse angle.