Solution (source code)

= Solution

The stationarity equation at an interior state collects arrivals from its two neighbors and itself:
$$
\pi_i=a\pi_{i-1}+(1-a-b)\pi_i+b\pi_{i+1}.
$$
This rearranges to the required recurrence. At zero, stationarity gives $\pi_0=(1-a)\pi_0+b\pi_1$, hence $\boxed{b\pi_1=a\pi_0}$.

The recurrence says the flux $a\pi_{i-1}-b\pi_i$ equals $a\pi_i-b\pi_{i+1}$. The boundary equation makes that flux zero, so $\pi_i=(a/b)^i\pi_0$. Since $0\le a/b<1$, normalization gives
$$
\boxed{\pi_i=(1-a/b)(a/b)^i\quad(i\ge0).}
$$
When $a=0$ this means $\pi_0=1$ and $\pi_i=0$ for $i>0$. The probability assumptions also require $a,b\ge0$, $a+b\le1$, as implicit in the transition rules.