I have the following recurrence relation that I'm trying to solve:
$$f(n)=2f(n-1)-f(n-2)-2$$
The homogeneous part is easy:
The characteristic polynomial $r^2-2r+r=0$ has root $r=1$ with multiplicity 2, so the general solution is:
$$f(n)=An+B$$
for some initial conditions.
The non-homogeneous part I cannot get. I start with a guess that the solution will be of the form $f(n)=C$ since the $-2$ in the original function is just a constant.
This becomes troublesome, because if $f(n)=C$, $f(n-1)=C$, $f(n-2)=C$, then $f(n)=2f(n-1)-f(n-2)-2$ becomes
$$C=2C-C-2$$ $$0\neq2$$
I get a similar result if I assume a solution of the form $Cn+D$.
What do I need to do here to solve the non-homogeneous part?
Thanks!