Infinite integrals$\int_0^{ + \infty } {\frac{1}{{\left( {x + 1} \right)\left( {{x^n} + 1} \right)}}dx} .$ How to calculate
$$\int_0^{ + \infty } {\frac{1}{{\left( {x + 1} \right)\left( {{x^n} + 1} \right)}}dx} .$$
 A: For odd values of n, use the fact that $~\dfrac n{(1+x)(1+x^n)}~=~\dfrac1{(1+x)^2}~+~\dfrac{P_{n-2}(x)}{1+x^n}~,~$ where 
$P_{n-2}(x)~=~\displaystyle\sum_{k=0}^{n-2}(n-k-1)(-x)^k,~$ in conjunction with the famous identity $~\displaystyle\int_0^\infty\frac{x^{a-1}}{1+x^n}~dx$
$=~\dfrac\pi n\cdot\csc\bigg(a~\dfrac\pi n\bigg),~$ which can be proven using the substitution $t=\dfrac1{1+x^n}~,~$ followed by 
recognizing the expression of the beta function in the new integral, and then employing Euler's 
reflection formula for the $\Gamma$ function to simplify the result. For even values of n, a similar trick 
applies, with the caveat that the new formulas are $~\dfrac2{(1+x)(1+x^n)}~=~\dfrac1{1+x}~+~\dfrac{R_{n-1}(x)}{1+x^n}~,~$ 
where $~R_{n-1}(x)~=~\displaystyle\sum_{k=0}^{n-1}(-x)^k,~$ and the rather important observation that, for even values 
of n, $~\displaystyle\int_0^\infty\bigg(\frac1{1+x}-\frac{x^{n-1}}{1+x^n}\bigg)~dx~=~0.$
A: We have $\displaystyle\int_0^{\infty}\dfrac{dx}{(1+x)(1+x^n)}=\int_0^{\infty}\dfrac{dx}{1+x^n}-\int_0^{\infty}\dfrac{xdx}{1+x^n}$
$=\displaystyle\frac{1}{n}(B\Bigl(\frac{1}{n},1-\frac{1}{n},\Bigr)-B\Bigl(\frac{2}{n},1-\frac{2}{n},\Bigr))=\dfrac{\pi}{n\sin(\pi/n)}-\dfrac{\pi}{n\sin(2\pi/n)}$.
Second try. We have 
$\displaystyle\int_0^\infty\dfrac{dx}{(1+x)(1+x^n)}$
$=\displaystyle\dfrac{1}{2}\int_0^\infty\dfrac{1}{1+x}-\dfrac{x^{n-1}}{1+x^n}dx+\sum_{k=1}^{n-1}\dfrac{(-1)^k}{2}\int_0^\infty\dfrac{x^{n-k}}{1+x^n}$
$=\displaystyle\sum_{k=1}^{n-1}\dfrac{(-1)^k}{2}\int_0^\infty\dfrac{x^{n-k}}{1+x^n}$
$=\displaystyle\sum_{k=1}^{n-1}\dfrac{(-1)^k}{2n}B\Bigl(\frac{n-k+1}{n},1-\frac{n-k+1}{n}\Bigr)$
$=\displaystyle\sum_{k=1}^{n-1}\dfrac{(-1)^k}{2n}\dfrac{\pi}{sin(\pi(n-k+1)/n)}$.
