Pythagorean theorem and law of cosines
You can also download a PDF version of this article.
Proof of Pythagorean theorem
Based on geometric considerations, we are going to give proof for one of the most widely known identities in mathematics - the Pythagorean theorem. It states that the sides of a right triangle (that is, a triangle for which one of the inner angles measures [math]\displaystyle{ 90^\circ }[/math] or [math]\displaystyle{ \pi/2 }[/math] radians) of lengths [math]\displaystyle{ a }[/math], [math]\displaystyle{ b }[/math] and [math]\displaystyle{ c }[/math] satisfy the following identity:
[math]\displaystyle{ c^2 = a^2 + b^2.\qquad\qquad(1) }[/math]
Consider the triangle of sides [math]\displaystyle{ a }[/math], [math]\displaystyle{ b }[/math] and [math]\displaystyle{ c }[/math] marked in bold of Fig. 1. If we construct the system of triangles shown in the figure, then it is clear that the area of the bigger square is [math]\displaystyle{ (a+b)^2 }[/math]. The area of all the elements contained within must of course equal [math]\displaystyle{ (a+b)^2 }[/math]. There are four triangles of area [math]\displaystyle{ \frac{1}{2} a b }[/math] and one square of area [math]\displaystyle{ c^2 }[/math]. Hence, it must be
[math]\displaystyle{ (a+b)^2 = 4 \frac{1}{2} a b + c^2.\qquad\qquad(2) }[/math]
Expanding the parenthesis in Eq. (2) we have
[math]\displaystyle{ a^2 + b^2 + \cancel{2ab} = \cancel{2 a b} + c^2,\qquad\qquad(3) }[/math]
or
[math]\displaystyle{ a^2 + b^2 = c^2,\qquad\qquad(4) }[/math]
as we wanted to prove.
Law of cosines
The Pythagorean theorem is only valid for right triangles. There is a more general theorem, the law of cosines, that relates the lengths of the sides of any given triangle as
[math]\displaystyle{ c^2 = a^2 + b^2 - 2ab \cos\alpha,\qquad\qquad(5) }[/math]
where [math]\displaystyle{ \alpha }[/math] is the angle formed by the sides of lengths [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math], and opposite [math]\displaystyle{ c }[/math], as shown in Fig. 2. In that figure, the side of length [math]\displaystyle{ a }[/math] is extended to form a right triangle that will help prove the identity given by Eq. (5).
It is clear from Fig. 2 that [math]\displaystyle{ \beta = \pi - \alpha }[/math], in radians, or [math]\displaystyle{ \beta = 180^\circ - \alpha }[/math] in degrees. Here we prefer to work in radians, and so will use the former expression. Although usually it would suffice to say that
[math]\displaystyle{ \cos \beta = \cos \left( \pi - \alpha \right) = - \cos \alpha \qquad \text{and} }[/math]
[math]\displaystyle{ \sin \beta = \sin \left( \pi - \alpha \right) = \sin \alpha,\qquad\qquad(6) }[/math]
we are trying to make as few assumptions as possible. Therefore the geometric proof to Eq. (6) is given in Fig. 3. Having constructed a right triangle in Fig. 2 we can now relate the length of [math]\displaystyle{ c }[/math] to the other sides of the bigger triangle through the Pythagorean theorem:
[math]\displaystyle{ c^2 = \left( a - b\cos\alpha \right)^2 + \left( b\sin\alpha \right)^2.\qquad\qquad(7) }[/math]
Expanding the powers in parenthesis, one easily gets to
[math]\displaystyle{ c^2 = a^2 + b^2 \cos^2 \alpha -2ab\cos\alpha + b^2\sin^2\alpha.\qquad\qquad(8) }[/math]
Given the well known trigonometric relation [math]\displaystyle{ \cos^2\alpha + \sin^2\alpha = 1 }[/math] (the relation [math]\displaystyle{ \cos^2\alpha + \sin^2\alpha = 1 }[/math] can easily be proven using the Pythagorean theorem for a triangle for which [math]\displaystyle{ c=1 }[/math] and [math]\displaystyle{ \alpha }[/math] is the angle between [math]\displaystyle{ a }[/math] and [math]\displaystyle{ c }[/math]. It follows immediately that [math]\displaystyle{ a=\cos\alpha }[/math] and [math]\displaystyle{ b=\sin\alpha }[/math].), Eq. (8) reduces to
[math]\displaystyle{ c^2 = a^2 + b^2 - 2ab\cos\alpha,\qquad\qquad(9) }[/math]
which is the relation we wanted to prove.