Solution (source code)

= Solution

The homogeneous characteristic equation is
$$
r^2+r-6=(r-2)(r+3)=0.
$$
A linear particular solution $u_n=an+b$ gives
$$
-4an+11a-4b=n,
$$
so $a=-1/4$ and $b=-11/16$. Thus
$$
u_n=A2^n+B(-3)^n-\frac n4-\frac{11}{16}.
$$
The initial data yield $A=1$ and $B=-5/16$, hence
$$
\boxed{u_n=2^n-\frac5{16}(-3)^n-\frac n4-\frac{11}{16}}.
$$

For the <ordinary generating function of a recurrence>, multiply by $x^n$ and sum for $n\geq2$. Using $u_0=0,u_1=2$ gives
$$
(1+x-6x^2)G(x)
=x+\frac{x}{(1-x)^2}.
$$
Equivalently,
$$
\boxed{
G(x)=
\frac1{1-2x}
-\frac5{16(1+3x)}
-\frac{x}{4(1-x)^2}
-\frac{11}{16(1-x)}}.
$$
Expanding each geometric <series> gives exactly the displayed formula for $u_n$, verifying consistency.