Law of Sines and Cosines: Formulas, When to Use Each, and Worked Examples

The law of sines and cosines is the toolkit for solving triangles that don’t have a right angle. Give either law enough information (three measurements, including at least one side) and you can find every missing side and angle.

The hard part is knowing which law to use. That depends on what you were given, so this page starts with a table that answers it in about ten seconds. After that you’ll get each law with a derivation, worked examples, the ambiguous case (SSA) that catches almost everyone once, the inverse trig functions you need to find angles, the trigonometric area formula, and four fully solved triangle problems.

Quick answer: Law of sines: a ÷ sinA = b ÷ sinB = c ÷ sinC. Law of cosines formula: c² = a² + b² − 2ab cosC. Use the law of sines when you have a matching side and angle pair. Use the law of cosines when you don’t.

Law of sines and cosines shown on a scalene triangle

Both law of sines and cosines use the same labelling, so get this straight first. Angles are capital letters: A, B, C. Each side is the matching lowercase letter and sits opposite its angle. Side a is opposite angle A, side b is opposite angle B, and side c is opposite angle C.

Getting this wrong is the single most common source of wrong answers. Always check that the side you use is opposite the angle you use.

The two laws are also known as the sine rule and the cosine rule, especially in the UK and many other countries. They are the same thing.

Triangle with angles A, B, C and the sides a, b, c opposite them
What you knowShort nameWhich LawNotes
Two angles and any sideASA or AASLaw of sinesFind the third angle first (angles add up to 180°)
Two sides and an angle opposite one of themSSALaw of sinesThe ambiguous case: there may be 0, 1 or 2 triangles
Two sides and the angle between themSASLaw of cosinesFind the third side first
All three sidesSSSLaw of cosinesFind the largest angle first
A right angle plus two other piecesRight triangleSOH CAH TOASee the trigonometric ratios

Here’s the rule of thumb. The law of sines needs a matching pair: a side and the angle opposite it. If you have one, use the law of sines. If you don’t, use the law of cosines.

Three angles alone (AAA) can’t give you side lengths. They only tell you the shape of the triangle, not its size.

The law of sines says that in any triangle, the ratio of a side to the sine of its opposite angle is the same for all three sides:

a ÷ sinA = b ÷ sinB = c ÷ sinC

You can also flip it: sinA ÷ a = sinB ÷ b = sinC ÷ c. Flipped is handy when you’re solving for an angle. That common ratio has a meaning, too. It equals 2R, where R is the radius of the circle that passes through all three corners of the triangle.

Draw the altitude from corner C down to side c. Call its length h. This splits the triangle into two right triangles. In the left one, h = b sinA. In the right one, h = a sinB. Both equal h, so:

b sinA = a sinB

Divide both sides by sinA sinB and you get a ÷ sinA = b ÷ sinB. Drop an altitude from a different corner and the same steps link c to the other two sides.

Problem: In triangle ABC, A = 40°, B = 65° and a = 12. Find C, b and c.

  1. Third angle: C = 180° − 40° − 65° = 75°
  2. Side b: b = a × sinB ÷ sinA = 12 × sin65° ÷ sin40° = 12 × 0.9063 ÷ 0.6428 ≈ 16.92
  3. Side c: c = a × sinC ÷ sinA = 12 × sin75° ÷ sin40° = 12 × 0.9659 ÷ 0.6428 ≈ 18.03

Sense check: the largest angle (75°) is opposite the longest side (18.03), and the smallest angle (40°) is opposite the shortest side (12). That’s how it should be.

A habit worth keeping: always work from the values you were given, not from numbers you calculated, so a rounding error can’t carry forward.

Triangle with an altitude h used to prove the law of sines

The ambiguous case is what you get when you know two sides and an angle that is not between them (SSA). Sometimes this gives one triangle, sometimes two, and sometimes none.

Why it happens. Imagine side a as a gate hinged at the end of side b, swinging toward the base. Depending on how long it is, the gate may miss the base, touch it once, or cross it twice. On paper: sine is positive in both the first and second quadrants, so sinB = 0.8 is satisfied by B = 53.1° and by B = 180° − 53.1° = 126.9°. Your calculator only gives you the first one.

How to check. Suppose you know angle A, and sides a (opposite A) and b. Calculate the height h = b sinA, then use this table.

Angle ACompared withResult
Acute (under 90°)a < hNo triangle (side a can’t reach the base)
Acutea = hOne triangle (right-angled)
Acuteh < a < bTwo triangles
Acutea ≥ bOne triangle
Right or obtusea ≤ bNo triangle
Right or obtusea > bOne triangle

A shortcut that works every time: solve sinB = (b sinA) ÷ a. If the result is more than 1, there’s no triangle. If it’s less than 1, find B₁ = arcsin(result) and B₂ = 180° − B₁. Keep B₂ only if A + B₂ is less than 180°.

Problem: A = 40°, a = 8, b = 10. Solve the triangle.

  1. Height: h = 10 × sin40° ≈ 6.43. Since 6.43 < 8 < 10, there are two triangles.
  2. sinB = 10 × sin40° ÷ 8 ≈ 0.8035
  3. B₁ = arcsin(0.8035) ≈ 53.46°, and B₂ = 180° − 53.46° = 126.54°
  4. Check B₂: A + B₂ = 40° + 126.54° = 166.54°, which is under 180°. Both are valid.
Triangle 1Triangle 2
Angle B53.46°126.54°
Angle C180° − 40° − 53.46° = 86.54° 180° − 40° − 126.54° = 13.46°
side c8 × sin86.54° ÷ sin40° ≈ 12.42 8 × sin13.46° ÷ sin40° ≈ 2.90

Problem: A = 50°, a = 5, b = 10.

sinB = 10 × sin50° ÷ 5 ≈ 1.53. Sine can never be greater than 1, so no triangle exists. Side a is simply too short to reach the base.

Problem: A = 35°, a = 10, b = 7.

sinB = 7 × sin35° ÷ 10 ≈ 0.4015, so B₁ ≈ 23.67°. The other candidate is B₂ = 180° − 23.67° = 156.33°. But 35° + 156.33° = 191.33°, which is over 180°. So only B = 23.67° works. Here a ≥ b, which matches the table.

How to avoid the ambiguity. If you have a choice, use the law of cosines to find the missing side first. It never gives two answers. Or, when you use the law of sines to find an angle, find the one opposite the smaller side. A smaller side’s opposite angle can’t be obtuse, so there’s no second option.

The law of cosines formula links all three sides to one angle:

c² = a² + b² − 2ab cosC

  • a² = b² + c² − 2bc cosA
  • b² = a² + c² − 2ac cosB

The same pattern works for each corner:

To find an angle, rearrange:

  • cosC = (a² + b² − c²) ÷ (2ab)
  • cosA = (b² + c² − a²) ÷ (2bc)
  • cosB = (a² + c² − b²) ÷ (2ac)

Draw the altitude from corner B down to side b (the side AC), meeting it at point D. In the right triangle with hypotenuse c, the altitude is c sinA and the part of the base next to A is c cosA. That leaves b − c cosA for the other part of the base.

Apply Pythagoras to the second right triangle:

a² = (c sinA)² + (b − c cosA)² a² = c² sin²A + b² − 2bc cosA + c² cos²A a² = b² + c²(sin²A + cos²A) − 2bc cosA

Since sin²A + cos²A = 1, you get a² = b² + c² − 2bc cosA. (That Pythagorean identity is explained on the trigonometric identities page.)

If the angle is 90°, then cos90° = 0 and the extra term disappears: c² = a² + b². So the law of cosines is the Pythagorean theorem with a correction term for the angle. It also tells you what kind of angle you have:

  • If C is acute, c² is smaller than a² + b².
  • If C is obtuse, c² is larger than a² + b².

Problem: a = 7, b = 9, C = 52°. Find c, A and B.

  1. Side c: c² = 7² + 9² − 2 × 7 × 9 × cos52° = 49 + 81 − 126 × 0.6157 = 130 − 77.57 = 52.43, so c ≈ 7.24
  2. Angle A: cosA = (b² + c² − a²) ÷ (2bc) = (81 + 52.43 − 49) ÷ (2 × 9 × 7.24) = 84.43 ÷ 130.33 ≈ 0.6478, so A ≈ 49.63°
  3. Angle B: B = 180° − 52° − 49.63° = 78.37°

Problem: A triangle has sides a = 5, b = 7 and c = 9. Find all three angles.

  1. Largest angle first, which is C (opposite the longest side): cosC = (25 + 49 − 81) ÷ (2 × 5 × 7) = −7 ÷ 70 = −0.1, so C ≈ 95.74°
  2. cosA = (49 + 81 − 25) ÷ (2 × 7 × 9) = 105 ÷ 126 ≈ 0.8333, so A ≈ 33.56°
  3. B = 180° − 95.74° − 33.56° = 50.70°

Why start with the largest angle? Because cosine gives a negative number for obtuse angles. If the largest angle isn’t obtuse, neither of the others can be, so you can use the law of sines safely for the rest if you want to.

Triangle with altitude splitting the base into c cos A and b minus c cos A

To find an angle from a ratio, you use an inverse trig function. Every time you wrote B = arcsin(0.8035) above, that was one.

Function Also
Written
DomainRange
(degree)
Range
(radian)
arcsinsin⁻¹−1 to 1−90° to 90°−π/2 to π/2
arccoscos⁻¹1 to 10° to 180°0 to π
arctantan⁻¹All real numbers−90° to 90° (excluding ends)π/2 to π/2 (excluding ends)

A few examples: arcsin(0.5) = 30°, arccos(−0.5) = 120°, arctan(1) = 45°.

Why does this matter for triangles? Because of the ranges.

  • arcsin only returns angles up to 90°. It can never give you an obtuse angle. That’s exactly why the law of sines has an ambiguous case. You must check whether 180° − B is also valid.
  • arccos covers 0° to 180°. It can return an obtuse angle correctly, which is why the law of cosines has no ambiguity.

Two cautions. First, sin⁻¹x does not mean 1 ÷ sinx. It means the inverse function. Second, make sure your calculator is in degree mode when your triangle is in degrees. For identities such as arcsin x + arccos x = 90°, see the inverse trig identities section of the identities page.

Graphs of arcsin, arccos and arctan with their ranges marked

When you know two sides and the angle between them (SAS), you can find the area without finding the height first:

Area = ½ × a × b × sinC

The same formula works with any pair of sides and the angle between them: ½ × b × c × sinA, or ½ × a × c × sinB.

Where it comes from. The usual area formula is ½ × base × height. Take a as the base. The height from the opposite corner is h = b sinC. Substitute it and you get ½ × a × b sinC.

Example: With a = 7, b = 9 and C = 52°:

Area = ½ × 7 × 9 × sin52° = 31.5 × 0.7880 ≈ 24.82 square units

If you know two angles and one side (ASA), you can first find a second side with the law of sines, or use the combined version: Area = a² sinB sinC ÷ (2 sinA).

You don’t have to do this by hand. The Triangle Area Calculator takes two sides and the included angle and shows each step. If you know all three sides instead, Heron’s formula is quicker, and it’s covered on the same calculator page.

There’s a third law that people rarely use. The law of tangents says:

(a − b) ÷ (a + b) = tan((A − B)/2) ÷ tan((A + B)/2)

It comes straight from the law of sines combined with the sum-to-product identities, which are in the double and half angle formulas guide. It’s useful when you know two sides and the included angle and want the other two angles directly. Most people skip it and use the law of cosines instead, and that’s fine.

Triangle with two sides, included angle C and height h = b sin C

Problem 1. Distance across a river (law of sines)

Two surveyors stand at points A and B on one riverbank, 120 m apart. They both look at a tree T on the opposite bank. The angle at A (between AB and the tree) is 62°, and the angle at B is 71°. How far is the tree from A?

  • Angle at the tree: T = 180° − 62° − 71° = 47°
  • Distance AT is opposite the 71° angle: AT = 120 × sin71° ÷ sin47° = 120 × 0.9455 ÷ 0.7314 ≈ 155.1 m
  • For completeness, BT = 120 × sin62° ÷ sin47° ≈ 144.9 m

Problem 2. A ship’s distance from port (law of cosines, SAS)

A ship leaves a harbour and sails 40 km on a bearing of 060°. It then turns and sails 30 km on a bearing of 140°. How far is it from the harbour?

  • The two legs are 60° and 140° from north, so the angle between them at the turning point is 180° − (140° − 60°) = 100°
  • d² = 40² + 30² − 2 × 40 × 30 × cos100° = 1600 + 900 + 2400 × 0.1736 = 2916.8
  • d ≈ 54.0 km

Problem 3. Angles of a triangular plot (law of cosines, SSS)

A triangular plot has sides of 120 m, 150 m and 200 m. Find its three angles.

  • Largest angle, opposite 200 m: cos = (120² + 150² − 200²) ÷ (2 × 120 × 150) = −3100 ÷ 36000 ≈ −0.0861, so the angle is 94.94°
  • Opposite 120 m: cos = (150² + 200² − 120²) ÷ (2 × 150 × 200) = 48100 ÷ 60000 ≈ 0.8017, so the angle is 36.71°
  • The last angle is 180° − 94.94° − 36.71° = 48.35°

Problem 4. Area of a plot from two sides and an angle (trig area formula)

Two boundaries of a plot are 85 m and 110 m long, and the angle between them is 68°. Find the area.

  • Area = ½ × 85 × 110 × sin68° = 4675 × 0.9272 ≈ 4,335 m²

You can check any of these on the Triangle Area Calculator.

  • Matching a side with the wrong angle. Each side must be opposite the angle in the same ratio.
  • Assuming SSA has one answer. Always test for a second triangle with 180° − B.
  • Using the law of sines when there’s no matching pair. With SAS and SSS, use the law of cosines first.
  • Calculator in radian mode. If your answers look absurd, check this first.
  • Rounding too early. Keep at least four decimal places until the final step.
  • Forgetting the 2ab in the law of cosines. It’s −2ab cosC, and it’s easy to drop the 2.
  • Skipping the final sense check. Angles must add to 180°, and the longest side must face the largest angle.

When do I use the law of sines and cosines?

Use the law of sines when you have a side and its opposite angle plus one more piece of information (ASA, AAS or SSA). Use the law of cosines when you have SAS or SSS.

Can I use the law of cosines on a right triangle?

Yes. When the angle is 90°, cos90° = 0, and the formula turns into the Pythagorean theorem.

What are the sine rule and cosine rule

They’re the same as the law of sines and the law of cosines. Different countries just use different names.

Why does arcsin only give acute angles?

Because its range is limited to −90° to 90°, so that the inverse function has exactly one output. That’s why you must check the obtuse option yourself.

If any of the labels or identities here feel shaky, review the trigonometric ratios and identities. For the angle formulas used to derive and extend these laws, see the double and half angle formulas.

Related calculators: Triangle Area Calculator · Area Calculator