Difference equation with one definition for odd $n$ and another for $n$ even. 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. 
 A: Here is an approach  by   rearranging the recurrence relations  and  separating them  in  even  and  odd   parts.
We start with the given relations consisting of  even  part, odd part  and initial conditions.
\begin{align*}
&u_{2n+2}-au_{2n+1}+u_{2n}=0\qquad\qquad  n\geq0\\
&u_{2n+1}-bu_{2n}+u_{2n-1}=0\\
&u_0,u_1
\end{align*}

We obtain for  $n\geq0$:
  \begin{align*}
u_{2n+1}=\frac{1}{a}\left(u_{2n+2}+u_{2n}\right),\qquad\qquad  u_{2n}=\frac{1}{b}\left(u_{2n+1}+u_{2n-1}\right)
\end{align*}
  and we obtain recurrence relations where even  and odd  terms are separated. 
  \begin{align*}
&u_{2n+2}+(2-ab)u_{2n}+u_{2n-2}=0\qquad\qquad u_0,u_2=au_1-u_0\tag{1}\\
&u_{2n+3}+(2-ab)u_{2n+1}+u_{2n-1}=0\qquad\quad  u_1,u_3=(ab-1)u_1-bu_0\tag{2}
\end{align*}
  The recurrence relations (1)  and (2)  can be  solved independently  and can then be combined to give a final result.

Using a generating function approach $$U(z)=\sum_{n=0}^\infty  u_nz^n$$ with even function $U_{E}(z)=\sum_{n=0}^\infty u_{2n}z^{2n}$   and  odd function $U_{O}(z)=\sum_{n=0}^\infty u_{2n+1}z^{2n+1}$,

we can calculate $U_{E}(z)$:
\begin{align*}
\sum_{n=2}^\infty   u_{2n}&=\sum_{n=0}^\infty u_{2n+4}z^{2n+4}\\
&=\sum_{n=0}^\infty  (ab-2)u_{2n+2}z^{2n+4}-\sum_{n=0}^\infty u_{2n}z^{2n+4}\\
&=(ab-2)z^2\sum_{n=1}^\infty  u_{2n}z^{2n}-z^4\sum_{n=0}^\infty u_{2n}z^{2n}\\
&=(ab-2)z^2\left(U_{E}-u_0\right)-z^4U_{E}(z)\\
U_{E}(z)-u_0-u_2z^2&=(ab-2)z^2\left(U_{E}-u_0\right)-z^4U_{E}(z)\\
\color{blue}{U_{E}(z)}&\color{blue}{=\frac{u_0+\left((1-ab)u_0+au_1\right)z^2}{1+(2-ab)z^2+z^4}}\tag{3}
\end{align*}
and similarly we  obtain
  \begin{align*}
\color{blue}{U_{O}(z)}&\color{blue}{=\frac{u_1z+\left(u_1-bu_0\right)z^3}{1+(2-ab)z^2+z^4}}\tag{4}
\end{align*}

Note the equal denominator in (3) and (4) showing that  $U_{E}(z)$ and $U_{O}(z)$       have   essentially  the same structure. This is also indicated by the recurrence relations (1) and (2). Combining (3) and (4) we find a generating function 
\begin{align*}
U(z)&=U_{E}(z)+U_{O}(z)\\
&=\frac{u_0+u_1z+\left(au_1+(1-ab)u_0\right)z^2+(u_1-bu_0)z^3}{1+(2-ab)z^2+z^4}\tag{5}\\
&=u_0+u_1z+(au_1-u_0)z^2+\left((ab-1)u_1-bu_0\right)z^3\\
&\qquad+\left(\left(a^2b-2a\right)u_1+\left(1-ab\right)u_0\right)z^4\\
&\qquad+\left(\left(a^2b^2-3ab+1\right)u_1-\left(ab^2-2b\right)u_0\right)z^5+\cdots
\end{align*}
The expansion  of   (5) was calculated with some help of WolframAlpha. The manual way to derive a  representation of  $u_n$ from $U(z)$  is usually done by partial  fraction  decomposition of (5)  followed by  a geometric series expansion of the partial fractions.
A: 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.
A: Okay lets look:
Odd case:
$$u_{n+1} - au_n + u_{n-1} = 0\tag{1}$$
Even case:
$$u_{n+1} - bu_n + u_{n-1} = 0\tag{2}$$
Rearranged Even case:
$$u_{n+1}=bu_n - u_{n-1}\tag{2a}$$
Index edited Even case:
$$u_{n}=bu_{n-1} - u_{n-2}\tag{2b}$$
Substitution Odd case:
$$u_{n+1} - a(bu_{n-1} - u_{n-2}) + u_{n-1} = 0\tag{1a}$$
Disribution Odd case:
$$u_{n+1} - abu_{n-1} - au_{n-2} + u_{n-1} = 0\tag{1b}$$
Odd case:
$$u_{n+1} - au_n + u_{n-1} = 0\tag{1}$$
Even case:
$$u_{n+1} - bu_n + u_{n-1} = 0\tag{2}$$
Rearranged Odd case:
$$u_{n+1}=au_n - u_{n-1}\tag{1c}$$
Index edited  Odd case:
$$u_{n}=au_{n-1} - u_{n-2}\tag{1d}$$
Substitution Even case:
$$u_{n+1} - b(au_{n-1} - u_{n-2}) + u_{n-1} = 0\tag{2c}$$
Disribution Even case:
$$u_{n+1} - abu_{n-1} - bu_{n-2} + u_{n-1} = 0\tag{2d}$$
