Law of Cosines Calculator

Find a triangle's missing side from two sides and an angle, or its three angles from three sides, with the full law of cosines working.

The angle between sides a and b
Side a
8 ftgiven
Side b
11 ftgiven
Side c
6.666345 ft
Angle A
46.2375°0.806996 rad
Angle B
96.7625°1.688824 rad
Angle C
37°given
Perimeter
25.666345 ft
Area
26.479861 ft2
Triangle type
Scalene, obtuse
Third side c6.666345 ft

Show the work

  1. Law of cosines for the third side: c2 = a2 + b2 − 2ab cos C = 82 + 112 − 2 × 8 × 11 × cos 37° = 44.44015
  2. c = √44.44015 = 6.666345
  3. Law of cosines for A: cos A = (b2 + c2 − a2) ÷ 2bc = 0.691671, so A = 46.2375°
  4. Angle sum: B = 180° − A − C = 180° − 46.2375° − 37° = 96.7625°
  5. Area = ½ bc sin A = ½ × 11 × 6.666345 × sin 46.2375° = 26.479861 ft2
a = 8b = 11c = 6.66646.2°96.8°37°ABCunits: ft
Heights, medians, bisectors and circles
MeasureValue
Height to side a (hₐ)6.619965 ft
Height to side b (h_b)4.81452 ft
Height to side c (h_c)7.944342 ft
Median to side a (mₐ)8.168236 ft
Median to side b (m_b)4.895924 ft
Median to side c (m_c)9.021639 ft
Bisector of angle A (tₐ)7.634958 ft
Bisector of angle B (t_b)4.830206 ft
Bisector of angle C (t_c)8.784472 ft
Inradius (r)2.063392 ft
Circumradius (R)5.538533 ft

The law of cosines is the Pythagorean theorem extended to every triangle. Give it two sides and the angle between them and it returns the third side; give it three sides and it returns every angle. This calculator also solves two sides with a non-included angle, as a quadratic.

How to use the law of cosines calculator

  1. In What do you want to find?, choose the third side from two sides and the angle between them (SAS), all three angles from three sides (SSS), or the third side from two sides and an angle not between them (SSA).
  2. Enter Side a and Side b, then Angle C (between a and b) for SAS, Side c for SSS, or Angle A (opposite side a) for SSA.
  3. Choose the Units (feet by default) and the Angle unit, degrees or radians.
  4. The headline is the third side c (SAS and SSA) or the three angles (SSS). The tape adds every side and angle, the perimeter, area and triangle type, plus a table of heights, medians and radii. If SSA has two answers, both triangles appear side by side.

Law of cosines formulas

c2 = a2 + b2 − 2ab cos C
cos C = (a2 + b2 − c2) ÷ 2ab

For SSA, with angle A opposite side a:

c2 − (2b cos A)c + (b2 − a2) = 0  ⇒  c = b cos A ± √(a2 − b2 sin2 A)

How it generalizes the Pythagorean theorem

When C = 90°, cos C = 0 and the formula collapses to c² = a² + b²: sides 3 and 4 at a right angle give c = 5. The term −2ab cos C corrects for a corner that isn’t square. Below 90° that term is negative, so the third side is shorter than the Pythagorean value; above 90° it is positive and the side is longer. Euclid stated the result geometrically in Book II, Propositions 12 and 13, of the Elements.

Worked example: distance between two ships

From a lighthouse, ship P is 9 km away on a bearing of 035° and ship Q is 14 km away on a bearing of 110°, so the sight lines are 110° − 35° = 75° apart. Choose SAS and enter Side a = 9, Side b = 14 and Angle C = 75, in km.

  • c² = 9² + 14² − 2 × 9 × 14 × cos 75° ≈ 277 − 65.22 = 211.78
  • Distance between the ships: c = √211.78 ≈ 14.55 km
  • Remaining angles: about 36.68° at Q, opposite the 9 km side, and 68.32° at P.

The same setup gives a hiker’s distance from the start: 3 mi, then 2 mi with a 110° angle between the legs, leaves you about 4.14 mi away.

Law of cosines or law of sines?

You know Start with Why
SAS Law of cosines No side is paired with its opposite angle
SSS Law of cosines Only sides are known
AAS or ASA Law of sines The angle sum completes a matched pair
SSA Either Both reveal 0, 1 or 2 triangles

Tip: find the largest angle first

If you solve SSS by hand and switch to the law of sines after one angle, find the largest angle (opposite the longest side) with the law of cosines first. An inverse cosine returns any angle from 0° to 180°; an inverse sine only returns up to 90°. With sides 7, 9 and 14 ft, cos C = (49 + 81 − 196) ÷ 126 ≈ −0.5238, so C ≈ 121.59°. Had you found A ≈ 25.21° first and used the law of sines for C, you would get sin C ≈ 0.8518 and an inverse sine of 58.41°, the supplement of the true answer. Once the largest angle is known, the other two must be acute, so either law is safe. The calculator uses inverse cosines and the angle sum, so it avoids this trap.

For very thin triangles, a² + b² − 2ab cos C subtracts nearly equal numbers and magnifies rounding error; the equivalent c² = (a − b)² + 4ab sin²(C ÷ 2) avoids that.

The SSA case as a quadratic

The SSA default, a = 8 ft, b = 11 ft and A = 40°, gives c² − 16.853c + 57 = 0. The discriminant is about 56.02, so c = (16.853 ± 7.485) ÷ 2: either 12.17 ft or 4.68 ft. Both roots are positive, so two triangles fit, with B ≈ 62.11° or 117.89°. When a is longer than b, the constant b² − a² is negative, the roots have opposite signs and only one triangle exists. A negative discriminant means side a is too short to close the triangle.

See also the law of sines calculator and, for right triangles, the Pythagorean theorem calculator.

Frequently asked questions

What is the law of cosines?

For any triangle, c² = a² + b² − 2ab cos C, where C is the angle between sides a and b. It works for acute, right and obtuse triangles, and it becomes the Pythagorean theorem when C is 90°.

How do I find an angle from three sides?

Rearrange the formula to cos C = (a² + b² − c²) ÷ 2ab, then take the inverse cosine. With sides 7, 9 and 14, cos C ≈ −0.5238, so the angle opposite the 14 side is about 121.59°.

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

Use it when you know two sides and the angle between them (SAS) or all three sides (SSS). The law of sines needs a side paired with its opposite angle, and neither of those cases gives you one.

Can the law of cosines solve the SSA case?

Yes. Writing the formula around the known angle A gives a quadratic in the unknown side: c² − (2b cos A)c + (b² − a²) = 0. Two positive roots mean two triangles, one positive root means one, and no real root means none.

What if my three sides cannot form a triangle?

The two shorter sides must add up to more than the longest one. If they don't, the calculator says so, showing the shorter sides' total next to the longest side, instead of returning angles.

Last reviewed October 2026 by the CalcFluent editorial team. How we check our calculators.