# A Rooted Ternary Tree

There is another way of generating the primitive Pythagorean triples using matrices which was discovered by Berggren in 1934 and again by Barning in 1963.

The matrices are :

$$\mathbf{A} = \begin{pmatrix} 1&-2&2\\ 2&-1&2\\ 2&-2&3 \end{pmatrix}$$

$$\mathbf{B} = \begin{pmatrix} 1&2&2\\ 2&1&2\\ 2&2&3 \end{pmatrix}$$

$$\mathbf{C} = \begin{pmatrix} -1&2&2\\ -2&1&2\\ -2&2&3 \end{pmatrix}$$

$$(3, 4, 5)$$ is the root of this ternary tree and has three children using these matrices.

We showed previously that there is an infinite set of Pythagorean triples where $$m\; – n = 1$$ and another infinite set where $$(m\; – n)/n \approx \sqrt{2}$$.

We show another infinite set where $$n = 1$$.

We chose this time to use $$(3, 4, 5) = (x, y, z)$$ where $$x = m^2\;- n^2, y = 2mn$$ and $$z = m^2 + n^2$$.

We observe that $$x + 2 = z$$.  That is :

\begin{align} m^2 – n^2 + 2 &= m^2 + n^2\\ 2n^2 &= 2\\ n^2 &= 1\\ n &= 1 \end{align}

The set begins :

$$\begin{array} {c c c c c} m&n&x&y&z\\ \hline 2&1&3&4&5\\ 4&1&15&8&17\\ 6&1&35&12&37\\ 8&1&63&16&65\\ 10&1&99&20&101 \end{array}$$

All three of the above properties hold for the first primitive Pythagorean triple $$(3, 4, 5)$$.

We express $$(3, 4, 5)$$ as a column vector

$$\mathbf{P}_0 = \begin{pmatrix}3\\4\\5\end{pmatrix}$$

Matrix multiplication is not commutative.    $$\mathbf{AB}\neq\mathbf{BA}$$  in general.

We calculate as follows :

$$\begin{pmatrix} a&b&c\\ d&e&f\\ g&h&i \end{pmatrix} \begin{pmatrix} j\\ k\\ l \end{pmatrix} = \begin{pmatrix} aj\;\; + &bk\;\; + &cl\\ dj\;\; + &ek\;\; + &fl\\ gj\;\; + &hk\;\;+ &il \end{pmatrix} = \begin{pmatrix} m\\ n\\ o \end{pmatrix}$$

We apply each matrix:

$$\mathbf{AP}_0 = \begin{pmatrix} 1&-2&2\\ 2&-1&2\\ 2&-2&3 \end{pmatrix} \begin{pmatrix}3\\4\\5\end{pmatrix} = \begin{pmatrix}5\\12\\13\end{pmatrix} = \mathbf{P}_1$$

$$\mathbf{BP}_0 =\; \begin{pmatrix} 1&2&2\\ 2&1&2\\ 2&2&3 \end{pmatrix} \begin{pmatrix}3\\4\\5\end{pmatrix} = \begin{pmatrix}21\\20\\29\end{pmatrix} = \mathbf{P}_2$$

$$\mathbf{CP}_0 = \begin{pmatrix} -1&2&2\\-2&1&2\\-2&2&3\end{pmatrix} \begin{pmatrix}3\\4\\5\end{pmatrix} = \begin{pmatrix}15\\8\\17\end{pmatrix} = \mathbf{P}_3$$

The property $$m\, – n = 1$$ holds for $$\mathbf{P}_1$$.

The property $$(m\, – n)/n \approx \sqrt 2$$ holds for $$\mathbf{P}_2$$.

The property $$n = 1$$ holds for $$\mathbf{P}_3$$.

The three children each have three children ad infinitum.

By inspection of the second generation, we see that the first child of $$\mathbf{P}_1$$ inherits the property $$m\,-n = 1$$.

The middle child of $$\mathbf{P}_2$$ inherits the property $$(m\,-n)/n \approx \sqrt 2$$.

The third child of $$\mathbf{P}_3$$inherits the property $$n = 1$$.

This rooted ternary tree produces every primitive Pythagorean triple exactly once.