<s>[INST] Sum of $1+4\epsilon +9\epsilon^2 +16\epsilon^3+...+2018^2 \epsilon^{2017}$ I have this problem from a college exam: Let $\epsilon$ be a non-real root of unity of order 2018, find the sum$$S=1+4\epsilon +9\epsilon^2 +16\epsilon^3+...+2018^2 \epsilon^{2017}$$Here is my try. First I considered $$S_1=\sum_{k=0}^{2018} x^k=\frac{1-x^{2019}}{1-x}$$ Now I derivate one time then I multiply again by x to get: $$\sum_{k=0}^{2018} kx^k=\frac{x-x^{2020}-2019x^{2019}}{(1-x)^2}$$ And now I must derivate one more time and set $x=\epsilon$ in order to get the desired sum: $$S=\sum_{k=0}^{2018} k^2\epsilon^{k-1}=\frac{2019^2\epsilon^{2018}-2020\epsilon^{2020}-(2019^2-3\cdot2019-1)\epsilon^{2019}-\epsilon-1}{(1-\epsilon)^3}$$ And my final simplification to the numerator was:$$\epsilon(2019^2-2021)-2018\epsilon^2-2019^2-1$$ Now there were 5 answers given, and not a single one  was even close to this one. Out of luck because only 2 answer had $1-\epsilon$ in the denominator I have choosen the correct one, which was: $$S=\frac{2018(2018\epsilon-2020)}{(1-\epsilon)^2}$$ Can you help me to get that  answer?
 [/INST] Using the operator $\delta = x \, \frac{d}{dx}$ leads to
\begin{align}
\sum_{k=0}^{n} x^{k} &= \frac{1 - x^{n+1}}{1-x} \\
\sum_{k=0}^{n} k \, x^{k} &= \delta \left(\frac{1 - x^{n+1}}{1-x} \right) = \frac{x - (n+1) x^{n+1} + n x^{n+2}}{(1-x)^2}  \\
\sum_{k=0}^{n} k^{2} \, x^{k} &= \delta^{2} \left(\frac{1 - x^{n+1}}{1-x} \right) = \frac{x(1 + x - (n+1)^2 x^n + (2n^2 +2n -1) x^{n+1} - n^2 x^{n+2})}{(1-x)^{3}}
\end{align}
Letting $x^{n} =1$ gives
\begin{align}
\sum_{k=1}^{n} k^{2} \, x^{k-1} &= \frac{1 + x - (n+1)^2 + (2n^2 +2n -1) x - n^2 x^2}{(1-x)^{3}} \\
&= - \frac{n \, (n+2 + 2 (n+1) x + n x^2)}{(1-x)^3}
\end{align}
Now let $n=2018$.
</s>