TITLE: Recurrence of the form $2f(n) = f(n+1)+f(n-1)+3$
QUESTION [6 upvotes]: Can anyone suggest a shortcut to solving recurrences of the form, for example:
$2f(n) = f(n+1)+f(n-1)+3$, with $f(1)=f(-1)=0$
Sure, the homogenous solution can be solved by looking at the characteristic polynomial $r^2-2x+1$, so that in general a solution for the homogenous equation is of the form $f^h(n) = c_1+c_2n$. But how does one deal with the constant 3 in this case?

REPLY [2 votes]: we can use the generating function $F(x)=\sum_{k=1}^{\infty} f(k)x^k$
the recurrence relation may be written:
$$2f(n+1) = f(n+2)+f(n)+3$$
so multiplying by $x^{n+2}$ we have
$$2xf(n+1)x^{n+1} = f(n+2)x^{n+2}+x^2f(n)x^n+3x^{n+2}$$
and summing for $n=0$ to $\infty$
$$
2x(F(x)-f(0)) = F(x)-xf(1)-f(0) + x^2F(x) +3x^2(1-x)^{-1}
$$
since $f(1)=0$ and $f(0)=\frac32$ this gives (writing $F$ for $F(x)$)
$$
-(1-x)^2F= 3x - \frac32 +3x^2(1-x)^{-1}= \frac32(2x-1 +2x^2(1-x)^{-1})=\frac32(3x-1)(1-x)^{-1}
$$
so 
$$
F(x)=-\frac32(3x-1)(1-x)^{-3}
$$thus for $n \ge 1$ we have $f(n)$, the coefficient of $x^n$ is $-\frac32 \left(3 \binom{n+1}2 - \binom{n+2}2 \right)$
which simplifies to 
$$
f(n) = -\frac32 (n^2-1)
$$