# Solving inhomogeneous second-order linear difference equation

In general, how does one solve an inhomogeneous second-order linear difference equation of the form

$$a f(n+1) + b f(n) + c f(n-1) = d(n)$$

where $$a, b, c$$ are constants but $$d(n)$$ may also depend on $$n$$? For instance, consider as in here: $$2 f(n+1) - 7 f(n) + 3 f(n-1) = 2 + 2^n$$ with boundary conditions $$q_0 = 1$$ and $$q_1 = 2$$.

I understand that the general solution can be written as the sum of a particular solution to the inhomogeneous equation plus the general solution of the corresponding homogeneous equation, and I am able to find the latter, but how does one come up with a particular solution to the inhomogeneous equation in this case?

• obtaining a particular solution can be really complicated. It depends a lot on the function type of $d (n)$. In the polynomial case it is usually direct. Also for some exponential cases. – Cesareo Dec 25 '18 at 9:02
• @Cesareo Thanks; could you please elaborate how to do so for the polynomial and exponential cases such as $2 + 2^n$ in an answer? – p-value Dec 25 '18 at 21:10