I am helping designing a course module that teaches basic python programming to applied math undergraduates. As a result, I’m looking for examples of

mathematically interestingcomputations involving matrices.Preferably these examples would be easy to implement in a computer program.

For instance, suppose

$$\begin{eqnarray}

F_0&=&0\\

F_1&=&1\\

F_{n+1}&=&F_n+F_{n-1},

\end{eqnarray}$$

so that $F_n$ is the $n^{th}$ term in the Fibonacci sequence. If we set$$A=\begin{pmatrix}

1 & 1 \\ 1 & 0

\end{pmatrix}$$we see that

$$A^1=\begin{pmatrix}

1 & 1 \\ 1 & 0

\end{pmatrix} =

\begin{pmatrix}

F_2 & F_1 \\ F_1 & F_0

\end{pmatrix},$$and it can be shown that

$$

A^n =

\begin{pmatrix}

F_{n+1} & F_{n} \\ F_{n} & F_{n-1}

\end{pmatrix}.$$This example is “interesting” in that it provides a novel way to compute the Fibonacci sequence. It is also relatively easy to implement a simple program to verify the above.

Other examples like this will be much appreciated.

**Answer**

If $(a,b,c)$ is a *Pythagorean triple* (i.e. positive integers such that $a^2+b^2=c^2$), then

$$\underset{:=A}{\underbrace{\begin{pmatrix}

1 & -2 & 2\\

2 & -1 & 2\\

2 & -2 & 3

\end{pmatrix}}}\begin{pmatrix}

a\\

b\\

c

\end{pmatrix}$$

is also a Pythagorean triple. In addition, if the initial triple is *primitive* (i.e. $a$, $b$ and $c$ share no common divisor), then so is the result of the multiplication.

The same is true if we replace $A$ by one of the following matrices:

$$B:=\begin{pmatrix}

1 & 2 & 2\\

2 & 1 & 2\\

2 & 2 & 3

\end{pmatrix}

\quad \text{or}\quad

C:=\begin{pmatrix}

-1 & 2 & 2\\

-2 & 1 & 2\\

-2 & 2 & 3

\end{pmatrix}.

$$

Taking $x=(3,4,5)$ as initial triple, we can use the matrices $A$, $B$ and $C$ to construct a tree with all primitive Pythagorean triples (without repetition) as follows:

$$x\left\{\begin{matrix}

Ax\left\{\begin{matrix}

AAx\cdots\\

BAx\cdots\\

CAx\cdots

\end{matrix}\right.\\ \\

Bx\left\{\begin{matrix}

ABx\cdots\\

BBx\cdots\\

CBx\cdots

\end{matrix}\right.\\ \\

Cx\left\{\begin{matrix}

ACx\cdots\\

BCx\cdots\\

CCx\cdots

\end{matrix}\right.

\end{matrix}\right.$$

**Source:** Wikipedia’s page *Tree of primitive Pythagorean triples*.

**Attribution***Source : Link , Question Author : providence , Answer Author : Pedro*