500px|thumb|Berggrens's tree of primitive Pythagorean triples.
In mathematics, a tree of primitive Pythagorean triples is a data tree in which each node branches to three subsequent nodes with the infinite set of all nodes giving all (and only) primitive Pythagorean triples without duplication.
A Pythagorean triple is a set of three positive integers a, b, and c having the property that they can be respectively the two legs and the hypotenuse of a right triangle, thus satisfying the equation
a2+b2=c2
F. J. M. Barning showed[2] that when any of the three matrices
\begin{array}{lcr} A=\begin{bmatrix}1&-2&2\ 2&-1&2\ 2&-2&3\end{bmatrix}& B=\begin{bmatrix}1&2&2\ 2&1&2\ 2&2&3\end{bmatrix}& C=\begin{bmatrix}-1&2&2\ -2&1&2\ -2&2&3\end{bmatrix} \end{array}
It can be shown inductively that the tree contains primitive Pythagorean triples and nothing else by showing that starting from a primitive Pythagorean triple, such as is present at the initial node with (3, 4, 5), each generated triple is both Pythagorean and primitive.
If any of the above matrices, say A, is applied to a triple (a, b, c)T having the Pythagorean property a2 + b2 = c2 to obtain a new triple (d, e, f)T = A(a, b, c)T, this new triple is also Pythagorean. This can be seen by writing out each of d, e, and f as the sum of three terms in a, b, and c, squaring each of them, and substituting c2 = a2 + b2 to obtain f2 = d2 + e2. This holds for B and C as well as for A.
The matrices A, B, and C are all unimodular—that is, they have only integer entries and their determinants are ±1. Thus their inverses are also unimodular and in particular have only integer entries. So if any one of them, for example A, is applied to a primitive Pythagorean triple (a, b, c)T to obtain another triple (d, e, f)T, we have (d, e, f)T = A(a, b, c)T and hence (a, b, c)T = A−1(d, e, f)T. If any prime factor were shared by any two of (and hence all three of) d, e, and f then by this last equation that prime would also divide each of a, b, and c. So if a, b, and c are in fact pairwise coprime, then d, e, and f must be pairwise coprime as well. This holds for B and C as well as for A.
To show that the tree contains every primitive Pythagorean triple, but no more than once, it suffices to show that for any such triple there is exactly one path back through the tree to the starting node (3, 4, 5). This can be seen by applying in turn each of the unimodular inverse matrices A−1, B−1, and C−1 to an arbitrary primitive Pythagorean triple (d, e, f), noting that by the above reasoning primitivity and the Pythagorean property are retained, and noting that for any triple larger than (3, 4, 5) exactly one of the inverse transition matrices yields a new triple with all positive entries (and a smaller hypotenuse). By induction, this new valid triple itself leads to exactly one smaller valid triple, and so forth. By the finiteness of the number of smaller and smaller potential hypotenuses, eventually (3, 4, 5) is reached. This proves that (d, e, f) does in fact occur in the tree, since it can be reached from (3, 4, 5) by reversing the steps; and it occurs uniquely because there was only one path from (d, e, f) to (3, 4, 5).
The transformation using matrix A, if performed repeatedly from (a, b, c) = (3, 4, 5), preserves the feature b + 1 = c; matrix B preserves a – b = ±1 starting from (3, 4, 5); and matrix C preserves the feature a + 2 = c starting from (3, 4, 5).
A geometric interpretation for this tree involves the excircles present at each node. The three children of any parent triangle “inherit” their inradii from the parent: the parent’s excircle radii become the inradii for the next generation.[6] For example, parent (3, 4, 5) has excircle radii equal to 2, 3 and 6. These are precisely the inradii of the three children (5, 12, 13), (15, 8, 17) and respectively.
If either of A or C is applied repeatedly from any Pythagorean triple used as an initial condition, then the dynamics of any of a, b, and c can be expressed as the dynamics of x in
xn+3-3xn+2+3xn+1-xn=0
which is patterned on the matrices' shared characteristic equation
λ3-3λ2+3λ-1=0.
If B is applied repeatedly, then the dynamics of any of a, b, and c can be expressed as the dynamics of x in
xn+3-5xn+2-5xn+1+xn=0,
which is patterned on the characteristic equation of B.[7]
Moreover, an infinitude of other third-order univariate difference equations can be found by multiplying any of the three matrices together an arbitrary number of times in an arbitrary sequence. For instance, the matrix D = CB moves one out the tree by two nodes (across, then down) in a single step; the characteristic equation of D provides the pattern for the third-order dynamics of any of a, b, or c in the non-exhaustive tree formed by D.
Another approach to the dynamics of this tree[8] relies on the standard formula for generating all primitive Pythagorean triples:
a=m2-n2,
b=2mn,
c=m2+n2,
with and and coprime and of opposite parity (i.e., not both odd). Pairs can be iterated by pre-multiplying them (expressed as a column vector) by any of
\begin{array}{lcr} \begin{bmatrix}2&-1\ 1&0\end{bmatrix},& \begin{bmatrix}2&1\ 1&0\end{bmatrix},& \begin{bmatrix}1&2\ 0&1\end{bmatrix}, \end{array}
each of which preserves the inequalities, coprimeness, and opposite parity. The resulting ternary tree, starting at, contains every such pair exactly once, and when converted into triples it becomes identical to the tree described above.
Alternatively, start with for the root node.[9] Then the matrix multiplications will preserve the inequalities and coprimeness, and both and will remain odd. The corresponding primitive Pythagorean triples will have,, and . This tree will produce the same primitive Pythagorean triples, though with and switched.
This approach relies on the standard formula for generating any primitive Pythagorean triple from a half-angle tangent. Specifically one writes, where is the tangent of half of the interior angle that is opposite to the side of length . The root node of the tree is, which is for the primitive Pythagorean triple . For any node with value, its three children are,, and . To find the primitive Pythagorean triple associated with any such value, compute and multiply all three values by the least common multiple of their denominators. (Alternatively, write as a fraction in lowest terms and use the formulas from the previous section.) A root node that instead has value will give the same tree of primitive Pythagorean triples, though with the values of and switched.
500px|thumb|Price's tree of primitive Pythagorean triples.Alternatively, one may also use 3 different matrices found by Price.[6] These matrices A', B', C and their corresponding linear transformations are shown below.
\overset{{{A}'}}{\left[\begin{matrix 2&1&-1\\ -2&2&2\\ -2&1&3 \end{matrix}\right]}}\left[\begin{matrix} a\\ b\\ c \end{matrix}\right]=\left[\begin{matrix} a1\\ b1\\ c1 \end{matrix}\right], \overset{{{B}'}}{\left[\begin{matrix 2&1&1\\ 2&-2&2\\ 2&-1&3 \end{matrix}\right]}}\left[\begin{matrix} a\\ b\\ c\\ \end{matrix}\right]=\left[\begin{matrix} a2\\ b2\\ c2 \end{matrix}\right], \overset{{{C}'}}{\left[\begin{matrix 2&-1&1\\ 2&2&2\\ 2&1&3\\ \end{matrix}\right]}}\left[\begin{matrix} a\\ b\\ c\\ \end{matrix}\right]=\left[\begin{matrix} a3\\ b3\\ c3 \end{matrix}\right]
Price's three linear transformations are
\begin{align} &\begin{matrix} +2a+b-c=a1 &-2a+2b+2c=b1 &-2a+b+3c=c1& \to\left[a1,b1,c1\right] \end{matrix}\ &\begin{matrix} +2a+b+c=a2 &+2a-2b+2c=b2 &+2a-b+3c=c2& \to\left[a2,b2,c2\right] \end{matrix}\ &\begin{matrix} +2a-b+c=a3 &+2a+2b+2c=b3 &+2a+b+3c=c3& \to\left[a3,b3,c3\right] \end{matrix}\ & \end{align}
The 3 children produced by each of the two sets of matrices are not the same, but each set separately produces all primitive triples. For example, using [5, 12, 13] as the parent, we get two sets of three children:
\begin{array}{ccc} &\left[5,12,13\right]&\\ A&B&C\\ \left[45,28,53\right]&\left[55,48,73\right]&\left[7,24,25\right] \end{array} \begin{array}{ccc} {}&\left[5,12,13\right]&{}\\ A'&B'&C'\\ \left[9,40,41\right]&\left[35,12,37\right]&\left[11,60,61\right] \end{array}