Skip to content
MoneyDeck

Law of Cosines Calculator

Solve any triangle from three sides (SSS) or two sides and an angle (SAS)

Updated · Free, no signup

°

Solution

c = 6.245, A = 43.9°, B = 76.1°

Side a

5

Side b

7

Side c

6.245

Angle A

43.8979 °

Angle B

76.1021 °

Angle C

60 °

Area

15.1554

Perimeter

18.245

  • This is an acute triangle — all three angles are under 90°.
  • c² = 5² + 7² − 2·5·7·cos 60° = 39

Angles of the triangle

About the Law of Cosines Calculator

This law of cosines calculator solves a triangle completely when you know either all three sides (SSS) or two sides and the angle between them (SAS). It returns every side, every angle, the area and the perimeter, so you can check homework, lay out a roof truss or work out the distance between two points separated by a known angle.

The law of cosines is the tool to use when the law of sines cannot get started — that is, when you do not yet know any matching side–angle pair. With SSS it finds the largest angle first without any ambiguity, and with SAS it finds the third side directly. Once one angle is known, the remaining angles follow.

Angles are entered and reported in degrees. The calculator follows the usual labelling: side a is opposite angle A, side b opposite angle B and side c opposite angle C. It checks the triangle inequality and warns you if three sides cannot form a triangle.

How to use the law of cosines calculator

  1. 1Choose SAS if you know two sides and the angle between them, or SSS if you know all three sides.
  2. 2Enter the side lengths in any single unit (cm, m, ft…).
  3. 3For SAS, enter the included angle C in degrees.
  4. 4Read the missing side and angles, plus the triangle’s area and perimeter.

Formula and method

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

The law of cosines generalises the Pythagorean theorem to every triangle. The extra term −2ab·cos C corrects for the angle between sides a and b: when C is 90°, cos C is 0 and the formula collapses to c² = a² + b².

For SAS the calculator plugs the two sides and the included angle into the first form to get side c. For SSS it rearranges to the second form to get angle C. In both cases angle A is then found with cos A = (b² + c² − a²) ÷ (2bc), which is unambiguous because arccos returns a single angle between 0° and 180°, and angle B is 180° − A − C. Area is ½·a·b·sin C.

a, b, c
Side lengths (any consistent unit)
A, B, C
Angles opposite sides a, b and c, in degrees

Worked examples

SAS: sides 5 and 7 with a 60° angle

c² = 25 + 49 − 2·5·7·cos 60° = 74 − 35 = 39, so c = √39 ≈ 6.245. Then cos A = (49 + 39 − 25) ÷ (2·7·6.245) gives A ≈ 43.90°, and B = 180° − 43.90° − 60° ≈ 76.10°. The area is ½·5·7·sin 60° ≈ 15.16.

SSS: the 3-4-5 triangle

cos C = (9 + 16 − 25) ÷ 24 = 0, so C = 90° — the classic right triangle. cos A = (16 + 25 − 9) ÷ 40 = 0.8 gives A ≈ 36.87°, leaving B ≈ 53.13°. The area is ½·3·4 = 6.

SAS: surveying across a pond

Two measured distances of 120 m and 95 m meet at 110°. c² = 14,400 + 9,025 − 2·120·95·cos 110° ≈ 31,223, so the distance across the pond is about 176.70 m, and the other two angles are about 39.65° and 30.35°.

Frequently asked questions

When should I use the law of cosines instead of the law of sines?+

Use the law of cosines when you know three sides (SSS) or two sides and the angle between them (SAS). The law of sines needs a known side together with its opposite angle, which you do not have in those two cases.

Does the law of cosines have an ambiguous case?+

No. Arccos returns one angle between 0° and 180°, so SSS and SAS always give a single triangle. The ambiguous case only arises with the law of sines for SSA inputs.

How is the law of cosines related to the Pythagorean theorem?+

When the angle C is 90°, cos C = 0 and c² = a² + b² − 2ab·cos C becomes c² = a² + b². The law of cosines is the general version that works for any angle.

Why does the calculator say my sides are not a triangle?+

Three lengths only form a triangle if each one is shorter than the sum of the other two (the triangle inequality). For example 2, 3 and 6 fail because 2 + 3 is less than 6.

Can I use radians?+

The calculator works in degrees. To convert radians to degrees multiply by 180/π (about 57.2958), or use the angle converter first.

Related tools