Example 1.6. Find: $\int \frac{x_{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)} d x$.
Solution. According to the theorem of decomposition into partial fractions, the decomposition of the integrand, representing a proper rational fraction, has the form:

$$
\frac{x^{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)}=\frac{A}{(x-2)^{2}}+\frac{B}{(x-2)}+\frac{M x+N}{x^{2}+x+1}
$$

We bring the expression on the right side to a common denominator:

$$
\begin{aligned}
& \frac{x^{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)}= \\
& \quad=\frac{A\left(x^{2}+x+1\right)+B(x-2)\left(x^{2}+x+1\right)+(M x+N)(x-2)^{2}}{(x-2)^{2}\left(x^{2}+x+1\right)}
\end{aligned}
$$

Since both fractions are identically equal, the following equality must hold:

$$
\begin{aligned}
& x^{3}+2 x^{2}-4 x-1=A\left(x^{2}+x+1\right)+ \\
& \quad+B(x-2)\left(x^{2}+x+1\right)+(M x+N)(x-2)^{2}
\end{aligned}
$$

Expanding the brackets in the right-hand side of the obtained equality and combining like terms, we get:

$$
\begin{array}{r}
x^{3}+2 x^{2}-4 x-1=x^{3}(B+M)+x^{2}(A-B-4 M+N)+ \\
+x(A-B-4 N+4 M)+A+4 N-2 B
\end{array}
$$

Equating the coefficients of the same powers of $x$, we obtain the following system of equations:

$$
\left\{\begin{array}{l}
B+M=1 \\
A-B-4 M+N=2 \\
A-B+4 M-4 N=-4 \\
A-2 B+4 N=-1
\end{array}\right.
$$

Solving this system, we will find the coefficients of the decomposition $A, B, M, N$. Subtract the third equation from the second equation of the system. We get

$$
8 M-5 N=-6
$$

Then subtract the fourth equation from the second equation of the system. We get

$$
B-4 M-3 N=-3
$$

Substituting $B=1-M$ from the first equation of the system into this equation, we get, together with (1.18), a system of two equations for $M$ and $N$

$$
\left\{\begin{array}{c}
8 M-5 N=-6 \\
-5 M-3 N=2
\end{array}\right.
$$

Solving it, we get: $M=-\frac{4}{7}, N=-\frac{2}{7}$.

Then $B=1-M=\frac{11}{7}, A=-1+2 B-4 N=1$. Thus, the desired decomposition of the fraction is

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

Considering the obtained decomposition, the desired integral can be represented as the following sum of integrals:

$$
\begin{aligned}
& \int \frac{x^{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)} d x=\int \frac{d x}{(x-2)^{2}}+ \\
& +\frac{11}{7} \int \frac{d x}{(x-2)}+\frac{1}{7} \int \frac{-4 x+2}{x^{2}+x+1} d x
\end{aligned}
$$

Integrating, we get:

$$
\begin{aligned}
& \int \frac{x^{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)} d x=-\frac{1}{(x-2)}+ \\
& +\frac{11}{7}|\ln x-2|+\frac{1}{7} \int \frac{-4(t-1 / 2)+2}{t^{2}+3 / 4} d t
\end{aligned}
$$

(in the last integral, a new variable $t=x+\frac{1}{2} \Rightarrow x=t-\frac{1}{2} \Rightarrow d t=d\left(x-\frac{1}{2}\right)=d x$ is introduced), consider the last integral. We have

$$
\begin{gathered}
\int \frac{-4(t-1 / 2)+2}{t^{2}+3 / 4} d t=-4 \int \frac{t d t}{t^{2}+3 / 4}+4 \int \frac{d t}{t^{2}+3 / 4}= \\
=-2 \int \frac{d\left(t^{2}+3 / 4\right)}{t^{2}+3 / 4}+4 \frac{2}{\sqrt{3}} \operatorname{arctg} \frac{2 t}{\sqrt{3}}+C= \\
=-2 \ln \left(t^{2}+3 / 4\right)+4 \frac{8}{\sqrt{3}} \operatorname{arctg} \frac{2 t}{\sqrt{3}}+C= \\
=-2 \ln \left(x^{2}+x+1\right)+4 \frac{8}{\sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+C
\end{gathered}
$$

After integration, we return to the already considered variable, taking into account that $x^{2}+x+1=t^{2}+3 / 4$. Thus

$$
\begin{array}{r}
\int \frac{x^{3}+2 x^{2}-4 x-1}{(x-2)^{2}\left(x^{2}+x+1\right)} d x=-\frac{1}{(x-2)}+\frac{11}{7}|\ln x-2|- \\
-\frac{2}{7} \ln \left(x^{2}+x+1\right)+\frac{8}{7 \sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+C
\end{array}
$$