Basic question about Markov Chain stationary distribution using generating functions

This is really basic, but I've been trying hard for a while and didn't get where I made a mistake, so after some consideration decided to ask it here.

So I got a basic recurrence equation for stationary distribution in MC: $$0=\lambda \pi_{k-1} + \mu \pi_{k+1} - (\lambda+ \mu) \pi_k$$

I tried to solve it using generating functions with $G(z)=\sum_{k \geq 0} \pi_k z^k$, so I got

$$\frac{\mu \pi_0}{z}=P(z)(z-1)(\lambda-\frac{\mu}{z})$$ I understand how to go from here equating coefficients and so on, but this expression is incorrect! The correct one is

$$\frac{\mu \pi_0(1-z)}{z}=P(z)(z-1)(\lambda-\frac{\mu}{z})$$ before cancellations. I suspect I made a mistake when working out the generating function $G(z)$: $$\lambda \sum_{k \geq 0} \pi_{k-1} z^k=\lambda z G(z)\\ \mu \sum_{k \geq 0} \pi_{k+1}z^k = \frac{\mu}{z}(G(z)- \pi_0)$$

OK, start with: $$0 = \lambda \pi_k + \mu \pi_{k + 2} - (\lambda + \mu) \pi_{k + 1}$$ Define: $$P(z) = \sum_{k \ge 0} \pi_k z^k$$ Applying properties of ordinary generating functions: \begin{align*} 0 &= \lambda P(z) + \mu \frac{P(z) - \pi_0 - \pi_1 z}{z^2} - (\lambda + \mu) \frac{P(z) - \pi_0}{z} \\ P(z) &= \frac{(\mu \pi_1 - (\mu + \lambda) \pi_0) z + \mu \pi_0} {(1 - z) (\lambda z - \mu)} \end{align*} (This is a second order recurrence, need starting values $\pi_0$ and $\pi_1$.)

Maxima's help with algebra is gratefully aknowledged.

• I don't understand, why this does not work with the original recurrence? Is it because of $\pi_{-1}$ term?
– Alex
Mar 19 '13 at 21:55
• @Alex, you'd need $\sum_{k \ge 0} \pi_{k - 1} z^k = z P(z) + \pi_{-1}$ for a $\pi_{k - 1}$. Mar 19 '13 at 22:48
• Which does not exist, right? So this was my mistake then. Thanks.
– Alex
Mar 20 '13 at 0:01
• @Alex, If you want, you certainly can compute a $\pi_{-1}$ to match the recurrence (compute backwards, as it where). Mar 20 '13 at 0:55
• I'm sorry, I don't understand, could you explain in greater detail how this can work?
– Alex
Mar 20 '13 at 1:29