Sum of $1+4\epsilon +9\epsilon^2 +16\epsilon^3+...+2018^2 \epsilon^{2017}$

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$.


Consider the sum $$1+x+x^2+\dots+x^{2018}=\frac{1-x^{2019}}{1-x}$$ Differentiate both sides once: $$1+2x+3x^2+\dots+2018x^{2017}=\frac{1-x^{2019}}{{(1-x)}^2}-\frac{2019x^{2018}}{1-x}$$

Multiply both sides by $x$:$$x+2x^2+3x^3+\dots+2018x^{2018}=\frac{x-x^{2020}}{{(1-x)}^2}-\frac{2019x^{2019}}{1-x}$$ and differentiate again w.r.t. it: $$S'=1+4x +9x^2 +16x^3+...+2018^2 x^{2017}$$ On the right hand side, $$S'=\frac{2(x-x^{2020})}{(1-x)^3}+\frac{1-2020x^{2019}-2019x^{2019}}{(1-x)^2}-\frac{2019^2x^{2018}}{1-x}$$ Now, realising $\epsilon$ is a root of unity of order 2018, with $$\begin{cases} \epsilon^{2018} = 1 \\ \epsilon^{2019} = \epsilon \\ \epsilon^{2020} = \epsilon^2 \text{,} \\ \end{cases}$$ you then have$$\begin{align}S&=\frac{2(\epsilon-\epsilon^2)}{(1-\epsilon)^3}+\frac{1-2020\epsilon-2019\epsilon}{(1-\epsilon)^2}-\frac{2019^2}{1-\epsilon}\\ &=\frac{2\epsilon+1-2020\epsilon-2019\epsilon-2019^2+2019^2\epsilon}{(1-\epsilon)^2}\\&=\frac{2018^2\epsilon+(1+2019)(-2018)}{(1-\epsilon)^2}\\&=\frac{2018(2018\epsilon-2020)}{(1-\epsilon)^2}\end{align}$$

Comment: A correct sum gives you a correct answer. Also, don't plug in $\epsilon$ until you have the desired sum because there's something to "carry".