The Pythagorean theorem has a correction term when the angle is not right. This term is the law of cosines.

Who discovered

The metric relations of this topic are in The Elements of Euclid (c. 300 BC), in area language: the proposition II.12 deals with the side opposite to an obtuse angle and II.13, opposite an acute angle. The cosine form, $a^2 = b^2 + c^2 - 2bc\cos A$, appeared much later, along with the trigonometric tables. The Persian astronomer Jamshid al-Kashi presented it in 1427, in The Key to Arithmetic; in France, the law of cosines is still called théorème d’Al-Kashi. François Viète wrote it with cosines in 1593.

The story

Euclid had no cosines or numbers for lengths. He said that the square on the side opposite the obtuse angle is greater than the sum of the squares on the other two sides “by twice the rectangle” formed by one side and the projection of the other. It’s the same relationship as this topic, written with areas.

Comparing $a^2$ with $b^2 + c^2$ comes a simple test: just know the three sides to know whether the triangle is acute, right or obtuse.

In everyday life

  • Navigation. A boat that travels 10 km, turns 40° and travels another 6 km is a distance from the port calculated by the law of cosines.
  • Robotics. The joint angles of a two-segment robotic arm are calculated by the law of cosines.
  • Topography. When two sides of a piece of land and the angle between them are measured, the third side falls outside the law of cosines.
  • Sports. Analysts calculate the distance of a pass based on the distances between two players and a third and the angle between them.

Sources: Elements, proposition II.12 · Elements, proposition II.13 · Al-Kashi (MacTutor).

Theory and constructions

Metric relationships

TeoremaSide opposite an acute angle

In any triangle, the square on the side opposite an acute angle is equal to the sum of the squares on the other two sides minus twice the product of one of these sides and the projection of the other onto it:

$$\hat A < 90^{\circ},\; m = \text{proj. de } b \text{ sobre } c \;\Longrightarrow\; a^2 = b^2 + c^2 - 2cm.$$

TeoremaSide opposite an obtuse angle

In an obtuse triangle, the square on the side opposite the obtuse angle is equal to the sum of the squares on the other two sides plus twice the product of one of these sides and the projection of the other onto it (or onto the straight line that contains it):

$$\hat A > 90^{\circ},\; m = \text{proj. de } b \text{ sobre } c \;\Longrightarrow\; a^2 = b^2 + c^2 + 2cm.$$
See the demonstration (joint for both cases)

Leading $\overline{CD} = h_c$, relative height to the side $c$, comes:

  • in $\triangle CDB$: $a^2 = h_c^2 + (c \mp m)^2$, with sign $-$ if $\hat A$ is acute and $+$ if $\hat A$ is obtuse;
  • at $\triangle CDA$: $h_c^2 = b^2 - m^2$.

Replacing: $a^2 = b^2 - m^2 + c^2 \mp 2cm + m^2$, that is,

$$a^2 = b^2 + c^2 - 2cm \quad (1) \qquad \text{ou} \qquad a^2 = b^2 + c^2 + 2cm \quad (2).$$

Cosine theorem

TeoremaCosine theorem (law 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 A, \qquad b^2 = a^2 + c^2 - 2ac\cos B, \qquad c^2 = a^2 + b^2 - 2ab\cos C.$$
View the demo

If $\hat A$ is acute: in $\triangle CDA$, $\cos A = \dfrac{m}{b}$, therefore $m = b\cos A$. Replacing in (1): $a^2 = b^2 + c^2 - 2c\,(b\cos A)$.

If $\hat A$ is obtuse: in $\triangle CDA$, $\cos(180^{\circ} - A) = \dfrac{m}{b}$, that is, $-\cos A = \dfrac{m}{b}$ and $m = -b\cos A$. Replacing in (2): $a^2 = b^2 + c^2 + 2c\,(-b\cos A)$.

In both cases, $a^2 = b^2 + c^2 - 2bc\cos A$. If $\hat A$ is straight, $\cos A = 0$ and we fall back on the Pythagorean theorem.

Drag the vertices. The panel checks the law of cosines for side b and classifies the triangle by its sides.

Recognizing the nature of a triangle

Knowing the measurements of the sides of a triangle, calling the largest of them $a$ and the other two $b$ and $c$ — and remembering that $|b - c| < a < b + c$ —, we recognize the nature of the triangle:

ResumoNature of a triangle

$a^2 < b^2 + c^2$ triangle acutangle
$a^2 = b^2 + c^2$ triangle rectangle
$a^2 > b^2 + c^2$ triangle obtuse angle

The demonstrations follow immediately from the previous relationships.