Chapter 5
The laws of cosines and sines
Two rules solve every triangle, not only right-angled ones. Both are the unit circle in disguise.
Two rules solve any triangle, not only right-angled ones. The law of cosines, c² = a² + b² − 2ab cos C, is Pythagoras’s theorem with a correction term for an angle that is not 90°. The law of sines, a/sin A = b/sin B = c/sin C, says every side divided by the sine of the angle opposite it gives the same number, which turns out to be the diameter of the circle through the three corners[1]. Both come straight from the unit circle, and the figures below let you check them on a triangle you can bend into any shape.
The labels follow one convention throughout: corners A, B, C, and the side opposite each corner named by the same letter in lower case.
The law of cosines
Here is the proof, and it is the unit circle again. Put corner C at the origin and side a along the x-axis, so B = (a, 0). Corner A is at distance b from the origin, in the direction that makes angle C with the x-axis. On the unit circle that direction is the point (cos C, sin C); at distance b it is A = (b cos C, b sin C). Now c is the distance from A to B:
and cos² + sin² = 1 finishes it[2]. Nothing in this argument needs C to be acute. When C is obtuse, A sits to the left of the y-axis, cos C is negative, and the “correction” makes c longer than Pythagoras would. When C = 90°, cos C = 0 and the law is Pythagoras’s theorem exactly.
Euclid knew this, without cosines. Propositions 12 and 13 of Book II of the Elements state that the square on the side opposite an obtuse angle exceeds the squares on the other two sides by twice a rectangle, and that the square opposite an acute angle falls short by twice a rectangle[3]. documented That rectangle has sides a and the projection of b onto a, which is b cos C in modern notation: the yellow segment in the figure. Euclid’s two propositions are the two signs of the cosine.
A worked example. Two sides of a triangle are b = 5 and c = 7, and the angle between them is A = 60°. Then a² = 25 + 49 − 2 × 5 × 7 × cos 60° = 74 − 35 = 39, so a = √39 ≈ 6.245. Read the other way, the law finds an angle from three sides: cos C = (a² + b² − c²)/(2ab).
The law of sines
The quick proof drops an altitude. The height of the triangle above side c, measured from C, is b sin A if you look along side b, and a sin B if you look along side a. They are the same height, so b sin A = a sin B, which rearranges to a/sin A = b/sin B[1]. The circle shows what the common value is.
Every triangle has exactly one circle passing through its three corners, its circumcircle, with radius R. Draw the diameter from B across to the far side, B′. Two classical facts about circles finish the proof, both in Book III of Euclid: an angle inscribed in a semicircle is a right angle, so triangle BCB′ is right-angled at C; and angles standing on the same arc are equal, so the angle at B′ equals A[4]. In the right triangle, a = 2R sin A. The same argument from each corner gives the full law.
This explains why the law of sines can be trusted for sides but misleads for angles. A side determines its sine, but a sine does not determine its angle: sin B = sin(180° − B), because the unit-circle points at B and 180° − B have the same height. When the law of sines hands you an angle, it might be the obtuse one.
The rule is old. Ptolemy and the Indian astronomers solved triangles with chord and sine tables[5], but the first surviving book to set out the whole of plane and spherical trigonometry as a subject of its own is the Treatise on the Quadrilateral of Nasir al-Din al-Tusi, written in the thirteenth century, and it states the sine formula for plane triangles[6]. documented
Measuring a country with one ruler and many angles
The law of sines turns one measured length into as many as you like, provided you can measure angles. That is the whole idea of triangulation.
In 1615 Willebrord Snel, professor of mathematics at Leiden, set out to determine the length of the meridian by measuring the distance from Alkmaar to Bergen op Zoom, two towns about 130 kilometers apart on nearly the same meridian. He did not walk it with a chain. He measured one baseline on the ground, about 5 kilometers from Leiden to Zoeterwoude, and then only angles, sighted between the spires of town churches with a huge quadrant, 210 centimeters in size, built by the instrument maker Blaeu. A chain of triangles, each sharing a side with the last, carried the baseline across the country. His unit was the Rhineland rod of 3.767 meters, and he published the result in 1617 as Eratosthenes Batavus, “the Dutch Eratosthenes.” He took the method so far that his biographer in the Dictionary of Scientific Biography calls him the father of triangulation[7]. documented
One step of such a chain, with round numbers. Two stations A and B are 5,000 m apart. From A the church spire C is 72° away from the line AB; from B it is 63° away. The third angle is C = 180° − 72° − 63° = 45°, and the law of sines gives both new sides at once:
Either new side can be the baseline of the next triangle, and nobody has to cross the river, the marsh or the city in between with a tape.
The same formula says which triangles to avoid. The far angle C sits in the denominator, so a small error in it is magnified by how fast sin C changes. Differentiate: an error δC (in radians) changes the computed side by a fraction cot C · δC. With C = 45°, an error of one minute of arc (1/60 of a degree) moves the side by 0.03%; with C = 5°, the same one-minute error moves it by 0.33%, eleven times as much. A thin triangle is a bad lever. That is the arithmetic reason a survey net is drawn from fat, nearly equilateral triangles, and why the next figure, where a thin triangle is exactly what you get when side a barely reaches the baseline, is worth watching closely.
The ambiguous case (SSA)
Two sides and an angle that is not between them (“side-side-angle”) is the one set of measurements that can fail to pin a triangle down. Picture it as a construction. Draw angle A. Mark C on one arm, at distance b. Now side a must reach from C to the other arm: swing it like a compass and see where it lands.
The decision depends on two lengths, the height h = b sin A from C down to the baseline, and b itself[1]. For an acute angle A:
- a < h: the arm cannot reach the baseline. No triangle. (Algebraically, the law of sines would need sin B > 1.)
- a = h: the arm touches the baseline once, at a right angle. One right triangle.
- h < a < b: the arm crosses the baseline twice, both crossings on the correct side of A. Two triangles, with B and 180° − B.
- a ≥ b: the second crossing falls behind A, outside the angle. One triangle.
For an obtuse angle A, side a must be the longest side, so there is one triangle if a > b and none otherwise. The engine behind these figures implements exactly these cases, and its tests sweep a through each boundary to check that the count goes 0, 1, 2, 1 in that order.
Solving a triangle, with the working shown
Which law to use depends on what you know. Three sides (SSS) or two sides and the angle between them (SAS): start with the law of cosines. Two angles and any side (ASA or AAS): the third angle is 180° minus the other two, then the law of sines. Two sides and a non-included angle (SSA): the law of sines, keeping the ambiguous case in mind.
The same solver has a page of its own, the law of cosines calculator, for when you only need the answer.
One practical tip. When you know all three sides and want all three angles, find the largest angle (the one opposite the longest side) with the law of cosines first. It is the only angle that can be obtuse, and the law of cosines gets obtuse angles right, because cosine is negative there. The two remaining angles are then acute, and the law of sines cannot mislead you about them.
The area of any triangle
Half the base times the height works for every triangle, and trigonometry supplies the height. Stand side a on the ground. The height from the opposite corner is b sin C, the vertical coordinate of a point at distance b and angle C: the unit circle, stretched by b, once more. So
two sides and the angle between them[1]. It peaks when C = 90°, since sin C cannot exceed 1, and it does not care whether C is acute or obtuse, since sin C = sin(180° − C). Hinge two sticks of fixed length at one end and open them: the triangle they span is largest when the hinge is square.
If you know only the three sides, the law of cosines gives cos C, the Pythagorean identity gives sin C, and equation (5.5) gives the area. Carry that algebra through in general and it collapses to Heron’s formula, Area = √(s(s − a)(s − b)(s − c)), where s is half the perimeter[1]. The 13–14–15 triangle is the classic check. By the law of cosines, cos C = (169 + 196 − 225)/(2 · 13 · 14) = 5/13, so sin C = 12/13 and the area is ½ · 13 · 14 · 12/13 = 84. Heron, with s = 21, gives √(21 · 8 · 7 · 6) = √7056 = 84 as well.
When the formula is right and the computer is wrong
Every formula on this page is exact, and a calculator can still get it badly wrong. The usual way to find an angle from three sides is C = arccos((a² + b² − c²)/(2ab)). For a long thin “needle” triangle the fraction inside is a hair below 1, and rounding wipes out the hair.
William Kahan, a numerical analyst at Berkeley, works an example in his lecture notes on exactly this problem[9]. Take sides a = 100,000, b = 99,999.99979 and c = 0.00029. The angle opposite the tiny side is about 1.146 × 10−7 degrees. On a ten-digit HP-15C calculator the arccos formula returns exactly 0, and Heron’s formula for the area returns 17.6 when the accurate value is 9.99999999. documented Extra digits do not rescue it: in the sixteen-digit double precision that your browser uses, the arccos formula still returns exactly 0 for these sides.
The cure is not more precision but a better arrangement of the same arithmetic. Kahan sorts the sides so that a ≥ b ≥ c and writes the area as ¼√((a + (b + c))(c − (a − b))(c + (a − b))(a + (b − c))), and adds the instruction “Do not remove parentheses from this formula!” Each factor is then either a sum of positive numbers or a difference between two quantities that are themselves exact, so each is accurate to within a unit or two in its last digit; his matching formula for the angle uses 2 arctan instead of arccos and recovers 1.1459 × 10−7 degrees in double precision[9]. The lesson reaches well beyond triangles: algebraically identical formulas are not numerically identical, and the one in the textbook was chosen for the page, not for the machine.
Triangles are where trigonometry started, as Chapter 1 tells. The last chapter turns the circle into a coordinate system of its own: polar coordinates, which name a point by its distance and its angle.