Let us define the difference equation:
$u_{n+1} - au_n + u_{n-1} = 0 $, if $n$ is odd,
$u_{n+1} - bu_n + u_{n-1} = 0$, if $n$ is even.
I've been struggling to solve this equation for the last few days and I'm very stuck. I know that if either of the equations above was standalone $\forall n$ it would be a simple characteristic equation, but I'm not sure what to do here with how to split into an odd or even cases.
I thought about writing $u_n$ in a piecewise way:
$u_n=v_n$ for $n$ odd and $u_n = w_n$ for $n$ even. And treating it as a system:
$v_{n+1} - av_n + v_{n-1} = 0$
$w_{n+1} - bw_n + w_{n-1} = 0$$
But I didn't get very far with this approach. Thank you for your help.
Call $x_n=u_{2n}$ and $y_n=u_{2n+1}$. Then $$\begin{pmatrix}x_{n+1}\\ y_{n+1}\end{pmatrix}=\begin{pmatrix}au_{2n+1}-u_{2n}\\ bu_{2n+2}-u_{2n+1}\end{pmatrix}=\begin{pmatrix}ay_n-x_n\\ bx_{n+1}-y_n\end{pmatrix}=\begin{pmatrix}ay_n-x_n\\ bay_n-bx_n-y_n\end{pmatrix}=\\=\begin{pmatrix}-1&a\\ -b& ba-1\end{pmatrix}\begin{pmatrix}x_n\\ y_n\end{pmatrix}$$
Therefore $\begin{pmatrix}u_{2n}\\ u_{2n+1}\end{pmatrix}=\begin{pmatrix}-1 &a\\ -b& ba-1\end{pmatrix}^n\begin{pmatrix}u_0\\ u_1\end{pmatrix}$, which may be calculated with standard methods via the Jordan normal form of the matrix.