Suppose we have $$(1+x+x^2)^n = a_0 + a_1 x + a_2 x^2 + \cdots + a_{2n} x^{2n}.$$
What will be the value of $a_0^2 - a_1^2 + a_2^2 - \cdots + a_{2n}^2$?
The answer is $a_n$, but I can't solve it.
See, what I've done is substitute $x$ as $-\frac{1}{x}$ and I've got:
${\frac{(x^2-x+1)}{x^2}}^n = a_0 - \frac{a_1}{x} + \frac{a_2}{x^2}+...$
I've got the alternating signs but I can't get the squares of the numbers.
Let $(1+x+x^2)^n=\sum_ka_kx^k$. Then:
\begin{align} (1+x^2+x^4)^n&=(1-x^{-1}+x^{-2})^n(1+x+x^2)^nx^{2n}\\ \sum_ja_jx^{2j}&=\sum_k(-1)^ka_kx^{-k}\sum_ja_jx^jx^{2n}\\ &=\sum_j\sum_k(-1)^ka_ka_jx^{2n+j-k}\\ &=\sum_j\sum_k(-1)^ka_ka_{k+j-2n}x^j\\ \end{align}
The $x^{2n}$ coefficient on the left side is $a_n$; the same coefficient on the right side is $\sum_k(-1)^ka_k^2$.