Example 5. Find the sum of the series $f(x)=\sum_{n=0}^{\infty}\left(n^{2}+3 n-5\right) \cdot x^{n}$.
Solution. First, let's determine where the given series converges. Using D'Alembert's formula, it is easy to establish (do this) that the radius of convergence of the series is $R=1$. Therefore, the sum of the series is defined in the interval $(-1 ; 1)$.

The given series can be represented as the sum of three series:

$$
f(x)=\sum_{n=0}^{\infty}\left(n^{2}+3 n-5\right) \cdot x^{n}=\sum_{n=0}^{\infty} n^{2} \cdot x^{n}+\sum_{n=0}^{\infty} 3 n \cdot x^{n}-5 \cdot \sum_{n=0}^{\infty} x^{n}
$$

1) Start with the known equality (see Example 1): $\frac{1}{1-x}=$ $=\sum_{n=0}^{\infty} x^{n}, \quad|x|<1$. Thus, we have obtained the third term in $f(x)$.
2) Differentiate this series (geometric progression) (see Theorem 17): $\sum_{n=0}^{\infty} n x^{n-1}=\frac{1}{(1-x)^{2}}$, then multiply both sides by $3 x$: $\sum_{n=0}^{\infty} 3 n x^{n}=\frac{3 x}{(1-x)^{2}},|x|<1$ (we have obtained the second term in $f(x)$).
3) Multiply the intermediate series from step 2) by $x$:
$\sum_{n=0}^{\infty} n x^{n}=\frac{x}{(1-x)^{2}}, \quad|x|<1$. Differentiate this expansion: $\sum_{n=1}^{\infty} n^{2} \cdot x^{n-1}=\left(\frac{x}{(1-x)^{2}}\right)^{\prime}=\frac{1+x}{(1-x)^{3}}, \quad|x|<1$, and multiply this expansion by $x: \sum_{n=0}^{\infty} n^{2} x^{n}=\frac{x(1+x)}{(1-x)^{3}}$.

It remains to add the obtained intermediate results:

$$
\begin{aligned}
f(x)=\sum_{n=0}^{\infty}\left(n^{2}\right. & +3 n-5) x^{n}=\sum_{n=0}^{\infty} n^{2} x^{n}+\sum_{n=0}^{\infty} 3 n x^{n}-5 \sum_{n=0}^{\infty} x^{n}= \\
= & \frac{x(1+x)}{(1-x)^{3}}+\frac{3 x}{(1-x)^{2}}-\frac{5}{1-x}=\frac{-7 x^{2}+14 x-5}{(1-x)^{3}}, \quad|x|<1
\end{aligned}
$$

All intermediate series converge in the interval $(-1 ; 1)$, and therefore the original series converges in the interval $(-1 ; 1)$ to the obtained function.

Answer. $f(x)=\frac{7 x^{2}-14 x+5}{(x-1)^{3}}$.