Book II of Euclid's Elements, compiled c. 300 BC from material up to a century or two older, contains a geometric theorem corresponding to the law of cosines but expressed in the contemporary language of rectangle areas; Hellenistic trigonometry developed later, and sine and cosine per se first appeared centuries afterward in India.
In his (now-lost and only preserved through fragmentary quotations) commentary, Heron of Alexandria provided proofs of the converses of both II.12 and II.13.
[4] The 13th century Persian mathematician Naṣīr al-Dīn al-Ṭūsī, in his Kitāb al-Shakl al-qattāʴ (Book on the Complete Quadrilateral, c. 1250), systematically described how to solve triangles from various combinations of given data.
[5] About two centuries later, another Persian mathematician, Jamshīd al-Kāshī, who computed the most accurate trigonometric tables of his era, also described the solution of triangles from various combinations of given data in his Miftāḥ al-ḥisāb (Key of Arithmetic, 1427), and repeated essentially al-Ṭūsī's method, now consolidated into one formula and including more explicit details, as follows:[6] Another case is when two sides and the angle between them are known and the rest are unknown.
We take the square root of the sum to get the remaining side....Using modern algebraic notation and conventions this might be written
is positive; historically sines and cosines were considered to be line segments with non-negative lengths.)
[8][9] The same method used by al-Ṭūsī appeared in Europe as early as the 15th century, in Regiomontanus's De triangulis omnimodis (On Triangles of All Kinds, 1464), a comprehensive survey of plane and spherical trigonometry known at the time.
At the beginning of the 19th century, modern algebraic notation allowed the law of cosines to be written in its current symbolic form.
Using d to denote the line segment CH and h for the height BH, triangle AHB gives us
Euclid's proof of his Proposition 13 proceeds along the same lines as his proof of Proposition 12: he applies the Pythagorean theorem to both right triangles formed by dropping the perpendicular onto one of the sides enclosing the angle γ and uses the square of a difference to simplify.
However, this problem only occurs when β is obtuse, and may be avoided by reflecting the triangle about the bisector of γ.
This proof is independent of the Pythagorean theorem, insofar as it is based only on the right-triangle definition of cosine and obtains squared side lengths algebraically.
Other proofs typically invoke the Pythagorean theorem explicitly, and are more geometric, treating a cos γ as a label for the length of a certain line segment.
[13] Unlike many proofs, this one handles the cases of obtuse and acute angles γ in a unified fashion.
An advantage of this proof is that it does not require the consideration of separate cases depending on whether the angle γ is acute, right, or obtuse.
Referring to the diagram, triangle ABC with sides AB = c, BC = a and AC = b is drawn inside its circumcircle as shown.
Now the law of cosines is rendered by a straightforward application of Ptolemy's theorem to cyclic quadrilateral ABCD:
Figure 7a shows a heptagon cut into smaller pieces (in two different ways) to yield a proof of the law of cosines.
Figure 7b cuts a hexagon in two different ways into smaller pieces, yielding a proof of the law of cosines in the case that the angle γ is obtuse.
Drop the perpendicular from A onto a = BC, creating a line segment of length b cos γ.
The tangent h forms a right angle with the radius b (Euclid's Elements: Book 3, Proposition 18; or see here), so the yellow triangle in Figure 8 is right.
Drop the perpendicular from A onto a = BC, creating a line segment of length b cos γ.
Construct the circle with center A and radius b, and a chord through B perpendicular to c = AB, half of which is h = BH.
This proof uses the power of a point theorem directly, without the auxiliary triangles obtained by constructing a tangent or a chord.
When a = b, i.e., when the triangle is isosceles with the two sides incident to the angle γ equal, the law of cosines simplifies significantly.
In situations where this is an important concern, a mathematically equivalent version of the law of cosines, similar to the haversine formula, can prove useful:
In the limit of an infinitesimal angle, the law of cosines degenerates into the circular arc length formula, c = a γ.
As in Euclidean geometry, one can use the law of cosines to determine the angles A, B, C from the knowledge of the sides a, b, c. In contrast to Euclidean geometry, the reverse is also possible in both non-Euclidean models: the angles A, B, C determine the sides a, b, c. A triangle is defined by three points u, v, and w on the unit sphere, and the arcs of great circles connecting those points.
If these great circles make angles A, B, and C with opposite sides a, b, c then the spherical law of cosines asserts that all of the following relationships hold:
The law of cosines can be generalized to all polyhedra by considering any polyhedron with vector sides and invoking the divergence Theorem.