Example 3. Find the integral of the improper rational function $I=\int \frac{x^{6}+2 x^{5}-x^{4}+x^{2}+2 x}{x^{4}+1} d x$.
Solution. Dividing the numerator by the denominator (it is recommended to do this "in column"), we single out the integer part of the fraction:

$$
\frac{x^{6}+2 x^{5}-x^{4}+x^{2}+2 x}{x^{4}+1}=x^{2}+2 x-1+\frac{1}{x^{4}+1}
$$

We decompose the proper fraction into the simplest ones, taking into account the equality

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

## We have

$$
\frac{1}{x^{4}+1}=\frac{A x+B}{x^{2}+\sqrt{2} x+1}+\frac{C x+D}{x^{2}-\sqrt{2} x+1}
$$

From the corresponding system (which we suggest to form and solve independently), we get $A=\frac{1}{2 \sqrt{2}}, B=\frac{1}{2}, C=-\frac{1}{2 \sqrt{2}}, D=\frac{1}{2}$. Let's return to the integrals, but first, let's show how to deal with one of the obtained fractions

$$
\begin{array}{r}
\int \frac{(A x+B) d x}{x^{2}+\sqrt{2} x+1}=\frac{1}{2 \sqrt{2}} \int \frac{x+\sqrt{2}}{x^{2}+\sqrt{2} x+1} d x=\frac{1}{2 \sqrt{2}} \int \frac{2 x+\sqrt{2}+\sqrt{2}}{2\left(x^{2}+\sqrt{2} x+1\right)} d x= \\
=\frac{1}{2 \sqrt{2}}\left(\frac{1}{2} \ln \left(x^{2}+\sqrt{2} x+1\right)+\frac{\sqrt{2}}{2} \int \frac{d x}{\left(x+\frac{\sqrt{2}}{2}\right)^{2}+\left(\frac{1}{\sqrt{2}}\right)^{2}}\right)= \\
=\frac{1}{2 \sqrt{2}}\left(\frac{1}{2} \ln \left(x^{2}+\sqrt{2} x+1\right)+\frac{\sqrt{2}}{2} \cdot \frac{2}{\sqrt{2}} \operatorname{arctg} \frac{2 x+\sqrt{2}}{\sqrt{2}}\right)+C_{1}= \\
=\frac{1}{4 \sqrt{2}} \ln \left(x^{2}+\sqrt{2} x+1\right)+\frac{1}{2 \sqrt{2}} \operatorname{arctg}(\sqrt{2} x+1)+C
\end{array}
$$

Similarly, the second fraction should be integrated. We get $\int \frac{(C x+D) d x}{x^{2}-\sqrt{2} x+1}=-\frac{1}{4 \sqrt{2}} \ln \left(x^{2}-2 \sqrt{x}+1\right)+\frac{1}{2 \sqrt{2}} \operatorname{arctg}(\sqrt{2} x-1)+C$

Finally, we get the answer.

$I=\frac{x^{3}}{3}+x^{2}-x+\frac{1}{4 \sqrt{2}} \ln \frac{x^{2}+\sqrt{x}+1}{x^{2}-\sqrt{2} x+1}+\frac{1}{2 \sqrt{2}} \operatorname{arctg}(\sqrt{2} x+1)+$ $+\frac{1}{2 \sqrt{2}} \operatorname{arctg}(\sqrt{2} x-1)+C$

Note. If necessary, the arctangents can be combined.