I have the following exponential generating function G(x),
\begin{align*} {G(x)}&=\left(e^x-1\right)(e^x-1-x)e^x\\ &{=e^{3x}\color{blue}{-(x+2)e^{2x}+(x+1)e^x}} \end{align*}
As far as I see, I can write $e^{3x}$ as $3^n$ although I don't know the logic behind it.. But I don't know how to write the blue part as such.
How is the following obtained, for example, $n2^{n-1}$ and the others? Could you please help and explain?
$$\sum_{n=1}^{\infty} a_{n} \frac{x^n}{n!} = \sum_{n=1}^{\infty} 3^{n} \frac{x^n}{n!} - \sum_{n=1}^{\infty}n2^{n-1} \frac{x^n}{n!} - \sum_{n=1}^{\infty} 2^{n+1} \frac{x^n}{n!} + \sum_{n=1}^{\infty}(n+1) \frac{x^n}{n!}$$
It is convenient to use the coefficient of operator $[x^n]$ to denote the coefficient of $x^n$ of a series.
Comment:
In (1) we use the linearity of the coefficient of operator.
In (2) we apply the rule $[x^{p-q}]A(x)=[x^p]x^qA(x)$.
In (3) we use the series expansion of the series at $x=0$.
In (4) we select the coefficient of $[x^n]$ and $[x^{n-1}]$.