Help with recurrence equation I need to solve the following recurrence equation 
$p_i =\begin{cases} r(p_{i-1}+p_{i+2}) &\mbox{if } i \text{ is odd} \\ 
(1-r)(p_{i-1}+p_{i}) & \mbox{if } i \text{ is even} \end{cases}  i \in \mathbb{N}$
This equation came up trying to find an invariant measure vector for a given stochastic matrix, in fact $0\leq r \leq 1$.
I have no clue how to solve this, any help will be great :)
 A: If statement is correct:
$$
p_n =\begin{cases} r(p_{n-1}+p_{n+2}) &\mbox{if } n \text{ is odd} \\ 
(1-r)(p_{n-1}+p_{n}) & \mbox{if } n \text{ is even} \end{cases}  n \in \mathbb{N}
$$
then for $r\ne 0$
$$
\Downarrow
$$
$$
\begin{cases}
rp_{n+2} = p_{n} - rp_{n-1}, &\mbox{if } n \text{ is odd} \\ 
rp_{n} = (1-r)p_{n-1} & \mbox{if } n \text{ is even} \end{cases}  n \in \mathbb{N}\tag{1}
$$
$$
\Downarrow
$$
$$
\begin{cases}
rp_{n+2} = p_{n} - (1-r)p_{n-2}, &\mbox{if } n \text{ is odd} \\ 
rp_{n} = (1-r)p_{n-1} & \mbox{if } n \text{ is even} \end{cases}  n \in \mathbb{N}\tag{2}
$$
Now consider only odd $n$: $n=2k-1$.
Search $p_{2k-1}$ in the form 
$$
p_{2k-1} = ab^{k}.
$$
Then $(2) \implies$ 
$$
rab^{k+1} = ab^{k}-(1-r)ab^{k-1},
$$
$$
rb^{2} = b-(1-r),
$$
$$
rb^{2} - b+(1-r)=0,
$$
this quadratic (on $b$) equation has solutions:
$$
b=1,  \qquad b=\dfrac{1-r}{r}.
$$
If $b=1$, then solution of $(1)$ has form
$p_{2k-1}=a, p_{2k}=\dfrac{1-r}{r}a$.
If $b=\dfrac{1-r}{r}$, then
$$
p_{2k-1}=a\left(\dfrac{1-r}{r}\right)^k,
$$
$$
p_{2k}=a\left(\dfrac{1-r}{r}\right)^{k+1}.
$$
$a$ is any real value (if $p_1$ would defined, then $a$ would defined too).
The case $r=0$ is obvious.
