The formulas that solve any triangle
A triangle has six measurements: three sides and three angles. Give any three of them, including at least one side, and the other three follow. By convention side a lies opposite angle A, side b opposite angle B and side c opposite angle C. Four relationships do all the work.
Angle sum: A + B + C = 180°
Law of sines: a ÷ sin A = b ÷ sin B = c ÷ sin C
Law of cosines: c² = a² + b² − 2ab × cos C
Area = ½ × a × b × sin C
The law of cosines works for any side as long as the angle used is the one opposite the side on the left. Rearranged, it gives an angle from three sides: cos C = (a² + b² − c²) ÷ (2ab). Each height follows from the area, because the area is also half of any side times the height drawn to it:
Height to side a = 2 × Area ÷ a
Which formula for which case
- SSS (three sides): law of cosines for two angles, then the angle sum.
- SAS (two sides and the angle between them): law of cosines for the third side, then for an angle.
- ASA and AAS (two angles and a side): the angle sum for the third angle, then the law of sines.
- SSA (two sides and an angle that is not between them): law of sines, with care, because there may be no triangle, one or two.
Worked example: two sides and the angle between them
Take a = 7, b = 10 and C = 40°.
- Third side. c² = 7² + 10² − 2 × 7 × 10 × cos 40° = 49 + 100 − 140 × 0.7660 = 149 − 107.25 = 41.75, so c = 6.46.
- Angle A. cos A = (b² + c² − a²) ÷ (2bc) = (100 + 41.75 − 49) ÷ (2 × 10 × 6.46) = 92.75 ÷ 129.23 = 0.7177, so A = 44.13°.
- Angle B. B = 180° − 40° − 44.13° = 95.87°.
- Area. ½ × 7 × 10 × sin 40° = 35 × 0.6428 = 22.50.
- Perimeter and a height. 7 + 10 + 6.46 = 23.46. The height to side c is 2 × 22.50 ÷ 6.46 = 6.96.
Step 2 uses the law of cosines on purpose. The law of sines would give sin B = 10 × sin 40° ÷ 6.46 = 0.9948, and a calculator’s inverse sine returns 84.13° for that, which is wrong. The true angle is 95.87°. Both angles have the same sine, and inverse sine only ever returns the one below 90°. The cosine of an obtuse angle is negative, so inverse cosine cannot make this mistake.
The ambiguous case (SSA)
When the known angle is not between the two known sides, the side opposite the angle can sometimes swing to touch the third side in two places. Suppose A = 30°, a = 6 and b = 10. The shortest distance from corner C to the opposite side is b × sin A = 10 × 0.5 = 5. Compare a with that distance and with b:
- a shorter than 5 (say a = 4): side a cannot reach, so there is no triangle.
- a exactly 5: it just touches, giving one right-angled triangle.
- a between 5 and 10 (our a = 6): it reaches in two places, so there are two triangles.
- a at least 10: only one of the two positions lies on the correct side of A, so there is one triangle.
For a = 6 the law of sines gives sin B = 10 × 0.5 ÷ 6 = 0.8333, so B is 56.44° or 180° − 56.44° = 123.56°. The first gives C = 93.56° and c = 11.98. The second gives C = 26.44° and c = 5.34. Both are genuine triangles, and only extra information, such as knowing that angle B is obtuse, can tell you which one you have.
When the numbers cannot make a triangle
Three sides only close up if the longest is shorter than the other two added together. Sides of 2, 3 and 6 fail, because 2 + 3 = 5 falls short of 6. Two angles must add up to less than 180°, or nothing is left for the third. Three angles alone fix the shape but not the size, so at least one side is always needed.
Two practical points. Check that your calculator is in the same angle mode as your data: 40° is 0.6981 radians, and mixing the two is the most common source of nonsense answers. And carry full precision through the steps, rounding only at the end. The worked example above shows rounded values, but each step was calculated from the unrounded ones.
A useful check on any answer is that the largest angle must sit opposite the longest side. The 3-4-5 triangle that loads with this page has a right angle of exactly 90° opposite the side of length 5, and an area of 6.