I'm trying to solve the difference equation $$ pE_{k+1} - E_{k} + qE_{k-1} = -1 $$ given the boundary conditions $E_{0} = 0, \; E_{a} = 0$, if $p=q=\frac{1}{2}$
To attempt this, I first found and solved the characteristic polynomial, as follows: $$ p \lambda^{2} - \lambda + q = 0 \\ \iff (p \lambda - q)(\lambda - 1) \\ \iff \lambda_{1} = \frac{q}{p}, \; \lambda_{2} = 1 $$
But since we know that $p=q$, we know that $\lambda_{1} = \lambda_{2} = 1$. Thus, the general solution to the homogeneous difference equation would be $$ E_{k} = Ak + B $$
I have then found that $$ E_{k} = \frac{k}{p-q} $$ is a particular integral for this equation, so we no that the solution to the inhomogeneous equation would be $$ E_{k} = Ak + B + \frac{k}{p-q} $$
Finally, the boundary conditions $E_{0} = 0, \; E_{a} = 0$ can be used to find the constants $A$ and $B$, as follows: $$ E_{0} = A(0) + B + \frac{0}{p-q} = B = 0 $$
and
$$ E_{a} = A(a) + \frac{a}{p-q} = 0 \Rightarrow A = -\frac{1}{p-q} $$
Thus, our exact solution would be $$ E_{k} = Ak + B + \frac{k}{p-q} = -\frac{k}{p-q} + \frac{k}{p-q} = 0 $$
Why has my final solution come out as $E_{k}=0$?
Because the RHS is $-1.1^k$, this means that you should search for particular integral of the form $ck^2$, where the square is because $\lambda =1$ is a double root of the characteristic equation. Then, plugging it in the difference equation: $$\frac{1}{2}c(k+1)^2-ck^2+\frac{1}{2}(k-1)^2=-1$$
$$c=-1$$. So your general solution is $E_k=Ak+B-k^2$. From the initial conditions $E_0=E_a=0$: $$0=B$$ $$0=Aa+B-a^2\Rightarrow Aa-a^2=0\Rightarrow a(A-a)=0 \Rightarrow A=a\Rightarrow E_k=ak-k^2$$