# sequences breakdown

The question is using the method of differences solve $S_{n}=0+3x+...+(i^2-1)x^i-1+...$ using methods of differences. The answer comes out as $\frac{3x-x^2-n(n+2)x^n+(2n^2+2n-3)x^n+1-(n^2-1)x^n+2}{(1-x^3)}$ I'm used to simply using the technique $(1-x)s_{n}$ but from the denominator of the answer i presume this isnt the case for this question, do you have any tips as to recognie the technique im supposed to use and how this was done.
The second problem is $1+2^2x+3^2x^2+4^2x^3+...$ any ideas how they got $\frac{1+x-(1+n)^2x^2+2n(n+1)x^n+1-n^2x^n+2}{(1-x)^3}$??? thnx