<s>[INST] Calculate the following integral $ \int\frac{2x+1}{x^{n+2}(x+1)^{n+2}}\ln\left(\frac{2x^2+2x+1}{x^2(x+1)^2}+\frac7{16}\right)dx$ Hello I am trying to solve a pretty complicated integral. It is a from a set of problems, published in a monthly journal for high school students and they are exercises in preparation for a competition.
So the problem is the following: Calculate the integral $ \int \frac {2x+1}{x^{n+2}(x+1)^{n+2}} \ln\left(\frac {2x^2+2x+1}{x^2(x+1)^2} + \frac{7}{16}\right)dx$
I first tried partial integration, integrating $\frac {2x+1}{x^{n+2}(x+1)^{n+2}}$, it is happily easy to do it and we will end up with $\int \frac {2x+1}{x^{n+2}(x+1)^{n+2}} = \frac {-1}{x^{n+1}(x+1)^{n+1}}$.
I also differentiated $\ln\left(\frac {2x^2+2x+1}{x^2(x+1)^2} + \frac{7}{16}\right)$, ending up with $\frac {-64x^3-96x^2-96x-32}{7x^6+21x^5+71x^3+48x^2+16x}$
Now when I try to solve the integral of the product of these two, I am stuck.
I also thought about some kind of recursive relationship in terms of $n$ but I am not sure about it.
I would happily accept any help in solving this problem. Thanks in advance.
 [/INST] Integrate by parts:
$$\int \frac{2x+1}{x^{n+2}(x+1)^{n+2}} \ln\left(\frac{2x^2+2x+1}{x^2(x+1)^2} + \frac7{16}\right) \, dx \\
= -\frac1{n+1} \frac{\ln\left(\frac{2x^2+2x+1}{x^2(x+1)^2}+\frac7{16}\right)}{x^{n+1}(x+1)^{n+1}} - \frac{32}{n+1} \int \frac{2x^3+3x^2+3x+1}{x^{n+2}(x+1)^{n+2} \left(7x^4+14x^3+39x^2+32x+16\right)} \, dx$$
Expand into partial fractions:
$$\frac{2x^3+3x^2+3x+1}{7x^4+14x^3+39x^2+32x+16} = \frac18 \left(\frac{2x+1}{x^2+x+4} + \frac{2x+1}{7x^2+7x+4}\right)$$
The remaining integrals are elementary. For instance, substituting
$$x=\frac{\sqrt{4u-15}-1}2 \implies u = x^2+x+4 \implies du=2x+1\,dx$$
leads to
$$\int \frac{2x+1}{x^{n+2}(x+1)^{n+2}(x^2+x+4)} \, dx = \int \frac{du}{\left(\frac{\sqrt{4u-15}-1}2\right)^{n+2} \left(\frac{\sqrt{4u-15}-1}2+1\right)^{n+2} u} = \int \frac{du}{\left(u-4\right)^{n+2}u}$$
and can be further developed with partial fraction expansions.
</s>