Example 4. Find the integral $\int \frac{x^{3}+x^{2}+2}{x\left(x^{2}-1\right)^{2}} d x$.
Solution. We decompose the integrand into partial fractions. Since the denominator has roots $x_{1}=1$ and $x_{2}=-1$ of multiplicity 2 and a simple root $x_{3}=0$, the decomposition will take the form

$$
\frac{x^{3}+x^{2}+2}{x\left(x^{2}-1\right)^{2}}=\frac{A}{x}+\frac{B_{1}}{x-1}+\frac{B_{2}}{(x-1)^{2}}+\frac{C_{1}}{x+1}+\frac{C_{2}}{(x+1)^{2}}
$$

from which

$$
\begin{gathered}
x^{3}+x^{2}+2=A(x-1)^{2}(x+1)^{2}+B_{1} x(x-1)(x+1)^{2}+ \\
+B_{2} x(x+1)^{2}+C_{1} x(x+1)(x-1)^{2}+C_{2} x(x-1)^{2} \\
x^{3}+x^{2}+2=x^{4}\left(A+B_{1}+C_{1}\right)+x^{3}\left(B_{1}+B_{2}-C_{1}+C_{2}\right)+ \\
+x^{2}\left(2 B_{2}-2 A-B_{1}-2 C_{2}-C_{1}\right)+x\left(B_{2}-B_{1}+C_{2}+C_{1}\right)+A
\end{gathered}
$$

By comparing the coefficients of like powers of $x$, we obtain five equations to determine the five unknowns:

$$
\begin{gathered}
A+B_{1}+C_{1}=0 ; \\
B_{1}+B_{2}-C_{1}+C_{2}=1 ; \\
2 B_{2}-2 A-B_{1}-2 C_{2}-C_{1}=1 ; \\
B_{2}-B_{1}+C_{2}+C_{1}=0 ; \\
A=2
\end{gathered}
$$

Solving the resulting system, we find

$$
A=2, B_{1}=-\frac{3}{4}, B_{2}=1, C_{1}=-\frac{5}{4}, C_{2}=-\frac{1}{2}
$$

Thus, the integrand decomposes into partial fractions as follows:

$$
\frac{x^{3}+x^{2}+2}{x\left(x^{2}-1\right)^{2}}=\frac{2}{x}-\frac{3}{4(x-1)}+\frac{1}{(x-1)^{2}}-\frac{5}{4(x+1)}-\frac{1}{2(x+1)^{2}}
$$

Integrating, we get

$$
\begin{gathered}
\int \frac{x^{3}+x^{2}+2}{x\left(x^{2}-1\right)^{2}} d x=2 \int \frac{d x}{x}-\frac{3}{4} \int \frac{d(x-1)}{x-1}+\int \frac{d(x-1)}{(x-1)^{2}}- \\
-\frac{5}{4} \int \frac{d(x+1)}{x+1}-\frac{1}{2} \int \frac{d(x+1)}{(x+1)^{2}}= \\
=2 \ln x-\frac{3}{4} \ln |x-1|-\frac{1}{x-1}-\frac{5}{4} \ln |x+1|+\frac{1}{2(x+1)}+C= \\
=\frac{x+3}{2\left(1-x^{2}\right)}+\ln \frac{x^{2}}{\sqrt[4]{|x-1|^{3}|x+1|^{5}}}+C
\end{gathered}
$$