<s>[INST] A different type binomial expansion problem 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. 
 [/INST] Since
$$
(1+x+x^2)^n=\sum_{k=0}^{2n}a_kx^k\tag{1}
$$
we can look at the following in two ways
$$
\begin{align}
\left(1+\frac1x+\frac1{x^2}\right)^n
&=\sum_{k=0}^{2n}a_k\frac1{x^k}\\
&=\sum_{k=0}^{2n}a_kx^{-k}\tag{2}
\end{align}
$$
or as
$$
\begin{align}
\left(\frac1{x^2}+\frac1x+1\right)^n
&=\left(\frac{1+x+x^2}{x^2}\right)^n\\
&=\sum_{k=0}^{2n}a_kx^{k-2n}\\
&=\sum_{k=0}^{2n}a_{2n-k}x^{-k}\tag{3}
\end{align}
$$
Therefore, $(2)$ and $(3)$ show that $a_k$ is palindromic; that is,
$$
a_k=a_{2n-k}\tag{4}
$$
Furthermore, using $(1)$ and substituting $x\mapsto-x$, we get
$$
(1-x+x^2)^n=\sum_{k=0}^{2n}(-1)^ka_kx^k\tag{5}
$$
Using $(1)$, $(4)$, $(5)$, and the formula to multiply power series, we get the coefficient of $x^{2n}$ in $(1+x+x^2)^n(1-x+x^2)^n$ is
$$
\sum_{k=0}^{2n}(-1)^ka_ka_{2n-k}=\sum_{k=0}^{2n}(-1)^ka_k^2\tag{6}
$$
We can use $(1)$ to get that  the coefficient of $x^{2n}$ in $(1+x^2+x^4)^n$ is
$$
a_n\tag{7}
$$
Noting that $(1+x+x^2)^n(1-x+x^2)^n=(1+x^2+x^4)^n$, $(6)$ and $(7)$ show that
$$
\sum_{k=0}^{2n}(-1)^ka_k^2=a_n\tag{8}
$$
</s>