Find a closed form formula for $u_n$ where $u_{n+1} =2u_n - n^2$ and $u_0=a$
I'm not totally sure how closed form expressions are derived of a given sequence. I tried generating functions which goes like this: $\begin{aligned} \sum_{n=0}^{\infty} u_n x_0^n & =u_0+\sum_{n=0}^{\infty} u_{n+1} x^{n+1} \\ & =a+\sum_{n=0}^{\infty}\left(2 u_n-n^2\right) x^{n+1} \\ & =a+2 \sum_{n=0}^{\infty} u_n x^{n+1}-\sum_{n=0}^{\infty} n^2 x^{n+1} \\ & =a+2 x \cdot \sum_{n=0}^{\infty} u_n x^n-\sum_{n=0}^{\infty} n^2 x^{n+1} \end{aligned}$ Im stuck here. Please help.
$$u_{n+1} = 2u_n - n^2$$ Since $(n + 1)^2 = n^2 + 2n + 1$, the relevant non recursive terms are $n^2$, $n$, and $1$. $$u_{n} = v_{n} + An^2 + Bn + C$$ $$v_{n+1} + A(n+1)^2 + B(n+1) + C = 2v_n + 2An^2 + 2Bn + 2C - n^2$$ $$v_{n+1}-2v_n + (1-A)n^2 + (2A-B)n + (A + B - C) = 0$$ So choose $$1 - A = 0 \implies A = 1$$ $$2A - B = 0 \implies B=2$$ $$A+B-C = 0 \implies C=3$$ Now all you have to do is solve $v_{n + 1} = 2v_{n}$.