If $a_{n+1}=2a_n −n^2+n$ Define a sequence $a_n$ that satisfy the recurrence relation as described above, with $a_1 = 3$ If
$$a_{n+1}=2a_n −n^2+n$$
Define a sequence $a_n$
that satisfy the recurrence relation as described above, with $a_1 = 3$
Find the value of $$\dfrac{ |a_{20} - a_{15} | }{18133} $$
Attempt
First  evaluate $a_{0}$
$$a_{1} = 2a_{0} \Rightarrow a_{0}= \frac{3}{2}$$
Then, use Z-transform: $$a_{n+1} - 2a_{n} + n^2 - n = 0$$
$$z(\mathbf{A}(z)-a_{0}) - 2\mathbf{A}(z) + \dfrac{z(z+1)}{(z-1)^3} - \dfrac{z}{(z-1)^2} = 0$$
$$\Rightarrow \mathbf{A}(z) = \dfrac{z(3z^3 -9z^2 + 9z - 7)}{2(z-2)(z-1)^3}$$
​
$$\Rightarrow \mathbf{A}(z) = \dfrac{2z}{z-1} + \dfrac{z}{(z-1)^2} + \dfrac{z(z+1)}{(z-1)^3} - \dfrac{z}{2(z-2)}$$
The inverse of the Z-transform will be: $$\boxed{a_{n} = 2 + n + n^2 - 2^{n-1}}$$
​
Now: $$a_{20} = 422-2^{19}$$ $$a_{15} = 242-2^{14}$$
Is it Correct??
Any other precise solution will be highly appreciated
 A: As an alternative, you can use more elementary methods for linear difference equations. In fact, the general solution will be of the form
$$
a_n = a_n^h + a_n^*
$$
where $a_n^h$ is the general solution of the homogeneous equation, i.e. $a_n^h = c 2^n$, and $a_n^*$ is a particular solution  of the full equation. If you try a particular solution "similar" to $-n^2+2n$, namely $a_n^* = k_1 n^2+ k_2n + k_3$, you'll see that
$$
a_n = c 2^n +n^2+n+2
$$
The constant $c$ can be computed from the condition $a_1=3$, yielding the solution you have obtained using the Z-Transform.
A: Let $a_m=b_m+c_0+c_1m+c_2m^2+\cdots+c_rm^r$
$b_{m+1}+c_0+c_1(m+1)+c_2(m+1)^2+\cdots=2(b_n+c_0+c_1m+c_2n^2+\cdots)+n-n^2$
If $r\ge3,$ compare the coefficients of $m^r$
$$c_r=2c_r\iff c_r=0$$
$\implies a_m=b_m+c_0+c_1m+c_2m^2$
Compare the coefficients of $n^2, c_2=2c_1-1\iff c_2=1$
Similarly, comparing the  coefficients of $n$ and the constants, $c_1=1, c_0=2$
so that $b_{m+1}=2b_m=\cdots=2^tb_{m-t}$ for integer $t\ge0$
Again $3=a_1=b_1+c_0+c_1+c_2\implies b_1=-1$
