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.
 A: 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.
A: Starting as you did, with
$$du=\frac {2x+1}{x^{n+2}(x+1)^{n+2}}\,dx\qquad \text{and}\qquad v=\log\left(\frac {2x^2+2x+1}{x^2(x+1)^2} + \frac{7}{16}\right)$$as you wrote
$$u= -\frac {1}{(n+1)x^{n+1}(x+1)^{n+1}}$$ $$ dv=-\frac{32 (2 x+1) \left(x^2+x+1\right)}{x (x+1) \left(x^2+x+4\right) (7 x^2+7x+4)}$$
$$u\,dv=\frac {32}{n+1}\,\,\frac{ (2 x+1) \left(x^2+x+1\right)}{x (x+1) \left(x^2+x+4\right) (7 x^2+7x+4)x^{n+1}(x+1)^{n+1}}$$ Consider now that
$$A=\frac{ (2 x+1) \left(x^2+x+1\right)}{x (x+1) \left(x^2+x+4\right) (7 x^2+7x+4)}$$ can be decomposed as
$$A=-\frac{2}{x}-\frac{2}{x+1}+\frac 1{a-b}\left(\frac{2 a+1}{x-a}-\frac{2 b+1}{x-b} \right)+\frac 1{c-d}\left(\frac{2 c+1}{x-c}-\frac{2 d+1}{x-d}\right)$$ where $(a,b)$ are the complex roots of $x^2+x+4=0$ and $(c,d)$ are the complex roots of $7x^2+7x+4=0$.
So, we face by the end
$$I_1=\int \frac {dx}{ x^{n+2} (x+1)^{n+1}}=-\frac{\, _2F_1(-n-1,n+1;-n;-x)}{(n+1)x^{n+1}}$$
$$I_2=\int \frac {dx}{ x^{n+1} (x+1)^{n+2}}=-\frac{ \, _2F_1(-n,n+2;1-n;-x)}{n x^n}$$
where appears the Gaussian hypergeometric function
and four integrals of the form
$$I_k=\int \frac {dx}{x^{n+1}(x+1)^{n+1}(x-k)} \quad\quad\quad k\neq 0 \quad k \in \mathbb{C}$$
$$I_k=\frac {\frac{x F_1\left(1-n;n,1;2-n;-x,\frac{x}{k}\right)}{k^2 (n-1)}+\frac{(2 k+1) \,
   _2F_1(-n,n;1-n;-x)}{k n}-\frac{(x+1)^{-n}}{n}}{(1+k)x^n }$$ where also appears  the Appell hypergeometric function of two variables.
All of that seems to be complicated but as soon as you give $n$ an integer value you will have for
$$J_n=\int \frac {A}{x^{n+1}(x+1)^{n+1}}\,dx$$ things like
$$\color{blue}{J_n=\alpha_n \sqrt{7} \tan ^{-1}\left(\frac{ \sqrt{7}}{3} (2 x+1)\right)+\beta_n \sqrt{15} \tan ^{-1}\left(\frac{2 x+1}{\sqrt{15}}\right)+}$$
$$\color{blue}{\gamma_n \log(x)+\delta_n \log(x^2+x+4)+\epsilon_n \log(7x^2+7x+4)-\frac{P_{n-1}(x)}{x^{n+1}}}$$ where $(\alpha_n,\beta_n, \gamma_n,\delta_n ,\epsilon_n)$ are rational numbers and all coefficients in the polynomials are all rational and positive.
Notice that the last integral in @user170231's answer
$$I=\int \frac{du}{\left(u-4\right)^{n+2}u}=-\frac {\, _2F_1\left(1,-n-1;-n;1-\frac{u}{4}\right) } {4 (n+1) (u-4)^{n+1} }$$
A: As said in comments, using $u=x(x+1)$  as @David Quinn suggested the problem reduces to
$$I=\int\frac 1 {u^{n+2}} \log \left(\frac{7 u^2+32 u+16}{16 u^2}\right)\,du$$ which is
$$I=-\frac{2+(n+1) \log \left(16 u^2\right)}{(n+1)^2\, u^{n+1}}+\int \frac 1 {u^{n+2}}\log(7 u^2+32 u+16)\,du $$
$$J=\int \frac 1 {u^{n+2}}\log(7 u^2+32 u+16)\,du $$
$$J=\log(7)\int \frac {du}{u^{n+2}}+\int \frac{\log(u+4)}{u^{n+2}}\,du+\int \frac{\log \left(u+\frac{4}{7}\right)}{u^{n+2}}\,du$$
$$J=-\frac{\log(7)}{(n+1) u^{n+1} }+\int \frac{\log(u+4)}{u^{n+2}}\,du+\int \frac{\log \left(u+\frac{4}{7}\right)}{u^{n+2}}\,du$$
$$K_a=\int \frac{\log \left(u+a\right)}{u^{n+2}}\,du$$
$$K_a=-\frac{u \,\, _2F_1\left(1,-n;1-n;-\frac{u}{a}\right)+a n \log (u+a) } {a n (n+1) u^{n+1} }$$
