TITLE: Find the order of a class of finite matrices over finite fields
QUESTION [9 upvotes]: Consider matrices $M$ of size $L\times L$ over a finite field $\mathbb{Z}_p$, for simplicity focus on $p$ prime. The size $L$ is even. We want to find the order of a specific class of matrices, namely we want to find the smallest non-zero integer $n$ such that $$M^n=1,$$ where 1 is here the identity matrix of size $L\times L$. The matrix $M$ has a specific block structure, which originates from a specific linear cellular automaton. We have $$M=AB,$$ where
$$A=
  \begin{pmatrix}
    1 & 1 & & && & \\
    1 & -1 && & & & \\
   & &    1 & 1 && &\\
   & &  1 & -1 && & \\
   &&&& \ddots & & \\
   &  & & &&1 & 1\\
     &  & & &&1 & -1\\
  \end{pmatrix}$$
and
$$
  B=
   \begin{pmatrix}
 -1 && & & && 1&\\
   &    1 & 1 && && \\
   &  1 & -1 && && \\
  &&& \ddots & & & \\
    & & &&1 & 1&\\
    & & &&1 & -1&\\
    1 && & & && 1\\
  \end{pmatrix}$$
You can see $B$ as $CAC^{-1}$ where $C$ is a cyclic shift over $L$ variables. Separately $A$ and $B$ have simple properties, but their alternating product becomes complicated.
I did some numerical testing, choosing first $\mathbb{Z}_3$. The interesting thing is (which also motivates me to look deeper into this) that the order $n$ seems to have a complicated behaviour as a function of $L$ and it is not clear to me what is the precise source of this. Sometimes $n$ is very big, seemingly exponentially growing with $L$. For example $n(L=46)=354292=2^2\cdot 23\cdot 3851$. Or $n(L=58)=9565940=2^2\cdot 5\cdot 29\cdot 16493$. But if $L$ is divisible by 6 then we get much lower numbers, $n(60)=120$ for example. I understand that it is natural  to see the prime $p$ somehow reflected in the function $n(L)$, but what I don't understand is how the big primes mentioned above can enter the game.
Update: Further numerical experiments showed that the smallest orbit happens when $L=2p^m$, in which case $n=2L$, we have simple linear growth. It gets complicated and quickly growing for most other $L$.
The origin of the problem is the following cellular automaton. Consider $L$ variables $s_j\in \mathbb{Z}_p$, with  $j=1,2,\dots,L$. We define a dynamics on the model, such that we perform two operations cyclically. In each operation we group two neighbouring variables into a pair, and we alternate the ways how we make the pairing. For each pairing we perform the update
$$(s_j,s_{j+1})\to (s_j+s_{j+1},s_j-s_{j+1})$$
What changes is that at every second update $j$ is even or odd. If you represent this linear operation with matrices, you get $A$ and $B$ and we want to iterate the product $M=AB$.

REPLY [2 votes]: Denote $L=2\ell$, and let me assume that $p$ is an odd prime, not dividing $\ell$. Then there are $\ell$ distinct $\ell$-th roots of unity in a suitable extension of ${\mathbb F}_p$.
The Question can be solved by Fourier analysis over ${\mathbb F}_p^\ell$ (which turns out to be a discrete Fourier analysis). Let me split an $L$-vector $x$ into its odd and even parts:
$$y_i=x_{2i-1},\qquad z_i=x_{2i}.$$
Then $x':=Ax$ and $x'':=Bx$ are given by
$$y'=y+z,\quad z'=y-z,\qquad y_i''=-y_i+z_{i-1},\quad z_i''=z_i+y_{i+1}.$$
Let me define the Fourier transform of an $\ell$-vector $v$ by
$$\hat v(\omega)=\sum_iv_i\omega^{-i},$$
where the argument $\omega$ takes values in the group of $\ell$-th roots of unity. The formula above yield
$$\hat y'=\hat y+\hat z,\quad\hat z'=\hat y-\hat z,\qquad\hat y''(\omega)=-\hat y(\omega)+\omega^{-1}\hat z(\omega),\quad\hat z''(\omega)=\hat z(\omega)+\omega\hat y(\omega).$$
We infer that $X:=Mx$ is given by
$$X(\omega)=\hat M(\omega)x(\omega),\qquad\hat M(\omega):=\begin{pmatrix} \omega-1 & 1+\omega^{-1} \\ -1-\omega & \omega^{-1}-1 \end{pmatrix}.$$
The characteristic polynomial of $\hat M(\omega)$ is
$$P_\omega(\lambda)=\lambda^2-(\omega+\omega^{-1}-2)\lambda+4.$$
The spectrum of $M$ is thus the union of the pairs $(\lambda_\omega,\mu_\omega)$ of roots of the $P_\omega$'s.
The blocks $M(\omega)$ are diagonalisable, unless an $\ell$-root of unity satisfies $\omega^2-6\omega+1=0$.
The order of $M$ in ${\bf M}_L({\mathbb F}_p)$ is the lcm of the orders of the eigenvalues $\lambda_\omega,\mu_\omega$ in the algebraic closure (actually some finite extension),  mulitiplied by $2$ in the exceptional case that this lcm is odd (unlikely) and the order of the solutions of $t^2-6t+1=0$ divide $\ell$.
In other words, defining the vectors $v_\omega=(1,\omega,\ldots,\omega^{\ell-1})$, we see that the subspaces defined by $y,z\in{\rm Span}(v_\omega)$ are stable under both $A$ and $B$, and we are able to compute the spectrum of $AB$ by studying its restriction to these $2$-dimensional spaces. Notice that the action on the spaces associated with $v_{\omega}$ and $v_{\omega^{-1}}$ are conjugate to each other.