Skip to content

Law of Cosines Calculator

Type two sides and the angle between them to get the third side…

Type two sides and the angle between them to get the third side, or three sides to get the angles. The law of cosines works for every triangle.

°
°
°

Two sides and the angle between them (SAS). Each angle sits opposite the side with its letter.

More optionsNo length unit

Length unit

A label for the answers; the maths is the same in any unit.

ExampleSide c

7

The triangle is obtuse and scalene, with one angle over 90°.

Type your own values, or drag a corner.

a 3b 5c 7A21.8°B38.2°C120°

Drag the round handles on the corners.

Keep fixed while dragging
Every side and angle of the triangle
SideOpposite angle
a = 3givenA = 21.787°
b = 5givenB = 38.213°
c = 7C = 120°given

Area 15√3/4 ≈ 6.4952Perimeter 15

Area, perimeter, heights and circlesEvery other measurement of this triangle
More measurements of the triangle
Area15√3/4 ≈ 6.4952 square units
Perimeter15
Height to side a4.3301
Height to side b2.5981
Height to side c1.8558
Inradius (inscribed circle)0.866
Circumradius (circle through the corners)4.0415
Angles in radiansA 0.3803, B 0.6669, C 2.0944
How this works: 6 sources,

How this works

Method

The law of cosines extends Pythagoras to every triangle: c² = a² + b² − 2ab·cos C. When C is 90°, cos C is 0 and it is the Pythagorean theorem; when C is wider, cos C is negative and the third side comes out longer than Pythagoras would say, and when it is narrower, shorter. Full method

How it’s tested

4 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.

Privacy

On your device. Nothing you enter or open leaves this browser. About privacy labels

Changes

  • First published: any three values, both triangles in the ambiguous case, exact answers, worked steps, a drawing you can drag and seven focused pages.

Every change on What’s new

How we make toolsReport a mistake

How the law of cosines works

The law of cosines extends Pythagoras to every triangle: c² = a² + b² − 2ab·cos C. When C is 90°, cos C is 0 and it is the Pythagorean theorem; when C is wider, cos C is negative and the third side comes out longer than Pythagoras would say, and when it is narrower, shorter.

With two sides and the angle between them (SAS), it gives the third side at once. For b = 8, c = 11 and A = 37°: a² = 64 + 121 − 2 × 8 × 11 × cos 37° ≈ 44.4402, so a ≈ 6.6663. Then either law finds the other angles; using the law of cosines again for the smaller one avoids the ambiguity of the sine.

With all three sides (SSS) it runs the other way: cos C = (a² + b² − c²) ÷ 2ab. Every cosine between −1 and 1 belongs to exactly one angle between 0° and 180°, so, unlike the law of sines, there is never a second answer to check. The example triangle above, with sides 3 and 5 at 120°, has a third side of exactly 7, because cos 120° = −1/2.

c² = a² + b² − 2ab·cos C

Third side for sides 5 and 8 at different angles

The side opposite angle A when b = 5 and c = 8, for A from 15° to 165°, exact where cos A is a known surd.

The side opposite angle A when b = 5 and c = 8, for A from 15° to 165°, exact where cos A is a known surd.
Angle Acos Aa²Side aExact
15°(√2 + √6)/411.72593.4243√(89 − 20√2 − 20√6)
30°√3/219.7184.4405√(89 − 40√3)
45°√2/232.43155.6949√(89 − 40√2)
60°1/2497—
75°(√6 − √2)/468.29458.264√(89 + 20√2 − 20√6)
90°0899.434√89
105°(√2 − √6)/4109.705510.474√(89 − 20√2 + 20√6)
120°−1/212911.3578√129
135°−√2/2145.568512.0652√(89 + 40√2)
150°−√3/2158.28212.581√(89 + 40√3)
Show all 11 rows
165°(−√2 − √6)/4166.274112.8947√(89 + 20√2 + 20√6)

Common questions

What is the law of cosines used for in real life?

Anywhere two distances and the angle between them are known: the straight-line distance between two places from a surveyor’s readings, the third side of a roof truss, or how far apart two ships are after sailing on different headings from the same port.

Is the law of cosines the same as the cosine rule?

Yes. British schools call it the cosine rule, American ones the law of cosines. It is written for any side: a² = b² + c² − 2bc·cos A, and the same pattern for b and c.

Why do I get no triangle from three sides?

Because the longest side is at least as long as the other two together, so they can’t meet. The cosine would come out below −1. Sides 2, 3 and 6 fail: 2 + 3 = 5 is less than 6.