The lengths of the sides of a triangle (in Euclidean space) fully determine (the magnitudes of) the angles of the triangle. Conversely, given two sides of a triangle and the angle between them, it is possible to compute the length of the third side (which is said to be opposite to the angle given). One side of a triangle and two of its angles likewise suffice to determine the remaining angle and sides. In each case, to determine the missing information, we'll be using the trigonometric functions Sine and Cosine.

Suppose we are given a triangle with vertices A, B and C and we know the interior angle at C and the lengths of the sides BC and CA; we wish to know the length of the side AB and the magnitudes of the angles at A and B.

Drop a perpendicular from C onto the line of which the edge AB is a portion; let
F be the point where the perpendicular meets this line. The definition of Sine,
applied to the two right-angle triangles on either side of CF, tells us that the
length of CF is the length of either of the triangle's sides out of C times the
Sine of the angle at the chosen side's other end: CA.Sin(CAB) = CF =
BC.Sin(ABC), from which we can infer CA/Sin(ABC) = BC/Sin(CAB); the length of a
side of the triangle, divided by the Sine of the opposite angle, is the same for
both angles. Naturally, by chosing one of the other perpendiculars from a
vertex to an opposite side, we get AB/Sin(BCA) equal to the same ratio. This is
known as The Sine Rule

: CA/Sin(ABC) = BC/Sin(CAB) =
AB/Sin(BCA). Furthermore, this ratio is equal to the diameter of the triangle's
circumcircle, as I'll now show.

Every triangle has a circumcircle, which passes through all three vertices of the triangle. If we fix one side of the triangle and move the opposite vertex around this circle, the angle opposite the edge doesn't change as long as the vertex remains on the same side of the edge; and the angle opposite our edge in a triangle on its other side, still with the opposite vertex on the circle, is the complement of the original in half a turn, which has the same Sin as the original angle. So dividing the length of the edge by the Sin of the opposite angle gets the same value no matter which triangle we use, with the given fixed edge and circumcircle; and, by The Sine Rule, in each of those triangles, each side has this same ratio of length to Sin of opposite angle. At least one of the candidate triangles this lets us examine has a diameter as an edge, opposite a right angle, whose Sin is 1; and the Sine rule is true also in that triangle, so the diameter of the circumcircle is equal to the length of any side divided by the Sin of the opposite angle, in any triangle whose vertices all lie on this circle.

The sine rule, also called the law of sines

, leads
to the angle bisector theorem, which shows that the
parts of an edge of a triangle into which the opposite angle's bisector cuts it
have lengths proportional to the other two sides of the triangle. I imagine the
cosine rule, below, also gets called the law of cosines

.

Consider, next, the Cosines of the angles opposite CF in the right-angle triangle on each side of it; multiply each of these by the length of a side from C to the given angle and we get the length of the part of AB that's on the same side of F as the chosen angle. Adding these, we get AB = CA.Cos(CAB) +BC.Cos(ABC). (Note that, if CAB > turn/4, F falls on the extension of AB past A and Cos(CAB) < 0; we still get AB = CA.Cos(CAB) +BC.Cos(ABC), but now with BC.Cos(ABC) > AB.) Again, the other perpendiculars from a vertex to the opposite side give us equivalent formulae, BC = AB.Cos(ABC) +CA.Cos(BCA) and CA = AB.Cos(CAB) +BC.Cos(BCA). Multiply each of the last two by the other's multiplier for Cos(BCA) and add to get:

- BC.BC +CA.CA
- = AB.BC.Cos(ABC) +CA.AB.Cos(CAB) +2.CA.BC.Cos(BCA)
- = AB.(BC.Cos(ABC) +CA.Cos(CAB)) +2.CA.BC.Cos(BCA)
- = AB.AB +2.CA.BC.Cos(BCA)

by applying the first of our Cos-equations to replace BC.Cos(ABC)
+CA.Cos(CAB) with AB. This is known as The Cosine Rule

;
it naturally comes in three forms, depending on which angle's Cosine we're left
with after eliminating the other two:

- CA.CA +BC.BC = AB.AB +2.CA.BC.Cos(BCA)
- AB.AB +CA.CA = BC.BC +2.AB.BC.Cos(CAB)
- AB.AB +BC.BC = CA.CA +2.AB.BC.Cos(ABC)

If we know two angles of a triangle, we can infer the third because all three together sum to a half turn; given also the length of one side, we can infer the lengths of the other two sides using The Sine Rule. If, instead, we know two sides and the angle between them, we can infer the length of the third side using The Cosine Rule; or, once we know all three sides of a triangle, The Cosine Rule tells us the Cosine of each of its angles.

One may equally arrive at the cosine law by considering AB, BC and CA as vectors (the above considered them only as lengths) so that AC+CB = AB (and CB = −BC has the same length as BC but opposite direction); lengths are then encoded by a metric, g, which consumes two vectors, linearly in each, and yields their inner product; which is the product of their lengths multiplied by the cosine of the angle through which we must rotate one to make it parallel to the other; when the two vectors are equal, this is just the square of the vector's length. Then g(AB,AB) = g(AC,AC) +g(CB,CB) +g(AC,CB) +g(CB,AC); the last two terms are equal (due to symmetry of the metric) and each is just the product of the lengths of BC and CA multiplied by the angle through which AC must be rotated to make it parallel to CB; this angle is just the external angle of the triangle at C, which is equal to CAB +ABC = turn/2 −BCA, whose cosine is −Cos(BCA).

If we know two sides and an angle *other than* the one between them, this
angle is opposite one of the sides whose length we know, so The Sine Rule will
tell us the Sine of the angle opposite the other known side. If that Sine is 1,
we can infer that the angle is a right angle; otherwise, there are two angles,
one on each side of a right angle, with the given Sine, so we have two possible
triangles with the given two sides and specified angle; for each of these (or
for the single case, when the Sine was 1) we can infer the third angle of the
triangle, between the two given sides, and thus the length of the remaining
side. Thus, of the three side lengths and three angles of a triangle, if we
know three, including at least one side-length, we know all six, albeit with two
solutions in this last case (which represents a real geometric ambiguity in the
data given).

Consider now the case where BCA is a right angle; AB is then the hypotenuse, with CA and BC as the perpendicular sides. The Sine rule now reduces to CA/Sin(ABC) = BC/Sin(CAB) = AB/Sin(turn/4) and the definition of Sine says Sin(ABC) = CA/AB, so Sin(turn/4) = AB.Sin(ABC)/CA = 1; or, given this fact, the Sin rule reiterates the definition of Sine for ABC; likewise for Sin(CAB) = BC/AB. In the same situation, we have AB.AB = CA.CA +BC.BC as Pythagoras's theorem; applied to The Cosine Rule for our right angle BCA we find 0 = 2.CA.BC.Cos(turn/2), whence Cos(turn/2) = 0. Equally, given that fact, we could have inferred Pythagoras's theorem.

Substituting AB.AB = CA.CA +BC.BC on the left of either of the other two cases of The Cosine Law duplicates the other squared term on that side and adds a match for the other side's squared term; after cancelling that away, each side has a factor of twice the side whose square is left on the left; dividing that out, we're left with that side equal to the hypotenuse, AB, times the Cosine of the angle between them, exactly the definition of Cos.

In particular, we can infer, from the cosine law, that the cosine of any interior angle of a triangle whose sides are all rationally commensurate (i.e. whole multiples of some shared unit in length) must be a rational (that is, a ratio of whole numbers). It is worth noting that the sine and cosine of any angle which is a rational multiple of the whole turn (or, equivalently, of the degree) are necessarily algebraic (that is, roots of some polynomial equation whose coefficients are all whole numbers; in particular, all rationals are algebraic). Consequently it may be worth exploring whether all internal angles of integer-sided triangles are necessarily rational multiples of a turn.

In contrast, for a triangle with rationally commensurate side
lengths, the sine rule doesn't imply rational values for the sines of the
angles; it only implies that the sines of the angles are rationally commensurate
with one another. Given that the cosines of the angles are rational, the sines
are at worst square roots of rationals, which one can fairly regard as
the most tractable

of the irrational numbers.

One can also exploit the cosine law to study the analogue, for angles other than the right angle, of the problem of seeking triangles with rationally commensurate sides and some prescribed angle. Using the largest unit of length of which all three sides are integer multiples, we can describe the edges by integers a, b and c which we can use in place of the lengths involved in the cosine rule. Our choice of length unit ensures that a, b and c are coprime. Any whole scaling applied to all three integers alike will yield another solution to our problem; but this is equivalent to the un-scaled solution from which it is derived by simply selecting a different unit of length. Consequently, we can afford to ignore solutions having a common factor between the three integers.

As an example, consider the cases of turn/3 and turn/6 (i.e. 120 and 60 degrees); these have cosines −1/2 and +1/2, respectively, so that the cosine law reduces to: a.a ±a.b +b.b = c.c, which we may re-arrange as a.(a±b) = (c+b).(c−b).

Any common factor of a and b is necessarily a repeated factor of c.c and thus a factor of c. Any common factor of c and b is necessarily a repeated factor of a.(a±b); if it is a factor of a±b then it will necessarily also be a factor of a; thus the only way for it to not be a factor of a is for it to be a product of coprime integers, one of whose squares is a factor of a while the other's square is a factor of a±b; but then the first factor is a factor of a and the second is a shared factor of b and a±b, hence also of a, making a a multiple of both coprime factors and, hence, of their product. Since the equation is symmetric between a and b, we may thus infer that any common factor of any two of our integers is necessarily a common factor of the third; the three integers are collectively coprime only if they are pair-wise coprime.

In particular we can ignore any case where more than one of our edges has even length; in particular, either a or b must be odd; given symmetry between them, we may suppose a is odd. Then if b is even, so is b.(a±b); if b is odd, so are both b.b and a.b, so b.b±a.b is even; either way, adding odd a.a we find that c.c is odd, hence so is c. Thus, c+a and c−a are both even; and they differ by 2.a, which isn't a multiple of 4, so in fact one of them is a multiple of 4, so b.(b±a) = (c+a).(c−a) is a multiple of 8. Thus either b or a±b is a multiple of 8, the other being odd (since these two must also be coprime, any common factor of them being a common factor of a and b). Thus, if b has any factors of two, it has at least three of them; otherwise, it is odd and a±b is a multiple of 8.

We can arrive at the same conclusion another way. Modulo 8, all odd squares are 1; multiples of four have 0 as their square and other even numbers have 4 as their square. The product a.b need not be a perfect square, however. We know c and a are odd; thus, modulo 8, we require (b±a).b = c.c −a.a = 0; as a is odd, one of b±a and b must be odd and the other even; whence the even one must in fact be a multiple of 8; so either b or b±a is a multiple of 8.

Any common factor of c+b and c−b is necessarily a common factor of their sum and product, 2.c and 2.b; thus, if c and b are coprime, the highest common factor of c+b and c−b is 1 or 2; the common factor will only be two if both c and b are odd, in which case a±b is a multiple of 8.

Aside from the case where all three sides are 1 (the equilateral triangle, with interior angle turn/6), being coprime implies that the three sides must be distinct; since the nearest perfect squares to b.b are b.b±2.b+1, we can exclude the case a = 1 since b.b±b+1 is too close to b.b to be a perfect square, like c.c; consequently, with a odd, we may assert that a > 2; and, by kindred argument, that b > 1.

If b is a multiple of 8 it is 2.n for some n divisible by 4; yielding c.c = a.a ±2.n.a +4.n.n = (a±n).(a±n) +3.n.n whence (c+a±n).(c−(a±n)) = 3.n.n. Since a, b and c are the sides of a triangle, we know a+c ≥ b > n whence c+a±n > 0, whence our other factor of 3.n.n > 0 must also be positive, so c > a±n. As a and c are odd, c−a is even; being > ±n, which is also even, we may infer that c−(a±n) ≥ 2 whence 3.n.n/2 ≥ c+a±n > 2.(a±n) yielding 3.n.n/4 > a±n. Thus c.c = (a±n).(a±n) +3.n.n < 3.n.n.(1 +3.n.n/16) and c < n.√(3 +9.n.n/16).

For the turn/6 (i.e. 60 degree) case, ± is − and the case where b−a is zero (a particularly convenient multiple of 8) is simply the familiar equilateral triangle, with b = a and c.c = a.a −a.b +b.b = a.a so c = a also, so that the coprime form has a = b = c = 1. Otherwise either b or b−a must be a non-zero multiple of 8. For b = 8 we have c < 4.√12 < 14, 12 > a−4, whence a < 16, and c > a−4, with a and c odd, so c in {a−2, a, a+2, a+4, ...}; we require (c+a−4).(c+4−a) = 48; the case c = a necessarily yields b = a, the equilateral case already considered; any c > a+4 would yield c+4−a > 8 whence 2.a < c+a−4 < 48/8 = 6, making a < 3 but we already know a > 2, so c > a+4 can yield no solutions; the remaining cases, c = a−2, a+2 and a+4, yield solutions [a,c] = [15,13], [5,7] and [3,7], respectively.

Written by Eddy.