<s>[INST] What kind of matrix is this and why does this happen? So I was studying Markov chains and I came across this matrix  \begin{align*}P=\left( \begin{array}{ccccc}
        0 & \frac{1}{4} & \frac{3}{4} & 0 & 0\\
        \frac{1}{4} & 0 & 0 & \frac{1}{4} & \frac{1}{2}\\
        \frac{1}{2} & 0 & 0 & \frac{1}{4}& \frac{1}{4}\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
    \end{array} \right).\end{align*}
I noticed (by brute force) that \begin{align*}P^2=\left( \begin{array}{ccccc}
        \frac{7}{16} & 0 & 0 & \frac{1}{4} & \frac{5}{16}\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
        \frac{3}{8} & 0 & 0 & \frac{1}{4}& \frac{1}{2}\\
        \frac{7}{16} & 0 & 0 & \frac{1}{4} & \frac{5}{16}\\
    \end{array} \right),\end{align*}
and \begin{align*}P^3=\left( \begin{array}{ccccc}
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
        \frac{7}{16} & 0 & 0 & \frac{1}{4} & \frac{5}{16}\\
        \frac{7}{16} & 0 & 0 & \frac{1}{4} & \frac{5}{16}\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
        0 & \frac{1}{4} & \frac{3}{4} & 0& 0\\
    \end{array} \right).\end{align*}
In fact; using a computer I found that every even power takes the form of the $P^2$ matrix and every odd power takes the form of the $P^3$ matrix.
I just wanted to know why that oscillation occurs? Is there a special name for the kind of matrix that $P$ is for it to exhibit that kind of behaviour?
 [/INST] It is a matrix such that $P^4= P^2$ and some additional relations.
We see that
$$ 0 = P^4 - P^2 = P^2(P^2 - I) = P^2(P-I)(P+I)$$
so the minimal polynomial $\mu_P(x)$ divides $x^2(x-1)(x+1)$. 
However, the minimal polynomial is not any of $$x, x^2, x-1, x+1, \underbrace{x(x-1)}_{P^2 \ne P}, \underbrace{x(x+1)}_{P^2 \ne -P}, \underbrace{x^2(x-1)}_{P^3 \ne P^2}, \underbrace{x^2(x-1)}_{P^3 \ne -P^2}, \underbrace{(x-1)(x+1)}_{P^2 \ne I}, \underbrace{x(x-1)(x+1)}_{P^3 \ne P}$$ so it has to be precisely $x^2(x-1)(x+1)$.
The possibilities for the Jordan normal form of $P$ are:
$$\pmatrix{0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & 0 & 0}, \pmatrix{0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & 0 & 1}, \pmatrix{0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & 0 & -1}$$
meaning $5 \times 5$ matrices have the above properties if and only if they are similar to one of the three matrices above.
</s>