Law of Cosines Calculator

Solve any triangle from three sides or two sides and an angle.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The law of cosines is the rule that lets you solve oblique (non-right) triangles where the simple Pythagorean theorem and SOH-CAH-TOA do not apply. Students, engineers, surveyors and anyone working with triangles can use it to find a missing side from two sides and the angle between them, or to recover all three angles from three known sides.

How it works

The core identity is a² = b² + c² − 2bc·cos(A), where each lowercase side sits opposite the matching uppercase angle.

  • SSS mode (three sides known): the tool rearranges the rule to cos(A) = (b² + c² − a²) / (2bc) and takes the inverse cosine for angles A and B, then finds C as 180° − A − B.
  • SAS mode (two sides and the included angle): it first computes the missing side a = √(b² + c² − 2bc·cos(A)), then solves for the remaining angles the same way.

In both modes it also returns the area via ½·b·c·sin(A) and the perimeter as a + b + c. The cosine inputs are clamped to the range −1 to 1 to avoid rounding errors at the extremes.

Example

Take a triangle with sides a = 7, b = 8, c = 9 (SSS mode):

ResultValue
Angle A48.19°
Angle B58.41°
Angle C73.40°
Area26.83
Perimeter24

Angle A comes from cos(A) = (8² + 9² − 7²) / (2·8·9) = 96/144 = 0.6667, giving A ≈ 48.19°.

All math happens locally in your browser — nothing is uploaded.

Ad placeholder (rectangle)