How to calculate this integral $$ \int_{0}^{\infty} \left(\frac{x - 1}{\ln(x)}\right)^2 \cdot \frac{1}{1 + x^n} \,dx$$
This is how I start $$f(a)=\int_{0}^{\infty} \frac{(x^a-1)^2}{\ln^2(x)}\frac{1}{1+x^n}dx$$ Feynman trick $$f’’(a)=\int_{0}^{\infty} \frac{4x^{2a}}{1+x^n} - \frac{2x^a}{1+x^n} dx$$ used well known value of $$\int_{0}^{\infty} \frac{x^c}{1+x^b}dx $$
$$ \int_{0}^{\infty} \left(\frac{x - 1}{\ln(x)}\right)^2 \cdot \frac{1}{1 + x^n} \,dx=2 \int_0^1 \left( \ln \tan \frac{\pi(2t+1)}{2n}-\ln \tan \frac{\pi(t+1)}{2n} \right) dt$$
or
$$ \int_{0}^{\infty} \left(\frac{x - 1}{\ln(x)}\right)^2 \cdot \frac{1}{1 + x^n} \,dx=\frac{2n}{\pi} \left( \int_\frac{\pi}{n}^\frac{3\pi}{2n} \ln \tan x dx - \int_\frac{\pi}{2n}^\frac{\pi}{n} \ln \tan x dx\right) dt$$
which seems numerically correct. How would you suggest to proceed?
Making the substitution $x=e^{2\pi t}$ $$I_0=\int_{0}^{\infty} \left(\frac{x - 1}{\ln(x)}\right)^2 \cdot \frac{dx}{1 + x^n} =\frac1{2\pi}\int_{-\infty}^\infty\frac{(e^{2\pi t}-1)^2e^{2\pi t}}{t^2(e^{2\pi n t}+1)}dt$$ For convenience we will consider $$I(a)=\frac1{2\pi}\int_{-\infty}^\infty\frac{(e^{2\pi t}-1)^2e^{2\pi t}}{(t^2+a^2)(e^{2\pi n t}+1)}dt$$ It is clear that $I_0=I(0)$ (and we consider the case $n$ is integer and $\,\geqslant3$)
Making straightforward transformations, we can present the integral in the form $$I(a)=\frac1{2\pi a}\Re\,\frac{\partial}{\partial a}\int_{-\infty}^\infty\ln(a-it)\frac{(e^{2\pi t}-1)^2e^{2\pi t}}{e^{2\pi n t}+1}dt$$ Using the fact that $e^{2\pi (t+i)}=e^{2\pi t}\,$ $\,e^{2\pi n (t+i)}=e^{2\pi n t}$ and $\,\ln(a-it)=\ln\Gamma\big(a-i(t+i)\big)-\ln\Gamma\big(a-it\big)$, we can present our integral as the integral in the complex plane along the rectangular contour $C$: $-R\to R\to R+i\to-R+i\to-R$ (the method was developed by Iaroslav V. Blagouchine).
$$I(a)=-\frac1{2\pi a}\Re\,\frac{\partial}{\partial a}\oint_C\ln\Gamma(a-iz)\frac{(e^{2\pi z}-1)^2e^{2\pi z}}{e^{2\pi n z}+1}dz$$ We have simple poles at $z=\frac{2k+1}{2n}i$; therefore $$I(a)=-\frac1{2\pi a}\Re\,\frac{\partial}{\partial a}2\pi i\sum_{k=0}^{n-1}\underset{z=\frac{2k+1}{2n}i}{\operatorname{Res}}\ln\Gamma(a-iz)\frac{(e^{2\pi z}-1)^2e^{2\pi z}}{e^{2\pi n z}+1}$$ $$=-\frac1{2\pi na}\Im\,\sum_{k=0}^{n-1}\psi\Big(a+\frac{2k+1}{2n}\Big)\left(e^{\frac\pi n(2k+1)i}-1\right)^2e^{\frac\pi n(2k+1)i}$$ $$=-\frac1{2\pi na}\sum_{k=0}^{n-1}\psi\Big(a+\frac{2k+1}{2n}\Big)\left(\sin\frac{3\pi} n(2k+1)-2\sin\frac{2\pi} n(2k+1)+\sin\frac{\pi} n(2k+1)\right)$$ Using the formula (please, see the work of Iaroslav V. Blagouchine, appendix B (B10), or Wikipedia) $$\sum_{k=0}^{n-1}\psi\Big(\frac{2k+1}{2n}\Big)\sin\frac{l\pi} n(2k+1)=-\frac{\pi n}2,\quad l=1,2,...n-1$$ we get $$\sum_{k=0}^{n-1}\psi\Big(\frac{2k+1}{2n}\Big)\left(\sin\frac{3\pi} n(2k+1)-2\sin\frac{2\pi} n(2k+1)+\sin\frac{\pi} n(2k+1)\right)=0$$ as it should be.
Decomposing at $\,a\to 0\,$ $\,\psi\Big(a+\frac{2k+1}{2n}\Big)=\psi\Big(\frac{2k+1}{2n}\Big)+\psi^{(1)}\Big(\frac{2k+1}{2n}\Big)\cdot a+O(a^2)$
we finally get $$I_0=-\frac1{2\pi n}\sum_{k=0}^{n-1}\psi^{(1)}\Big(\frac{2k+1}{2n}\Big)\left(\sin\frac{3\pi} n(2k+1)-2\sin\frac{2\pi} n(2k+1)+\sin\frac{\pi} n(2k+1)\right)$$ $$=\frac2{\pi n}\sum_{k=0}^{n-1}\psi^{(1)}\Big(\frac{2k+1}{2n}\Big)\cdot\sin^2\frac\pi {2n}(2k+1)\cdot\sin\frac{2\pi} n(2k+1)$$ Numeric evaluation (WA) confirms the answer.