A random walk S with absorbing barriers at $0$ and $N$, at each step the particle can move right,left or stay put with probabilities (p+q+r=1). Let $W$ be the event that the particle is absorbed at $0$ rather than $N$ , and let $p_k=\mathbb{P}(W|S_0=k)$. Show that if the particle starts at $k$ where $0 < k < N$, the conditional probability given that the first step is rightwards, given $W$, equals $\frac{pp_{k+1}}{p_k}$. Deduce that the mean duration $J_k$ of the walk conditional on $W$ satisfies the equation:
$$pp_{k+1}J_{k+1}-(1-r)J_k+qp_{k-1}J_{k-1}=-p_k$$
$\mathbb{E}[T|S_0=k, W]=$
$\mathbb{E}[T|S_0=k, W, X_1=1]\mathbb{P}[X_1=1|S_0=k, W] +$
$\mathbb{E}[T|S_0=k, W, X_1=0]\mathbb{P}[X_1=0|S_0=k, W] + $
$\mathbb{E}[T|S_0=k, W, X_1=-1]\mathbb{P}[X_1=-1|S_0=k, W]$
$J_k = (1+J_{k+1})\frac{pp_{k+1}}{p_k} + (1+J_{k})\frac{rp_{k}}{p_k}+(1+J_{k-1})\frac{qp_{k-1}}{p_k}$
$-p_k = J_{k+1}pp_{k+1} - J_{k}(1- r)p_{k}+J_{k-1}qp_{k-1}$
set $\rho^k=(\frac{q}{p})^k$
$p_k=\frac{\rho^k-\rho^N}{1-\rho^N}$
set $\mu_k=(\rho^k-\rho^N)J_k$
$\rho^N-\rho^k = p\mu_{k+1} - (1- r) \mu_k + q\mu_{k-1}$
solving the homogeneous part
$p\mu_{k+1} - (p+q) \mu_k + q\mu_{k-1}=0$
$p\mu^2-(p+q)\mu+ q=0$
$(\mu-1),(p\mu-q)$
so the homogeneous solution is
$\mu= 1, \frac{q}{p}$
$A + B \rho^k$
The inhomogeneous solution is $\frac{k(\rho^k -\rho^N)}{p-q}$
I can't seem to get the result above. Here's my attempt
Taking $C(\rho^k -\rho^N)$
$ C(p(\rho^{k+1} - \rho^N) - (p+q)(\rho^{k} - \rho^N) + q(\rho^{k-1} - \rho^N))=\rho^N-\rho^k$
focusing on the $\rho_k$ part
$ C(p\rho^{k+1} - (p+q)\rho^{k} + q\rho^{k-1})$
$ C(p\rho^{k}(\rho - 1) + q\rho^{k-1}(1 -\rho))$
$ C(p\frac{q^k}{p^k}(\rho - 1) + q\frac{q^{k-1}}{p^{k-1}}(1 -\rho))$
$ C(\frac{q^k}{p^{k-1}}(\rho - 1) + \frac{q^{k}}{p^{k-1}}(1 -\rho))$
$ C(\frac{q^k}{p^{k-1}}(q - p) + \frac{q^{k}}{p^{k-1}}(p - q))$
$=0$
How do you derive the inhomogeneous result given?
Focusing on the boundary conditions $\mu_0=0$
$A + B \rho^0 +\frac{0(\rho^k+\rho^N)}{p-q}=0$
$A + B=0 $
$A=-B$
and $\mu_N=N$
$A + B \rho^N +\frac{N(\rho^N+\rho^N)}{p-q}=0$
$A + B \rho^N +\frac{2N\rho^N}{p-q}=0$
$A = -B \rho^N - \frac{2N\rho^N}{p-q}$
$-B = -B \rho^N - \frac{2N\rho^N}{p-q}$
$B(1-\rho^N) = \frac{2N\rho^N}{p-q}$
$B = \frac{2N\rho^N}{(p-q)(1-\rho^N)}$
hence
$A + B \rho^k +\frac{k(\rho^k+\rho^N)}{p-q}$
$=\frac{2N\rho^N(1-\rho^K)}{(p-q)(1-\rho^N)} + \frac{k(\rho^k+\rho^N)}{p-q}$
However the answer given is
$=\frac{1}{p-q}.\frac{1}{\rho^k-\rho^N}\frac{2N\rho^N(1-\rho^K)}{(p-q)(1-\rho^N)} + k(\rho^k+\rho^N)$
Where does the $\frac{1}{\rho^k-\rho^N}$ term come from?