Skip to content
M2TOOLKIT

Calculators guide

How to Solve Any Triangle: Which Rule to Use and When

Pick the right rule for what you know — law of cosines, law of sines or Pythagoras — with worked examples, the SSA ambiguous case and quick answer checks.

By M2Toolkit Editorial TeamPublished 8 min read

Quick answer

Match the rule to what you know. Three sides, or two sides with the angle between them: use the law of cosines. Two angles and any side: subtract from 180° for the third angle, then use the law of sines. A right angle: Pythagoras and SOH-CAH-TOA.

The only tricky case is two sides and an angle that isn't between them (SSA), which can give two different triangles. The Triangle Calculator handles all of these and draws the result to scale.

“Solving” a triangle means finding all three sides and all three angles from the three you're given. The method depends entirely on which three you have, and most wrong answers come from picking the wrong rule or labelling the sides inconsistently. Here's how to choose, with worked numbers.

First, label it consistently

Call the angles A, B and C, and name each side after the angle opposite it: side a faces angle A, side b faces B, side c faces C. Every formula below assumes this. If your textbook diagram labels sides differently, relabel before you start — it's the single most common source of errors.

Which rule to use

You knowNameStart withThen
3 sidesSSSLaw of cosines for one angleLaw of cosines again (or 180° rule)
2 sides + angle between themSASLaw of cosines for the third sideLaw of cosines for a second angle
2 angles + side between themASAThird angle = 180° − the other twoLaw of sines for both sides
2 angles + a side not between themAASThird angle = 180° − the other twoLaw of sines
2 sides + angle not between themSSALaw of sinesCheck for a second solution
Right triangle, any 2 values—Pythagoras or sin/cos/tan90° − the known acute angle
3 anglesAAANot solvableShape is fixed, size isn't — you need a side

The two rules you need

Law of cosines: c² = a² + b² − 2ab·cos C
Law of sines: a ÷ sin A = b ÷ sin B = c ÷ sin C

The law of cosines is Pythagoras with a correction term: when C = 90°, cos C = 0 and it becomes c² = a² + b². Rearranged, it gives an angle from three sides: cos C = (a² + b² − c²) ÷ 2ab. The law of sines links each side to the angle opposite it, so you need at least one matching side–angle pair to use it.

Prefer the law of cosines when finding an angle if you can. An inverse cosine gives a unique angle between 0° and 180°, while an inverse sine only returns angles up to 90° — the root of the ambiguous case below.

Worked example: two sides and the angle between them

A triangular garden bed has sides of 5 m and 7 m meeting at 49°. How long is the third side, and what are the other angles?

  1. 1
    Third side: c² = 5² + 7² − 2 × 5 × 7 × cos 49° = 25 + 49 − 70 × 0.6561 = 28.07, so c ≈ 5.30 m.
  2. 2
    Angle A (opposite the 5 m side): cos A = (7² + 5.30² − 5²) ÷ (2 × 7 × 5.30) → A ≈ 45.41°.
  3. 3
    Angle B = 180° − 49° − 45.41° ≈ 85.59°.
  4. 4
    Area = ½ × 5 × 7 × sin 49° ≈ 13.21 m² — handy for working out soil or mulch.
Try the free Triangle CalculatorChoose SAS, enter 5, 7 and 49° to see these values, the diagram and every step.

The ambiguous case (SSA): zero, one or two triangles

Suppose you know side a, side b and angle A, where A is not between them. Picture side b fixed with angle A at one end, and side a hanging from the other end like a swinging arm. Depending on its length, it reaches the base line not at all, once, or in two places. Compare a with the height h = b·sin A:

If angle A is acute and…Number of triangles
a < hNone — side a is too short to reach
a = hOne, with a right angle at B
h < a < bTwo — B and 180° − B both work
a ≥ bOne

With a = 7, b = 10 and A = 40°: h = 10 × sin 40° ≈ 6.43, which is less than 7, which is less than 10 — so there are two triangles. The sine rule gives sin B = 10 × sin 40° ÷ 7 ≈ 0.918, so B ≈ 66.67° or 113.33°. The first gives C ≈ 73.33° and c ≈ 10.43; the second gives C ≈ 26.67° and c ≈ 4.89. Both are valid; an exam usually wants both, and a real-world problem needs extra information to choose.

If angle A is 90° or more, there is one triangle when a > b and none otherwise.

Three ways to find the area

Area = ½ × base × height
Area = ½ab·sin C (two sides and the angle between them)
Heron's formula: Area = √(s(s − a)(s − b)(s − c)), where s = (a + b + c) ÷ 2

Heron's formula is the one to reach for when you've measured three sides and no angles — the usual situation when surveying a plot with a tape. For sides 7, 8 and 9: s = 12 and the area is √(12 × 5 × 4 × 3) = √720 ≈ 26.83. If you only need area, perimeter or a right-angled triangle, the Area Calculator and Pythagorean Theorem Calculator are quicker.

A practical one: roof rafters

A roof spans 7.2 m with a 35° pitch, so each half is a right triangle with a horizontal run of 3.6 m. The rise is 3.6 × tan 35° ≈ 2.52 m, and the rafter length (before overhang) is 3.6 ÷ cos 35° ≈ 4.39 m. In the calculator, choose Right, enter b = 3.6 and A = 35°.

How to check your answer

  • Angles add up to 180° (allow for rounding).
  • The longest side is opposite the largest angle, and the shortest opposite the smallest.
  • Any two sides add up to more than the third.
  • Plug your results into the law of sines: a ÷ sin A, b ÷ sin B and c ÷ sin C should all be equal.
  • Your calculator is in degrees, not radians — sin 40 in radian mode is about 0.745 instead of 0.643.

Frequently asked questions

Can you solve a triangle with only two values?

Only a right triangle, because the right angle counts as the third value. Any other triangle needs three measurements including at least one side.

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

Use the law of sines when you know a side and the angle opposite it (ASA, AAS, SSA). Use the law of cosines when you know all three sides, or two sides and the angle between them.

Why does my calculator give a different angle from the textbook?

Usually it's set to radians, or you're in the ambiguous case and the book wants the obtuse answer (180° minus what sin⁻¹ returns).

About this guide

The people who build M2Toolkit's tools write these guides. Every formula and example in an article is checked against the matching tool, and articles are reviewed when the tool changes.

Tools mentioned in this guide