Example 4.28 Use red, blue, and green to color a $1 \times n$ chessboard, with each cell colored in one color. Find the number of coloring methods $e_{n}$ such that the number of cells colored red and blue are both even.
Let $e_{n}$ be the number of $n$-repeated permutations of the 3-element set $A=\{$ red square, blue square, green square $\}$ that satisfy the condition: “red squares and blue squares both appear an even number of times”. Thus, $e_{n}$ is the coefficient of $t^{n} / n!$ in the expansion of
$$
E(t)=\left(1+\frac{t^{2}}{2!}+\frac{t^{4}}{4!}+\cdots\right)^{2}\left(1+t+t^{2} / 2!+t^{3} / 3!+\cdots\right),
$$
and
$$
\begin{aligned}
E(t) & =\left(\frac{\mathrm{e}^{t}+\mathrm{e}^{-t}}{2}\right)^{2} \mathrm{e}^{t} \\
& =\frac{\mathrm{e}^{2 t}+2+\mathrm{e}^{-2 t}}{4} \cdot \mathrm{e}^{t}=\frac{\mathrm{e}^{3 t}+2 \mathrm{e}^{t}+\mathrm{e}^{-t}}{4} \\
& =\sum_{n=0}^{\infty} \frac{1}{4}\left[3^{n}+2+(-1)^{n}\right] \cdot t^{n} / n!,
\end{aligned}
$$
Therefore,
$$
e_{n}=\frac{3^{n}+2+(-1)^{n}}{4} .
$$