If $$ (1+x+x^2)^n=\sum_{r=0}^{2n}a_rx^r $$ then find the sum of : $$ a_0^2-a_1^2+a_2^2 +.....+(-1)^{n-1}a_{n-1}^2=\sum_{r=0}^{n-1}(-1)^{r-1}a_r^2 $$ in terms of $a_n$ and $n$.
What I've done : I've tried replacing $x$ with $\frac{-1}{x}$ and then multiplying the resultant series with the original series. However, this proved long and tedious and I gave up. Is there any other method to solve this question ? The answer given in my textbook is $\frac{a_n(1-(-1)^na_n)}{2}$. However I believe this answer to be wrong since the previous owner has written so in the margin.
Thankyou.