The two laws in this topic are the main tools for working with triangles that are not right angles. Both are demonstrated by reducing the problem to right triangles: plotting a height, in the first, and a diameter, in the second.

The story

In geometric form, the law of cosines is already found in Euclid’s The Elements (book II, propositions 12 and 13), which compare the square on the opposite side to an obtuse or acute angle with the sum of the squares of the other two — without talking about cosine, of course. In trigonometric form, it appears in Miftah al-hisab (“The Key to Arithmetic”, 1427) of the Persian astronomer Jamshid al-Kashi, and that is why the French call it Al-Kashi’s theorem. The law of sines for flat triangles was enunciated and demonstrated in the 13th century by Nasir al-Din al-Tusi, in his Treatise on the quadrilateral, the first work to treat trigonometry as a discipline independent of astronomy (see chapter III).

  1. c. 300 a.C.
    Euclid (The Elements II.12–13): the law of cosines in geometric form.
  2. century. X
    Abu al-Wafa and others: the law of sines for spherical triangles.
  3. century. XIII
    al-Tusi: the law of sines for flat triangles.
  4. 1427
    al-Kashi: the law of cosines in trigonometric form.
  5. c. 1464
    Regiomontanus takes both laws to Europe.

Sources: Al-Kashi (MacTutor) · Al-Tusi (MacTutor) · Euclid, The Elements, book II, propositions 12 and 13.

In everyday life

  • Ships and planes. Two ships leave the same port on routes that form $60^\circ$; when one is 8 km away and the other is 5 km away, the distance between them is $\sqrt{64 + 25 - 2 \cdot 8 \cdot 5 \cdot \frac{1}{2}} = 7$ km.
  • Robots and prosthetics. An arm with two segments of known lengths reaches a point at a certain distance only if the “elbow” bends at the angle given by the law of cosines — this is the calculation that every robotic arm makes.
  • Measure what cannot be reached. With a measured base and two angles, the law of sines gives the distance to an island, a peak or a tower on the other side of the river.
Two ships leave the same port: the law of cosines gives the distance between them.

Theory

Law of cosines

TeoremaLaw of cosines

In any triangle, the square of one side is equal to the sum of the squares of the other two sides minus twice the product of these two sides and the cosine of the angle formed by them:

$$a^2 = b^2 + c^2 - 2bc\cos\hat{A}$$$$b^2 = a^2 + c^2 - 2ac\cos\hat{B}$$$$c^2 = a^2 + b^2 - 2ab\cos\hat{C}$$
View the demo

Let $\overline{BD}$ be the height relative to the side $\overline{AC}$, measuring $h$, and $m = AD$.

1st case: $\hat{A} < 90^\circ$. The point $D$ falls on the same side of $A$ as $C$, and $n = DC = b - m$ (left figure, with $D$ between $A$ and $C$; if $D$ falls beyond $C$, $n = m - b$, and the accounts are the same). In right triangles $BCD$ and $BAD$:

$$a^2 = n^2 + h^2 \;(\text{I}) \qquad h^2 = c^2 - m^2 \;(\text{II}) \qquad n = b - m \;(\text{III}).$$

Taking (III) and (II) into (I): $a^2 = (b - m)^2 + c^2 - m^2 = b^2 + c^2 - 2bm$. But, in the triangle $BAD$, $m = c\cos\hat{A}$; logo $a^2 = b^2 + c^2 - 2bc\cos\hat{A}$.

2nd case: $90^\circ < \hat{A} < 180^\circ$. Now $D$ falls in the extension of $\overline{CA}$, in addition to $A$, and $DC = b + m$ (figure on the right). Likewise, $a^2 = (b + m)^2 + c^2 - m^2 = b^2 + c^2 + 2bm$. In triangle $BAD$, the angle at $A$ is $180^\circ - \hat{A}$, so $m = c\cos(180^\circ - \hat{A}) = -c\cos\hat{A}$; again $a^2 = b^2 + c^2 - 2bc\cos\hat{A}$.

3rd case: $\hat{A} = 90^\circ$. It is the Pythagorean theorem, because $\cos 90^\circ = 0$.

The other two formulas are proven in the same way, exchanging the roles of the vertices.

PropriedadeGeneralized Pythagoras

The law of cosines says exactly how much $a^2$ differs from $b^2 + c^2$: if $\hat{A}$ is acute, $a^2 < b^2 + c^2$; if it is straight, $a^2 = b^2 + c^2$; if it is obtuse, $a^2 > b^2 + c^2$. Applied to the longest side, it classifies the triangle (exercise 372).

Law of sines

TeoremaLaw of sines

In any triangle, the quotient between each side and the sine of the opposite angle is constant and equal to the measurement of the diameter of the circumscribed circle:

$$\frac{a}{\operatorname{sen}\hat{A}} = \frac{b}{\operatorname{sen}\hat{B}} = \frac{c}{\operatorname{sen}\hat{C}} = 2R$$
View the demo

Let $ABC$ be a triangle inscribed in a circle of radius $R$. Through the vertex $B$, let’s draw the diameter $\overline{BA'}$ and connect $A'$ to $C$.

The angles $\hat{A}$ and $\hat{A}'$ are equal, as they are inscribed and determine the same chord $\overline{BC}$ on the circle. The triangle $A'BC$ is rectangular in $C$, as it is inscribed in a semicircle. Then

$$a = BC = BA' \cdot \operatorname{sen}\hat{A}' = 2R\operatorname{sen}\hat{A} \;\Longrightarrow\; \frac{a}{\operatorname{sen}\hat{A}} = 2R.$$

(If $\hat{A}$ is obtuse, $A$ and $A'$ are on opposite sides of $\overline{BC}$ and $\hat{A}' = 180^\circ - \hat{A}$, which have the same sine; if $\hat{A}$ is straight, $\overline{BC}$ is already diameter.) Similarly, $\frac{b}{\operatorname{sen}\hat{B}} = 2R$ and $\frac{c}{\operatorname{sen}\hat{C}} = 2R$.

To go further: the angle between two vectors

The law of cosines has a translation into coordinates. Let $\vec A = (a_1, a_2, a_3)$ and $\vec B = (b_1, b_2, b_3)$ be two sides of a triangle starting from a common vertex, with angle $\theta$ between them; the third side is $\vec A - \vec B$. The law of cosines says that

$$|\vec A - \vec B|^2 = |\vec A|^2 + |\vec B|^2 - 2|\vec A||\vec B|\cos\theta.$$

Developing the left side in coordinates, $(a_1 - b_1)^2 + (a_2 - b_2)^2 + (a_3 - b_3)^2 = |\vec A|^2 + |\vec B|^2 - 2(a_1b_1 + a_2b_2 + a_3b_3)$. Comparing:

$$a_1b_1 + a_2b_2 + a_3b_3 = |\vec A||\vec B|\cos\theta.$$

The sum on the left is the scalar product $\vec A \cdot \vec B$, and it gives the angle between two vectors without drawing anything: $\cos\theta = \dfrac{\vec A \cdot \vec B}{|\vec A||\vec B|}$.

ExemploAn angle in space

For $\vec A = (-2, 3, 1)$ and $\vec B = (1, 2, 3)$: $\vec A \cdot \vec B = -2 + 6 + 3 = 7$ and $|\vec A| = |\vec B| = \sqrt{14}$. Then $\cos\theta = \frac{7}{14} = \frac{1}{2}$ and $\theta = 60^\circ$.

In physics, the scalar product appears in the work of a force: a force $F$ that displaces a body of $d$ in a direction that forms an angle $\theta$ with it and does work $F\,d\cos\theta$. Only the component of the force in the direction of movement, $F\cos\theta$, counts.

The exercises in this section are numbers 360 to 392 from chapter list.