Law of sines or law of cosines: which one do you use?

Use the law of cosines when you know three sides (SSS) or two sides and the angle between them (SAS). Use the law of sines when you know two angles and a side (ASA or AAS). With two sides and an angle that is not between them (SSA), the law of sines works, but the data can fit no triangle, one or two, so count them first. If one angle is 90°, the Pythagorean theorem with sine, cosine and tangent is quicker than either law.

What you knowMethodTriangles
SSS: three sidesLaw of cosines for the largest angle (opposite the longest side), then either lawOne, if every pair of sides adds up to more than the third
SAS: two sides and the angle between themLaw of cosines for the third side, then the law of sines for the angle opposite the shorter known sideOne
ASA or AAS: two angles and any sideThird angle = 180° minus the other two, then the law of sinesOne, if the two angles total less than 180°
SSA: two sides and an angle opposite one of themCompare the side opposite the angle with the height h=bsin⁡Ah = b \sin A, then the law of sinesNone, one or two
AAA: three anglesCan’t be solved: angles fix the shape, not the sizeInfinitely many

You always need at least one side. The law of sines needs a known side together with its opposite angle. SSS and SAS don’t supply that pair, so they start with the law of cosines.

What do the two laws say?

The law of sines says that each side divided by the sine of its opposite angle gives the same number for all three sides:

asin⁡A=bsin⁡B=csin⁡C\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}

The law of cosines is the Pythagorean theorem with a correction term for the angle between two sides:

a2=b2+c2−2bccos⁡Aa^2 = b^2 + c^2 - 2bc\cos A

Label the triangle so that each side has the same letter as the angle across from it: side aa is opposite angle AA, bb is opposite BB, and cc is opposite CC. The formulas won’t warn you if you pair an angle with the wrong side, so write the labels on a sketch first.

To find an angle from three sides, rearrange the law of cosines: cos⁡A=b2+c2−a22bc\cos A = \dfrac{b^2 + c^2 - a^2}{2bc}. Cycle the letters for BB and CC. Once the triangle is solved, its area is 12bcsin⁡A\tfrac12 bc \sin A, or from the three sides alone, Heron’s formula s(s−a)(s−b)(s−c)\sqrt{s(s-a)(s-b)(s-c)} with s=(a+b+c)/2s = (a + b + c)/2.

Why does the law of sines sometimes give the wrong angle?

Because an angle and its supplement have the same sine. Both sin⁡49.86∘\sin 49.86^\circ and sin⁡130.14∘\sin 130.14^\circ equal 0.7645, and arcsin only returns the acute one. Cosine is negative for obtuse angles, so arccos returns the correct angle anywhere from 0° to 180°.

Example measurements: a triangular garden bed has edges of 4 m and 9 m that meet at 30°. That is SAS with b=4b = 4, c=9c = 9 and A=30∘A = 30^\circ.

  1. Third side: a2=42+92−2(4)(9)cos⁡30∘a^2 = 4^2 + 9^2 - 2(4)(9)\cos 30^\circ =97−62.354=34.646= 97 - 62.354 = 34.646, so a=5.886a = 5.886 m.
  2. The trap: the law of sines for angle CC, opposite the 9 m edge, gives sin⁡C=9sin⁡30∘/5.886=0.7645\sin C = 9 \sin 30^\circ / 5.886 = 0.7645, and arcsin returns 49.86°. That would make B=100.14∘B = 100.14^\circ. Both are wrong.
  3. The fix: use the law of cosines. cos⁡C=34.646+16−812×5.886×4=−0.6446\cos C = \dfrac{34.646 + 16 - 81}{2 \times 5.886 \times 4} = -0.6446, so C=130.14∘C = 130.14^\circ.
  4. Last angle: B=180∘−30∘−130.14∘=19.86∘B = 180^\circ - 30^\circ - 130.14^\circ = 19.86^\circ. The area is 12(4)(9)sin⁡30∘=9.00\tfrac12(4)(9)\sin 30^\circ = 9.00 m², and the perimeter is 18.89 m.

Only the largest angle, opposite the longest side, can be 90° or more. Find it with the law of cosines, and arcsin is safe for the other two.

Why can SSA give two triangles, or none?

Because the side opposite the known angle is free to pivot, it can meet the third side’s line twice, once or not at all. Draw angle AA at the left end of a baseline, with side bb rising from it. Side aa swings from the top of bb down to the baseline. Whether it reaches, and how many times, depends on how aa compares with bb and with the height of that top point, h=bsin⁡Ah = b \sin A:

Angle ASide aTriangles
AcuteShorter than hhNone: aa can’t reach the baseline
AcuteEqual to hhOne, with a right angle at BB
AcuteBetween hh and bbTwo: aa meets the baseline at two points
Acutebb or longerOne: the second crossing falls at or behind AA
90° or morebb or shorterNone
90° or moreLonger than bbOne

In law-of-sines terms, sin⁡B=bsin⁡A/a\sin B = b \sin A / a. A value above 1 means no triangle. Below 1, both BB and 180∘−B180^\circ - B have that sine, and the second counts only if A+(180∘−B)A + (180^\circ - B) is less than 180°.

To skip arcsin entirely, treat the law of cosines as a quadratic in the unknown side: c=bcos⁡A±a2−b2sin⁡2Ac = b\cos A \pm \sqrt{a^2 - b^2 \sin^2 A}. A negative number under the root means no triangle, and each positive cc is one triangle.

Worked example: a lighthouse that comes into view twice

Example assumptions: a ship holds a straight course. At point A, a lighthouse is 10 km away, 40° off the course, and its light can be seen from up to 7 km. How far along the course does the light come into view, and where does it drop out of view?

So A=40∘A = 40^\circ, b=10b = 10 km (ship to lighthouse), a=7a = 7 km (lighthouse to the point where the ship is exactly at the edge of the range), and cc is the distance sailed. This is SSA.

  1. Count the triangles. h=10sin⁡40∘=6.428h = 10 \sin 40^\circ = 6.428 km, the course’s closest approach to the lighthouse. Because 6.428 < 7 < 10, there are two.
  2. Angle B. sin⁡B=10sin⁡40∘/7=0.9183\sin B = 10 \sin 40^\circ / 7 = 0.9183. Arcsin gives 66.67°, and its supplement is 113.33°. Both leave room for a third angle.
  3. Angle C. 180∘−40∘−113.33∘=26.67∘180^\circ - 40^\circ - 113.33^\circ = 26.67^\circ, or 180∘−40∘−66.67∘=73.33∘180^\circ - 40^\circ - 66.67^\circ = 73.33^\circ.
  4. Distance c. c=asin⁡C/sin⁡Ac = a \sin C / \sin A: 7sin⁡26.67∘/sin⁡40∘=4.897 \sin 26.67^\circ / \sin 40^\circ = 4.89 km and 7sin⁡73.33∘/sin⁡40∘=10.437 \sin 73.33^\circ / \sin 40^\circ = 10.43 km.
  5. Cross-check. The quadratic gives c=10cos⁡40∘±72−6.4282c = 10\cos 40^\circ \pm \sqrt{7^2 - 6.428^2} =7.660±2.772= 7.660 \pm 2.772, which is 4.89 km or 10.43 km.
DetailTriangle 1Triangle 2
Angle B, at the ship113.33°66.67°
Angle C, at the lighthouse26.67°73.33°
Distance along the course, c4.89 km10.43 km
MeaningLight comes into viewLight drops out of view
The lighthouse example drawn to scale The ship's course runs along the bottom from point A. The lighthouse, C, is 10 km from A on a line 40° off the course. A dashed arc of radius 7 km around the lighthouse, the edge of its range, crosses the course twice: 4.89 km from A, where the light comes into view, and 10.43 km from A, where it drops out of view. A dashed line straight down from the lighthouse, the height h of 6.43 km, meets the course at 7.66 km, halfway between the two crossings. Lighthouse, C b = 10 km a = 7 km a = 7 km 40° A 4.89 km 10.43 km h = 6.43 km 7.66 km
Drawn to scale. Side a (7 km) is longer than the height h (6.43 km) but shorter than b (10 km), so it reaches the course at two points.

Both answers are real. The ship is in range for 5.54 km of its course and passes closest (6.43 km) at 7.66 km, halfway between the two points. Change the range and the count changes:

  • 6 km range, shorter than the closest approach: sin⁡B=1.071\sin B = 1.071, which is impossible. No triangle; the light never comes into view.
  • 12 km range, longer than the 10 km starting distance: one triangle. The ship starts in range and leaves it after 17.79 km. The quadratic’s other root, −2.47 km, lies behind the start.

How do you know which of the two triangles you need?

The three measurements can’t tell you, because both triangles fit all of them. The deciding fact has to come from elsewhere: a sketch or photo showing whether angle BB is obtuse, a fourth measurement, or the wording of the question. In the example, “comes into view” means the nearer point. When nothing decides it, report both.

How much can rounding change the answer?

Usually only the last digit, if you keep full precision until the final answer. In two situations, though, small roundings change the answer outright.

Near the SSA boundary. With a 6.5 km range, just above the 6.428 km closest approach, the light appears at 6.69 km and disappears at 8.63 km. Read the angle as 41° instead of 40° and the closest approach becomes 6.56 km, so there is no triangle at all. Close to the boundary, angle BB approaches 90° (81.46° here), and Kahan’s notes show that the arcsin step can lose up to half the digits carried there.

In long, thin triangles. Example measurements: two stakes are 50 m and 48 m from a survey point, 3° apart. a2=502+482−2(50)(48)cos⁡3∘a^2 = 50^2 + 48^2 - 2(50)(48)\cos 3^\circ =4804−4793.42=10.58= 4804 - 4793.42 = 10.58, so they are 3.252 m apart. That is a small difference between two numbers near 4,800, so any rounding in cos⁡3∘\cos 3^\circ is magnified:

Value of cos 3° usedDistance aError
0.99862953 (full precision)3.252 mNone
0.9986 (4 decimal places)3.274 m+0.7%
0.999 (3 decimal places)2.966 m−8.8%

The form a=(b−c)2+4bcsin⁡2(A/2)a = \sqrt{(b - c)^2 + 4bc\sin^2(A/2)}, which follows from 1−cos⁡A=2sin⁡2(A/2)1 - \cos A = 2\sin^2(A/2), avoids the subtraction: 4+6.578=3.252\sqrt{4 + 6.578} = 3.252 m, and rounding sin⁡1.5∘\sin 1.5^\circ to 0.0262 still gives 3.254 m. Kahan recommends it, with a rearranged Heron’s formula, for needle-shaped triangles.

The measurement limits you more than the arithmetic. If the 3° was read to the nearest degree, the true angle could be anywhere from 2.5° to 3.5°, which puts the stakes 2.93 m to 3.60 m apart. For a triangle this thin, measure the short side directly if you can.

When can you use right-triangle shortcuts instead?

Whenever one angle is 90°. Then cos⁡90∘=0\cos 90^\circ = 0 turns the law of cosines into the Pythagorean theorem, and SOH-CAH-TOA does the rest: sine is opposite over hypotenuse, cosine is adjacent over hypotenuse, tangent is opposite over adjacent. The two acute angles add up to 90°.

Example measurements: a shed’s gable end is 10 ft wide, and the ridge is 2.5 ft above the top of the 8 ft walls. Each half of the gable is a right triangle with legs of 5 ft and 2.5 ft.

  • Sloped edge: 52+2.52=31.25=5.590\sqrt{5^2 + 2.5^2} = \sqrt{31.25} = 5.590 ft.
  • Roof angle: tan⁡−1(2.5/5)=26.57∘\tan^{-1}(2.5/5) = 26.57^\circ, a rise of 6 in for every 12 in of run. That leaves 63.43° at the ridge in each half, or 126.87° across the full peak.
  • End-wall area: the gable is 12×10×2.5=12.5\tfrac12 \times 10 \times 2.5 = 12.5 ft², and the 10 ft × 8 ft rectangle below it is 80 ft², so the wall is 92.5 ft².

Some right triangles have exact ratios:

TriangleSide ratioAngles
45-45-901 : 1 : √245°, 45°, 90°
30-60-901 : √3 : 230°, 60°, 90°
3-4-53 : 4 : 536.87°, 53.13°, 90°
5-12-135 : 12 : 1322.62°, 67.38°, 90°

The converse holds too: if a2+b2=c2a^2 + b^2 = c^2, the angle opposite cc is exactly 90°. That is why marking 3 and 4 units along two edges and measuring 5 across confirms a square corner.

What if you know the corners’ coordinates instead of the sides?

Use the distance formula, d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}, on each pair of corners, then solve as SSS. For corners at (0, 0), (8, 0) and (2, 5) on a site plan in meters, the sides are 8 m, 29=5.385\sqrt{29} = 5.385 m and 61=7.810\sqrt{61} = 7.810 m. The law of cosines gives angles of 68.20° at (0, 0), 39.81° at (8, 0) and 72.00° at (2, 5). One side lies on the x-axis, so the area is 12×8×5=20\tfrac12 \times 8 \times 5 = 20 m², and Heron’s formula agrees. The 68.20° angle also equals the angle of inclination of the line from (0, 0) to (2, 5), which makes a quick check.

Mistakes that give wrong answers

  • Calculator in radian mode. sin⁡40\sin 40 returns 0.7451, the sine of 40 radians, instead of 0.6428. 180° is π radians, so check the mode first.
  • A misread case. In SSA the known angle is opposite one of the known sides. If it sits between them, the case is SAS and there is only one triangle.
  • Impossible data. Sides where one is at least as long as the other two combined (1, 2 and 3, for example) don’t close into a triangle, and neither do two angles totaling 180° or more.

Try it

  • Triangle calculator: the page opens with an example filled in, so press Reset before each set of values. Enter side a = 7, side b = 10 and angle A = 40°. Expect two triangles: c = 4.8887 with B = 113.3258°, and c = 10.4322 with B = 66.6742°. Change a to 6 for no triangle, or to 12 for one with c = 17.7937.
  • Same calculator: b = 4, c = 9, A = 30° gives a = 5.8861, C = 130.1363°, B = 19.8637° and area 9. For the thin triangle, b = 50, c = 48, A = 3° gives a = 3.2524; A = 2.5 and 3.5 give 2.9272 and 3.599. For half the gable, a = 2.5, b = 5, C = 90° gives c = 5.5902 and A = 26.5651°.
  • Slope, distance and midpoint calculator: points (0, 0) and (2, 5) give distance 5.3852 and angle of inclination 68.1986°; (8, 0) and (2, 5) give 7.8102. Pressing Reset in the triangle calculator and entering a = 7.8102, b = 5.3852, c = 8 returns A = 68.1979°: rounding the sides to four decimals moved the angle by 0.0007°.
  • Area and perimeter calculator: a 10 × 8 rectangle gives 80 ft². Add the 12.5 ft² gable for the 92.5 ft² end wall.

Questions

Can a triangle have two obtuse angles?

No. The three angles add up to 180°, and two angles over 90° would already total more than that. A triangle has at most one angle of 90° or more, and it is always the angle opposite the longest side.

Is SSA a valid way to prove two triangles congruent?

Not in general. The two triangles in the ambiguous case share both sides and the angle, yet their third sides differ, as in the lighthouse example (4.89 km and 10.43 km). SSA does fix the triangle when the side opposite the known angle is at least as long as the other known side, which includes the right-angle case where that side is the hypotenuse. SSS, SAS, ASA and AAS always fix it.

Sources

  1. Algebra and Trigonometry 2e, 10.1 Non-right Triangles: Law of Sines OpenStax (Rice University) The law of sines; the labeling convention (each side opposite the angle with the same letter); ASA, AAS and SSA cases; the SSA ambiguous case with no, one or two triangles; inverse sine returns a single value, so check for a second solution; carry exact values to the final answer; area as half of two sides times the sine of the included angle.
  2. Algebra and Trigonometry 2e, 10.2 Non-right Triangles: Law of Cosines OpenStax (Rice University) The law of sines does not solve SAS or SSS triangles; the law of cosines does, including its rearranged form for an angle; its derivation as a generalized Pythagorean theorem; Heron’s formula.
  3. Algebra and Trigonometry 2e, 7.2 Right Triangle Trigonometry OpenStax (Rice University) Sine, cosine and tangent as ratios of opposite, adjacent and hypotenuse (SohCahToa); side ratios of the 30-60-90 and 45-45-90 triangles; solving a right triangle from one side and one acute angle.
  4. Algebra and Trigonometry 2e, 7.1 Angles OpenStax (Rice University) 180° equals π radians, and how to convert between degrees and radians.
  5. College Algebra 2e, 2.1 The Rectangular Coordinate Systems and Graphs OpenStax (Rice University) The distance formula between two points, derived from the Pythagorean theorem.
  6. Miscalculating Area and Angles of a Needle-like Triangle (W. Kahan, lecture notes) University of California, Berkeley Rounding errors make the classical formulas (Heron’s formula, arccos for an angle) inaccurate for needle-like triangles; the rearranged side formula with (a − b)² + 4ab sin²(C/2); the arcsin step in SSA is ambiguous, has no solution when a < b sin A, and can lose up to half the digits carried when the angle is close to 90°.
  7. Euclid’s Elements, Book I, Proposition 20 (D. E. Joyce, ed.) Clark University The triangle inequality (any two sides together are longer than the third); the side opposite the greater angle is the greater side.
  8. Euclid’s Elements, Book I, Proposition 26 (D. E. Joyce, ed.) Clark University The commentary lists the congruence theorems (side-angle-side, side-side-side, side and two angles), explains that side-side-angle is ambiguous unless the side opposite the given angle is at least as long as the other given side, and cites the angle sum of two right angles (I.32).
  9. Euclid’s Elements, Book I, Proposition 48 (D. E. Joyce, ed.) Clark University The converse of the Pythagorean theorem; if the square on one side equals the sum of the squares on the other two, the angle between those two sides is right.