I want to find the sum to $n$ terms of the series $$1+4w+9w^2+...+n^2w^{n-1}$$ where$w$ is $n$th root of unity.
Let $$S_n = 1+4w+9w^2+...+n^2w^{n-1}$$ then $$ wS_n=w+4w^2+....+(n-1)^2w^{n-1}+n^2$$ therefore $$(1-w)S_n=1+3w+5w^2+...+(2n-1)w^{n-1}-n^2$$
Now when I find the sum of $$ 1+3w+5w^2+...+(2n-1)w^{n-1}$$ it comes out to be $$\frac{-2n}{1-w}$$ and after substituting we get $$ S_n= \frac{-2n}{(1-w)^2}-\frac{n^2}{1-w}$$
The problem is my book doesn't agree with my answer The answer is $$\frac{n[(1-w)n+2]}{3w}.$$