It occurred to me that in all the discussion about
Pythagoras' identity, and its generalization to general
triangles, the actual generalization (called the law
of cosines) was never explicitly stated. Here it is:
Given a triangle with side lengths a,b,c,
and with angle theta between the sides of length a and b,
the following identity holds:
c^2 = a^2 + b^2 - 2ab cos(theta)
Pythagoras' identity is just the special case where
theta is ninety degrees, so that cos(theta) is zero.
The other two special cases are theta = 0 and theta = 180 degrees.
For theta = 0:
c = abs(a-b), so that
c^2 = (a-b)^2
= a^2 + b^2 - 2ab
= a^2 + b^2 - 2ab cos(theta), since cos(theta)=1
For theta = 180 degrees:
c = a+b, so that
c^2 = (a+b)^2
= a^2 + b^2 + 2ab
= a^2 + b^2 - 2ab cos(theta), since cos(theta)= -1.
The general identity actually follows quickly from
Pythagoras' identity, since it is easy to construct a
right angled triangle with sides a - b cos(theta), b sin(theta), c
from the general a, b, c triangle.
It then follows that
c^2 = (a-bcos(theta))^2 + (b sin(theta))^2,
and then cos^2+sin^2=1 quickly gives us
c^2 = a^2 + b^2 - 2ab cos(theta).
Walter