8.1. In the expansion of the function $f(x)=\left(1+x-x^{2}\right)^{20}$ in powers of $x$, find the coefficient of $x^{3 n}$, where $n$ is equal to the sum of all coefficients of the expansion.
Answer: 760.

Solution. The expansion in powers of $x$ has the form $f(x)=\sum_{k=0}^{40} a_{k} x^{k}$. The sum of all coefficients is $\sum_{k=0}^{40} a_{k}=f(1)=1$. Therefore, we need to find the coefficient of $x^{3}$. We have:

$$
\begin{aligned}
f(x)=\left(\left(1-x^{2}\right)+x\right)^{20}=(1- & \left.x^{2}\right)^{20}+20\left(1-x^{2}\right)^{19} x+\frac{20 \cdot 19}{2}\left(1-x^{2}\right)^{18} x^{2}+ \\
& +\frac{20 \cdot 19 \cdot 18}{6}\left(1-x^{2}\right)^{17} x^{3}+\text { terms in which } x^{3} \text { does not appear. }
\end{aligned}
$$

In the first and third terms, $x^{3}$ does not appear. In the second term, $x^{3}$ appears with the coefficient $(-20) \cdot 19=-380$; in the fourth term, $x^{3}$ appears with the coefficient $\frac{20 \cdot 19 \cdot 18}{6}=1140$. Therefore, the coefficient of $x^{3}$ is $-380+1140=760$.