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

As you showed above, $$(1-w)S_{n}=1+3w+5w^2+\cdots +(2n-1)w^{n-1}-n^2.$$ Thus, $$(1-w)S_n +n^2 = 1+3w+5w^2+\cdots +(2n-1)w^{n-1}.$$ We now need the following fact (which you allude to, and I can prove but it might make this answer very long) $$ 1+3w+5w^2+\cdots +(2n-1)w^{n-1} = \frac{2n}{w-1}.$$ Combining these identities, we get $$(1-w)S_n +n^2 = \frac{2n}{w-1},$$ so $$(w-1)S_n - n^2 = -\frac{2n}{w-1},$$ and solving for $S_n$, we get $$S_n = \frac{n^2}{(w-1)} - \frac{2n}{(w-1)^2}.$$ The answer in the above form appears as an exercise in the book Complex Function Theory by Donald Sarason (page 8), and so I am sure it is correct.
