The ancient greeks were particularly interested in one crucial implication
of Pythagoras' theorem: the existence of
lengths which are not rationally commensurate

. Given a line, one can
make arbitrarily long lines by repeating it and arbitrarily short lines by
sub-dividing it into equal parts; combining these operations one may make a line
of length arbitrarily close to any length one cares to nominate – but not
all lengths can be arrived at from a given one by duplication and equal
sub-division. Lines of lengths one *can* obtain from a given line by
such scaling and shrinking are said to be rationally commensurate with

the given line.

Let's start by looking (as the greeks did) at the right-angle triangle whose two perpendicular sides are of equal length; we may as well use this as unit of length, so we can see that the square on the hypotenuse has area 2. Now, plainly, every natural greater than 1 has square bigger than 2; while the remaining two naturals, 0 and 1, are their own squares and both less than 2. The negative integers' squares are the same as those of the positives, so 2 clearly isn't the square of any whole number.

Now consider any ratio of whole numbers whose square is a whole number. There are necessarily two coprime whole numbers p, q for which the ratio is p/q; so we have p.p = n.q.q for some whole number n. As both sides of this equation are whole numbers, we can prime-factorise both sides. Every prime factor that divides either side divides the left side, p.p, hence also p; and p is coprime to q, so no prime factor of either side divides q; but every prime factor of q divides the right side, n.q.q; so we must infer that q has no prime factors: i.e. q = 1. But then our ratio p/q is a whole number; so a rational whose square is a whole number must in fact be a whole number.

So not only is 2 not the square of any whole number but, as a result, it's
also not the square of any ratio of whole numbers; a right-angle triangle whose
perpendicular sides are equal has a hypotenuse that isn't rationally
commensurate with them. Such a number, that isn't the ratio of any whole
numbers, is described as irrational – as it happens, there are vastly more
of these than there are of the rationals; but that's a topic for another
page. What matters, for now, is that a right-angle triangle, whose
perpendicular sides are of equal length, has a hypotenuse whose length isn't
rationally commensurate with this length. The rest of this page is devoted to
the study of right-angle triangles – and their higher-dimensional peers,
the simplices – whose sides *are* rationally commensurate.

I'll describe a
right-angle triangle as **pythagorean** precisely if its sides'
lengths are rationally commensurate. (One may likewise
pose the corresponding question for non-right
angles.)

If one length is rationally commensurate with another, duplicating the first
one number of times and the second another number of times will produce lines of
equal length, if we chose the numbers correctly; equivalently, sub-dividing each
into suitably many equal pieces will yield a unit for which each is obtained by
duplicating the unit. Thus being rationally commensurate is a symmetric
relationship. If lengths K and L are rationally commensurate and L is also
rationally commensurate with M, then there are some whole numbers k and m for
which dividing L into k equal parts gives a length that, when duplicated enough,
yields K; while dividing L into m equal parts gives a unit of which M is a
multiple. So dividing L into k.m equal parts gives a length of which both K and
M are multiples; thus K and M are also rationally commensurate and rationally
commensurate

is transitive. Since it is fatuously reflexive (every length
is rationally commensurate with itself) it is thus an equivalence relation.

To classify pythagorean triangles, it suffices to consider the case where our right-angle triangle's lengths are all whole multiples of some given unit; this reduces our description of the triangle to three whole numbers. The question thus reduces to finding cases where one perfect square (that is, the square of a whole number) is equal to the sum of two others.

Scaling a pythagorean triangle necessarily produces a pythagorean triangle; just scale the unit used for the original to get a unit that describes the scaled triangle's sides using the same numbers, whose squares haven't changed so still satisfy Pythagoras's equation. Sub-dividing our unit likewise just increases the numbers we use to describe the lengths of the edges, all by some common factor i, a whole number; if n.n +m.m = k.k then, i.n.i.n +i.m.i.m = i.k.i.k, so any whole-number scaling of a solution to our problem is, trivially, another solution. So we can scale up our three whole numbers by a common factor to turn one solution into another, albeit one that's not interestingly different.

Given that we can do this, it's sufficient to classify the solutions that have no common factor, since all others can be obtained from these by such scalings. If two of the sides share a common factor i then their squares have i.i as a common factor; hence the sum or difference of thsese squares, which is the square of the other side, also has i.i as a factor; hence the other side has i as a factor. Thus any common factor of two of the sides is in fact a common factor of all three, so we only need to consider cases where no two sides have any common factor; the three sides are mutually comprime.

In particular, at most one of the sides has two as a factor so at least two sides have odd lengths. Any odd number is 2.n +1 for some whole number n; its square is then (2.n).(2.n) +2.(2.n) +1 = 4.n.n +4.n +1 = 4.n.(n+1) +1. Of any two adjacent whole numbers, such as n and n+1, one is odd and the other is even; so n.(n+1) is even and 4.n.(n+1) is a multiple of eight. Thus the square of any odd number is one more than a multiple of eight; so the two odd sides have squares whose difference is a multiple of eight and whose sum is two more than a multiple of eight; one of these is the square of the other side, which thus isn't one more than a multiple of eight, so that other side isn't odd. Those even numbers that are twice an odd number have squares that are four more than a multiple of (32 hence also of) eight; all other even numbers are multiples of four so have squares that are multiples of 16, hence in particular of eight. So our pythagorean equation n.n +m.m = k.k, in which two terms are one more than multiples of eight, must have these two terms on opposite sides of the equation with the remaining term equal to a multiple of eight; i.e. the hypotenuse is odd, as is one of the other two sides, and the remaining side's square is a multiple of eight.

If we write out the prime factorisation of some side and double the multiplicity of each prime as a factor in it, we get a prime factorisation of the side's square in which every prime's multiplicity is even. As prime factorisation of integers is unique, any factorisation of the square of a side must have only even powers of each prime used. So the squared side with a factor of eight, hence at least three factors of two, must in fact have at least four (the smallest even that's at least three) factors of two and the side in question must have two factors of two, hence be a multiple of four. So our hypotenuse is odd, as is one of the other sides, and the remaining side is a multiple of four.

Suppose, then, that m is the multiple of four, with k and n odd; we have n.n = k.k −m.m = (k +m).(k −m) with k, n, m coprime. As k and m are coprime, k ±m are also coprime (had k and m both been odd, k ±m would have shared two as a common factor; but this is not the case); and their product is n.n, a perfect square. With {x, y} = {k ±m} in either order, any prime factor p of x is a prime factor of x.y = n.n hence also of n, hence has even multiplicity as a factor of n.n = x.y; but p is not a factor of y, hence p in fact has even multiplicity as a factor of x; thus the prime factorisation of x only has even multiplicities for its prime factors and x is a perfect square. Thus k ±m are mutually coprime odd perfect squares.

In particular, the two odd numbers whose squares are k ±m have product n; and we can obtain k and m from them as the mean and half-difference of their squares. Thus, for any coprime pythagorean triangle, there are naturals u, v with v > u for which k +m = 4.v.(v+1) +1, k −m = 4.u.(u +1) +1 and:

- k = 2.(v.(v +1) +(u +1).u) +1,
- m = 2.(v.(v +1) −(u +1).u) and
- n = (2.v +1).(2.u +1).

Furthermore, for any naturals u, v, we can compute k, m and n as above; they might not be coprime, but they do always satisfy n.n = (k +m).(k −m) = k.k −m.m hence k.k = n.n +m.m, so they do describe a pythagorean triangle, even if it's not coprime. (For example, [v,u] = [4,1] yields [45,36,27] which just scales the familiar [5,4,3] from [v,u] = [1,0] by a factor of 9.) Every pythagorean triangle is a whole multiple of some triangle generated in this way. Note that the hypotenuse, k, is always one more than a multiple of four (since both u.(u+1) and v.(v+1) are even). The above formulae can be re-written, by a substitution p = v+u+1, q = v−u, as p.p +q.q, 2.p.q and p.p −q.q, respectively, with p > q and p−q odd; for the three sides to be coprime, p and q must be coprime; this reformulation is known as Euclid's formula for generating pythagorean triangles. If your browser supports SVG (and CSS floats), you should see the first 58 distinct hypotenuses (with short side horizontal and intermediate side vertical) depicted at left (possibly above); these are all the examples with 0 ≤ u < v < 12.

In particular, this means that the set of pairs of rationals whose sum is 1,
i.e. the set of points on the unit circle of the two-dimensional rational plane,
is countable – it is a union of two images (using the perpendicular sides
above in each order) of the set of pairs of naturals [u, v], via the
combinations of them used to make the two perpendicular sides above. These give
us (countably many) angles whose Sin and Cos are rational. (Technically, these
are all in the first quadrant (from zero through a quarter turn); we can add and
subtract them to obtain angles in the full range, still with rational Sin and
Cos – but this in fact necessarily just gives the same set of angles as
adding multiples of a quarter turn to the ones obtained directly, since each
implies a pythagorean triangle, albeit in another quadrant.) While this set of
angles *is* (though I have not shown this) dense in the turn, it leaves
plenty of gaps in the unit circle of the rational plane; e.g. the line {[r, r]:
r is a positive rational} runs from [0,0] inside the unit circle to outside that
circle but has no intersection with the circle.

A simplex is the generalisation of a triangle to other than two dimensions;
the triangle is the two-simplex, the tetrahedron is the three-simplex, a simple
line segment is the one-simplex and a point is the zero-simplex. For any
natural n, {mappings ({positives}:f:1+n): sum(f) = 1} provides
a canonical

(open) n-simplex. However, I'm here more interested in a
less symmetric n-simplex – namely, one in which n of the edges are (of
non-zero length and) mutually perpendicular.

One important feature of a simplex is that each vertex is connected to every
other vertex by an edge (and, in fact, for every set of i vertices, there is an
i-simplex face

of the simplex which has these vertices as its
corners). Given a set of edges, a path

among those edges is a list
(:f:1+i) of vertices among which, for each j in i, f(j) and f(1+j) are connected
by one of the edges in our set; f(0) and f(i) are described as the ends

of the path and the path is described as a path between these two vertices, or
from f(0) to f(i). A set of edges is connected if, between any two vertices of
edges in the set, there is some path within the set.

A path is closed

if its ends are the same vertex; i.e. f(0) is
f(i). This is easy to achieve by traversing some sequence of edges and then
simply reversing the sequence of edges to come back to where you started; but
this is the boring case. If you can get back to where you started without doing
that, then your path can be reduced to one which never re-uses an edge; a path
is described as a closed loop

if it is closed and uses each edge at most
once. Among a set of mutually perpendicular edges there is, necessarily, no
closed loop. A path among some edges, among which there is no closed loop, can
always be reduced to a path that uses each edge at most once.

A set of i edges (for positive natural i), with as few vertices as possible subject to containing no closed loop, always has i+1 vertices and is connected: when i is 1, this is trivial. Thereafter, each added edge must add at least one vertex – because the prior edges are connected, so connecting two of their vertices would form a loop. If all vertices are reached by prior edges, it is no longer possible to add an edge without creating a loop; otherwise, connecting any vertex of an existing edge to any vertex not reached by existing edges does indeed add only the one vertex it must, to the set of edges, without adding a closed loop. If we have n edges of an n-simplex and no closed loop, this requires us to use all 1+n vertices that our n-simplex has; and (since this means our set of edges uses as few vertices as possible, while having no closed loop) ensures that they are all connected. So any n mutually perpendicular edges of an n-simplex are necessarily all connected and reach every vertex.

Every vertex of our n-simplex is an end of at least one of our mutually perpendicular edges; and the mutually perpendicular edges are all connected, so there is some path among these edges from any given vertex to any other. As there are no closed loops, this path need only use each edge at most once; and there is only one such path, for each given pair of vertices. Thus, for every edge of our n-simplex, there is such a path connecting its end-points; if this path traverses i edges (once each), I'll refer to the edge whose end-points it connects as an i-hypotenuse of our n-simplex. Each of our perpendicular edges is a 1-hypotenuse (which is boring).

If the n mutually perpendicular edges form a path, that uses each edge exactly once, then we have an n-hypotenuse and, for each positive i in n, each n−i sub-path of length i provide us with an i-hypotenuse. However, if three (or more) of the perpendicular edges meet in one vertex, no path among the perpendicular edges can use each exactly once; at most two of the edges at any given vertex can appear in any such path, as we have no closed loops.

In two dimensions, we had two perpendicular sides to a triangle and they couldn't avoid forming a connected path, so life was simple: we only had one other side and it was a 2-hypotenuse. In higher dimensions, we have more things to consider:

- We can restrict attention to the case with a single n-hypotenuse,
- We can consider all the i-hypotenuses, for each i in n, or
- We can restrict attention to the case where all the perpendicular edges meet in one vertex; all other edges are 2-hypotenuses.

This leads to various possible analogues of pythagorean

that we
could investigate for n-simplices with n perpendicular sides. Describe an edge
as tidy

, for present purposes, precisely if its length is rationally
commensurate with those of the perpendicular sides. No edge can be tidy unless
all the mutually perpendicular edges have rationally commensurate lengths, of
course. We could study n-simplices with n perpendicular edges and all edges
tidy. A little less generally, we could restrict attention to the case where
the perpendicular edges form a path. As a simplified case of this, we could
ignore all edges except the n-hypotenuse; this amounts to looking for lists
({naturals}:|n) whose sum of squares is a perfect square.

Refining the simplest notion slightly, we can ask for lists of naturals where each initial sub-list has a perfect square as its sum of squares; thus, for example, [3, 4, 12, 84, 132] has 3×3 +4×4 = 5×5; adding 12×12 to that we get 13×13; adding 84×84 to that we get 85×85; and adding 132×132 to that we get 157×157. Each of [3, 4], [3, 4, 12], [3, 4, 12, 84] is an initial prefix of the list and has a perfect square as its sum of squares. This means we can have an n-simplex with these as the lengths of successive perpendicular edges, such that each i-hypotenuse associated with a path starting from the start of the first edge is tidy. However, notice that 4×4+12×12 = 160 isn't a perfect square, so at least one of the other other 2-hypotenuses isn't tidy.

From the above, it should be clear that we can build such incrementally
pythagorean lists quite straightforwardly; indeed, in the example above, [3, 4,
12, 84] follow a pattern that can be continued indefinitely. As 3 is odd, its
square is the sum of adjacent naturals, 4 and 5, hence equal to the difference
of their squares, so [3, 4] has length 5. Then 5×5 is odd and likewise
12+13, so [5, 12] has length 13, whose odd square is 84+85, so [13, 84] has
length 85; whose square is 7225 = 3612 +3613, so [85, 3612] has length 3613,
which is (inevitably) odd again, so we can keep doing this for ever. Such a
list grows rapidly, approximating (: 2.power(power(2, 1+i), x/2) ←i :) for
some x, but can clearly be done for any odd start-value: for example, [7, 24,
312, 48984]. None the less, as illustrated above, they're not the only game in
town; we *could* use 132 after 84 instead of 3612.

Even so, all cases of this kind can be built using the two-dimensional pythagorean triangles, incrementally: the sum of squares of the first n entries in such a list is the square of some natural, p, so any pythagorean triangle of which p is a perpendicular side can be used to obtain the other perpendicular side as n-th entry in the list, making the hypotenuse take the place of p for the thus-extended list.

Written by Eddy.