Skip to content

Perspectives on Pythagoras’ Theorem

To teach myself \( \LaTeX \) in 2015 – 2016, I’d often write mock tests, assignments, and even write random articles on various basic mathematical topics. This is an extended version of one of those random articles, on Pythagoras’ theorem, Pythagorean triples and Dijkstra’s generalisation.

One of the fundamental things we are taught in geometry (at least in normal Euclidean geometry) is that the square of the hypotenuse of a right-angled triangle is equal to the sum of the squares of its other two sides, i.e. \( a^2 + b^2 = c^2 \). Its simplicity and elegance beguiles its immense historical importance, which sadly is often not expanded upon when the theorem is first encountered in school. There are hundreds of proofs of the theorem, and I will not be reinventing the wheel here. I will, however, discuss some aspects of the Pythagorean theorem that I wish I had learned in school (insofar as they show how interconnected otherwise disparate math concepts actually are), and which I think ought to be taught.

Pythagorean Triples

It’s all well and good to study the right angled triangles, but what about the numbers themselves? Suppose we have three integers \( a, b, c \) where \( a < b < c \) and \( a^2 + b^2 = c^2 \). Then \( (a,b,c) \) is called a Pythagorean triple.

Note that if \( (a, b, c) \) is a Pythagorean triple, then so too is \( ( ka, kb, kc ) \) for some integer \( k \) since \( k(a^2 + b^2) = kc^2 \). This motivates the definition of a Primitive Pythagorean triple (PPT), which is so defined when all of \( a, b, c \) are coprime (i.e. they share no common factors).

The simplest PPT is \( (3, 4, 5 ) \). Note that \( (6, 8, 10) \), while a valid Pythagorean triple, is not primitive since \( 6, 8 \) and \( 10 \) share a common factor of \( 2 \).

Euclid’s Formula

How can we find Pythagorean triples? Apart from mere trial and error, we can use the following formula, devised by Euclid:

Let \( m, n \in \mathbb{Z} \) where \( m > n \). Then \[ (m^2 – n^2, 2mn, m^2 + n^2) \] is a Pythagorean triple.

Clearly we recover \( (3, 4, 5) \) using \( m = 2, n = 1 \), and \( m = 3, n = 1 \) gives \( (8, 6, 10) \). Euclid’s formula can generate PPTs so long as \( m \) and \( n \) are coprime and have opposite parity (i.e. if one is even, the other must be odd). With this formula, solving Project Euler’s ninth problem should be straightforward.

Barning’s Tree

Suppose we just want to generate PPTs by themselves. The Dutch mathematician Barning showed it was possible to generate a tree of PPTs using the following matrix transformations: \[ A = \begin{bmatrix} 1 & -2 & 2 \\ 2 & -1 & 2 \\ 2 & -2 & 3 \end{bmatrix} \quad B = \begin{bmatrix}1 & 2 & 2 \\ 2 & 1 & 2 \\ 2 & 2 & 3\end{bmatrix} \quad C = \begin{bmatrix}-1 & 2 & 2 \\ -2 & 1 & 2 \\ -2 & 2 & 3\end{bmatrix}\] where each transformation generates a unique PPT. Starting with \( (3, 4, 5) \) we get \[ \begin{bmatrix} 1 & -2 & 2 \\ 2 & -1 & 2 \\ 2 & -2 & 3 \end{bmatrix} \times \begin{bmatrix}3 \\ 4 \\ 5\end{bmatrix} = \begin{bmatrix}5 \\ 12 \\ 13\end{bmatrix}\] Repeatedly performing these transformations ultimately yields the following tree:

and so on to infinity. Why go through all this trouble? Due to their unique properties – especially being coprime – PPTs have been proposed as a basis for cryptographic hashes.

What’s pi doing there?

I encountered a coding challenge that asked a simple question: how many PPTs are there with a hypotenuse of less than 1000? Turns out there are exactly 158. How about the number of PPTs with hypotenuses less than 1 million? Let’s consider the following sequence (A101931), which lists the number of PPTs with hypotenuses less than \( 10^n \) for \( n = 1, 2, \ldots, 9 \): \[ 1, 16, 158, 1593, 15919, 159139, 1591579, 15915492, 159154994 \] That is, there 159154994 PPTs with hypotenuse lengths of less than 1 billion. It’s curious to note how the digits begin to slowly converge to 15915499[…]. It behaves like a decimal infinite expansion. Like \( \pi \). In 1900, the mathematician D.N. Lehmer proved that: \[ \lim_{n\to\infty} \frac{ \text{ppt}(N)}{N} = \frac{1}{2\pi} \] In other words, the number of PPTs with hypotenuses less than \( N \) is roughly equal to \( N / 2\pi \). Where does the \( \pi \) come from? It comes from the density of points within a section of a circle, although the exact specifics are beyond the scope of this post.

For more on Pythagorean triples, check out this Mathworld article. Or, simply open up Python and start calculating and/or visualising them. You may be surprised by what patterns you find.

Generalisations

One of the beauties of Pythagoras’ theorem is its many generalisations – not just directly to higher dimensions or non right-angled triangles – but also to other areas of mathematics, such as Hilbert spaces and Grassman algebras (important for quantum mechanics). One elegant generalisation by Charles Frohman is as follows. Let \( A \) be an \( n \times k \) matrix. Then \[ \text{det}\left(A^T A\right) = \sum_I \text{det} \left(A_I\right)^2 \] which essentially relates the the square of the parallelepiped spanned by \( A \) to the squares of its orthogonal projections in \( k \)-dimensions.

One generalisation that I believe should get more attention, especially when Pythagoras’ theorem is first taught, is the generalisation by Edsger W. Dijkstra. You may well be familiar with the name “Dijkstra” if you’ve needed to find the shortest path between two vertices in a graph (or if you’re part of the Redanian Secret Service). Let’s first express the Pythagorean theorem in a slightly different form. Let \( a, b, c\) be the sides of a right-angled triangle with hypotenuse \( c \). Let \( \alpha, \beta, \gamma \) be the interior angles of the triangle such that \( \alpha \) is the angle opposite side \( a \), \( \beta \) opposite side \( b \), and \( \gamma \) opposite side \( c \). If \( \gamma = \pi/2 \), then \( a^2 + b ^2 = c^2 \). Note here we are using radians instead of degrees. This also implies that \( \alpha + \beta + \gamma = \pi \). We can effectively write the following: \[ \alpha + \beta = \gamma \equiv a^2 + b^2 = c^2 \] So we can express the Pythagorean theorem in terms of angles rather than sides. What happens if the triangle is acute \( (\alpha + \beta > \gamma) \) or obtuse \( (\alpha + \beta < \gamma) \)? We find that \begin{align*} \alpha + \beta < \gamma &\equiv a^2 + b^2 < c^2 \\ \alpha + \beta > \gamma &\equiv a^2 + b^2 > c^2 \end{align*}

Dijkstra’s generalisation

Dijkstra’s generalisation is to compress all three statements into a single line:

\[ \text{sgn}(\alpha+\beta-\gamma) = \text{sgn}(a^2+b^2-c^2) \]

where sgn is the signum function and returns 1 if the argument is positive, -1 if it is negative, and 0 if it is equal to 0. Not only does this encode Pythagoras’ theorem, but also encodes the general relationship between sides and angles for all types of triangles, all in a single, symmetric expression.

One of these days I would like to find a convincing explanation of the circumstance that youngsters continue to be educated with the theorem of Pythagoras in its diluted form…

Edsger W. Dijkstra