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?
 A: 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$.
A: Here is a way through.
You have $s=1+ \dots +x^{2018}$ so that $(xs')'=xs''+s'=x+4x^2+\dots +(2018)^2x^{2017}$
Lets do the general case with $n$ instead of $2018$ so that:
$$s=\frac {x^{n+1}-1}{x-1}=\frac {p(x)}{q(x)}$$
Now note that evaluating at $\epsilon$ where $\epsilon^n=1$ we have  $p(\epsilon)=q(\epsilon)$, $p'(\epsilon)=n+1$ and $\epsilon p''(\epsilon)=n(n+1)$. We have also $q'(x)=1$, and $q''(x)=0$ which can be applied before evaluating.
Next we take the necessary derivatives $$s'=\frac {p'q-pq'}{q^2}=\frac {p'q-p}{q^2}$$
and $$(xs')'=\left(\frac{xp'q-xp}{q^2}\right)'=\frac{\left(p'q+xp''q+xp'-p-xp'\right)q^2-2q\left(xp'q-xp\right)}{q^4}$$
Now we can evaluate at $\epsilon$ using the simplifications noted earlier so that the numerator becomes $$\left((n+1)q+n(n+1)q-q\right)q^2-2q^2\epsilon n=$$$$=(n^2+2n)q^3-2q^2\epsilon n$$ and taking out a factor of $q^2$ to cancel with the denominator, and setting $q=\epsilon -1$ we get a numerator of $$n^2\epsilon-n(n+2)$$
as required.
I think this simplifies the calculations somewhat. The trick of putting $n$ instead of a large constant can, in appropriate cases, save quite a lot of writing in this kind of question and can also help to illuminate what is going on, as some of the cancellations and factorisations may be more obvious.
