Example. Find the indefinite integral

$$
\int \frac{2 x^{3}+3 x^{2}+3 x+2}{\left(x^{2}+x+1\right)\left(x^{2}+1\right)} d x
$$
## Solution.

1. The integrand is a proper rational fraction.
2. Decompose it into partial fractions. The denominator has two pairs of complex conjugate roots: $r_{1,2}=-1 / 2 \pm i \sqrt{3} / 2$ and $r_{3,4}= \pm i$. Therefore, the partial fraction decomposition has the form

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

3. To find the coefficients $A_{1}, A_{2}, B_{1}, B_{2}$, we bring the fractions on the right-hand side to a common denominator:

$$
\frac{2 x^{3}+3 x^{2}+3 x+2}{\left(x^{2}+x+1\right)\left(x^{2}+1\right)} \equiv \frac{\left(A_{1} x+B_{1}\right)\left(x^{2}+1\right)+\left(A_{2} x+B_{2}\right)\left(x^{2}+x+1\right)}{\left(x^{2}+x+1\right)\left(x^{2}+1\right)}
$$

By equating the coefficients of like powers of $x$ in the numerators on the left and right, we obtain a system of four equations with four unknowns

$$
\left\{\begin{array}{l}
A_{1}+A_{2}=2 \\
A_{2}+B_{1}+B_{2}=3 \\
A_{1}+A_{2}+B_{2}=3 \\
B_{1}+B_{2}=2
\end{array}\right.
$$

This system has a unique solution

$$
A_{1}=1, \quad A_{2}=1, \quad B_{1}=1, \quad B_{2}=1
$$

Thus, the integrand has the form

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

4. Integrating the partial fractions, we get

$$
\begin{aligned}
& \int \frac{x+1}{x^{2}+x+1} d x=\frac{1}{2} \ln \left(x^{2}+x+1\right)+\frac{1}{\sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+C_{1} \\
& \int \frac{x+1}{x^{2}+1} d x=\frac{1}{2} \ln \left(x^{2}+1\right)+\operatorname{arctg} x+C_{2}
\end{aligned}
$$

Answer. $\int \frac{2 x^{3}+3 x^{2}+3 x+2}{\left(x^{2}+x+1\right)\left(x^{2}+1\right)} d x=$

$$
=\frac{1}{2} \ln \left(x^{2}+x+1\right)\left(x^{2}+1\right)+\frac{1}{\sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+\operatorname{arctg} x+C
$$

Conditions of the Problems. Find the indefinite integrals.

1. $\int \frac{1}{(x+1)^{2}\left(x^{2}+1\right)} d x$.
2. $\int \frac{2 x^{2}+x+3}{(x+2)\left(x^{2}+x+1\right)} d x$.
3. $\int \frac{1}{x^{3}-8} d x$.
4. $\int \frac{x^{3}+x+1}{x^{4}-1} d x$.
5. $\int \frac{7 x^{2}-1}{x^{4}+4 x^{2}-5} d x$.
6. $\int \frac{x+1}{\left(x^{2}+1\right)\left(x^{2}+9\right)} d x$.
7. $\int \frac{1}{x^{5}-x^{2}} d x$.
8. $\int \frac{x^{3}+x}{(x+1)\left(x^{2}+2 x+2\right)} d x$.
9. $\int \frac{3 x^{3}+x^{2}+5 x+1}{x^{3}+x} d x$.
10. $\int \frac{x^{4}}{x^{4}-16} d x$.

Answers.

1. $-\frac{1}{2(x+1)}+\frac{1}{4} \ln \frac{(x+1)^{2}}{x^{2}+1}+C$.
2. $3 \ln |x+2|-\frac{1}{2} \ln \left(x^{2}+x+1\right)+\frac{1}{\sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+C$.
3. $\frac{1}{24} \ln \frac{(x-2)^{2}}{x^{2}+2 x+4}-\frac{\sqrt{3}}{12} \operatorname{arctg} \frac{x+1}{\sqrt{3}}+C$.
4. $\frac{1}{4} \ln \left|(x-1)^{3}(x+1)\right|-\frac{1}{2} \operatorname{arctg} x+C$.
5. $\frac{1}{2} \ln \left|\frac{x-1}{x+1}\right|+\frac{6}{\sqrt{5}} \operatorname{arctg} \frac{x}{\sqrt{5}}+C$.
6. $\frac{1}{16} \ln \frac{x^{2}+1}{x^{2}+9}+\frac{1}{8} \operatorname{arctg} x-\frac{1}{24} \operatorname{arctg} \frac{x}{3}+C$.
7. $\frac{1}{x}+\frac{1}{6} \ln \frac{(x-1)^{2}}{x^{2}+x+1}+\frac{1}{\sqrt{3}} \operatorname{arctg} \frac{2 x+1}{\sqrt{3}}+C$.
8. $x-\frac{1}{2} \ln \left[\left(x^{2}+2 x+2\right)(x+1)^{4}\right]+3 \operatorname{arctg}(x+1)+C$.
9. $3 x+\ln |x|+2 \operatorname{arctg} x+C$.
10. $x+\frac{1}{2} \ln \left|\frac{x-2}{x+2}\right|-\operatorname{arctg} \frac{x}{2}+C$.

## 7.6. Integration of Expressions $R(\sin x, \cos x)$

Problem Statement. Find the indefinite integral

$$
\int R(\sin x, \cos x) d x
$$

where $R$ is a rational function of two variables.

PLAN OF SOLUTION.

1. Using the substitution

$$
t=\operatorname{tg} \frac{x}{2}
$$

integrals of functions $R(\sin x, \cos x)$ are reduced to integrals of rational functions of the new variable $t$. Indeed, substituting into the integrand

$$
\sin x=\frac{2 t}{1+t^{2}}, \quad \cos x=\frac{1-t^{2}}{1+t^{2}}, \quad d x=\frac{2}{1+t^{2}} d t
$$

we get

$$
R(\sin x, \cos x) d x=R\left(\frac{2 t}{1+t^{2}}, \frac{1-t^{2}}{1+t^{2}}\right) \frac{2}{1+t^{2}} d t=R_{1}(t) d t
$$

The substitution $t=\operatorname{tg}(x / 2)$ is called the universal substitution.

2. Apply the formula for the change of variable in an indefinite integral

$$
\int R(\sin x, \cos x) d x=\int R\left(\frac{2 t}{1+t^{2}}, \frac{1-t^{2}}{1+t^{2}}\right) \frac{2}{1+t^{2}} d t
$$

3. Compute the antiderivative of the rational function of $t$ and return to the variable $x$ by substituting $t=\operatorname{tg}(x / 2)$.

Remark. If the integrand has a special form, it is better to use substitutions that require fewer calculations:

a) if

$$
R(\sin x, \cos x)=R_{1}\left(\sin x, \cos ^{2} x\right) \cos x
$$

then we use the substitution $t=\sin x$. Indeed, the integrand becomes

$$
R_{1}\left(\sin x, \cos ^{2} x\right) \cos x d x=R_{1}\left(t, 1-t^{2}\right) d t
$$

b) if

$$
R(\sin x, \cos x)=R_{2}\left(\sin ^{2} x, \cos x\right) \sin x
$$

then we use the substitution $t=\cos x$. Indeed, the integrand becomes

$$
R_{2}\left(\sin ^{2} x, \cos x\right) \sin x d x=-R_{2}\left(1-t^{2}, t\right) d t
$$

c) if

$$
R(\sin x, \cos x)=R_{3}(\operatorname{tg} x)
$$

then we use the substitution $t=\operatorname{tg} x$. Indeed, the integrand becomes

$$
R_{3}(\operatorname{tg} x) d x=R_{3}(t) \frac{1}{1+t^{2}} d t
$$