The question
Given that the initial terms $a_1$, $a_2$ and the recursion:
$$ \left\{ \begin{matrix} a_{2k}=pa_k+qa_{k+1}\\ a_{2k+1}=ra_k+sa_{k+1}\\ \end{matrix} \right. $$
Find the general term of $a_n$ in term of $a_1, a_2, p, q, r, s$ and $n$
My work:
Let $ A_1= \begin{pmatrix} r&s&0\\ 0&p&q\\ 0&r&s\\ \end{pmatrix} $, $ A_0= \begin{pmatrix} p&q&0\\ r&s&0\\ 0&p&q\\ \end{pmatrix} $, $v_1=\begin{pmatrix} a_1\\ a_2\\ a_3\\ \end{pmatrix}$ and $v_0=\begin{pmatrix} a_2\\ a_3\\ a_4\\ \end{pmatrix}$
Then we have:
$$ \begin{pmatrix} a_{2k}\\ a_{2k+1}\\ a_{2k+2}\\ \end{pmatrix} = A_0\begin{pmatrix} a_{k}\\ a_{k+1}\\ a_{k+2}\\ \end{pmatrix} , \begin{pmatrix} a_{2k+1}\\ a_{2k+2}\\ a_{2k+3}\\ \end{pmatrix} = A_1\begin{pmatrix} a_{k}\\ a_{k+1}\\ a_{k+2}\\ \end{pmatrix} $$
For any integer $n$, $\begin{pmatrix} a_{n}\\ a_{n+1}\\ a_{n+2}\\ \end{pmatrix}$ can be written as a product of some $A_1$ and $A_0$ actting on $v_1$ or $v_0$. Their order depends on the binary form of $n$
For example:
$6=110_{(2)}$,so
$$\begin{pmatrix} a_{6}\\ a_{7}\\ a_{8}\\ \end{pmatrix}=A_0A_1v_1$$
$45=101101_{(2)}$,so
$$\begin{pmatrix} a_{45}\\ a_{46}\\ a_{47}\\ \end{pmatrix}=A_1A_0A_1A_1v_0$$
However, it is difficult to find the closed form of the product as $A_1,A_0$ have different eigenvalues.
Special Case I:
When $p=1+\frac{a}{d},q=1-\frac{a}{d},r=\frac{a}{d},s=2-\frac{a}{d}, a_1=a, a_2=a+d$, then:
$$a_n=a+(n-1)d$$
i.e. ${a_n}$ is an arithmetic sequence.
For the longest path, calling $k=2^m$ we have
$$ \left(\matrix{a_{2^{m+1}+1}\\ a_{2^{m+1}}}\right)= M^j\left(\matrix{a_{2^{m-j+1}+1}\\ a_{2^{m-j+1}}}\right)= M^{m+1}\left(\matrix{a_2\\ a_1}\right) $$
with $M = \left(\matrix{q&p\\ s& r}\right)$. Now if $M = \left(\matrix{1-\lambda&1+\lambda\\ 2-\lambda& \lambda}\right)$ we have
$$ M = T\cdot \Lambda\cdot T^{-1},\ \ T = \left( \begin{array}{cc} 1 & \frac{\lambda +1}{\lambda -2} \\ 1 & 1 \\ \end{array} \right)\ \ \ \Lambda = \left( \begin{array}{cc} 2 & 0 \\ 0 & -1 \\ \end{array} \right) $$
$$ \left(\matrix{a_{2^{m+1}+1}\\ a_{2^{m+1}}}\right)= T\Lambda^{m+1}T^{-1}\left(\matrix{a_2\\ a_1}\right) $$
so for $\lambda = \frac ad,\ \ a_2=a+d, a_1=a$ and $k = 2^m$ we have
$$ \left(\matrix{a_{2k+1}\\ a_{2k}}\right)= \frac 13\left( \begin{array}{c} \left(2^{m+1}+(-1)^m\right) (a+d)\\ \left(2^{m+1}+(-1)^m\right) (a+d)-3d(-1)^m \\ \end{array} \right) $$
For $a_1=a_2=a$ with the same $\lambda,k$ we have
$$ \left(\matrix{a_{2k+1}\\ a_{2k}}\right)=\left( \begin{array}{c} 2^m \\ 2^m \\ \end{array} \right)a $$