How do you integrate $\int_{0}^\infty \frac{\log(x)^2}{(1-x^2)^2}$ using contour integration? I have tried using the standard keyhole integral, and looking at$\ \log(x)^3 $, but because the poles lie on the real axis, when I expand the integrand $\ \frac{(\log(x) + 2\pi i)^3}{(1-x^2)^2} $ I get integrals which do not converge. Am I approaching this problem wrong? When the poles are first order on the real axis, or the poles do not lie on the axis at all, contour integration seems much simpler.
 A: $$\int_{1}^{+\infty}\frac{\log^2(x)}{(1-x^2)^2}\,dx = \int_{0}^{1}\frac{\log^2(x)}{x^2\left(1-\frac{1}{x^2}\right)^2}\,dx=\int_{0}^{1}\frac{x^2\log^2(x)}{(1-x^2)^2}\,dx $$
so the original integral equals
$$ \int_{0}^{1}\frac{1+x^2}{(1-x^2)^2}\log^2(x)\,dx $$
where
$$ \frac{1+z}{(1-z)^2}=\sum_{n\geq 0}(2n+1)z^n\qquad \text{and}\qquad \int_{0}^{1}x^{2n}\log^2(x)\,dx =\frac{2}{(2n+1)^3}$$
lead to
$$ \int_{0}^{+\infty}\frac{\log^2(x)\,dx}{(1-x^2)^2} = 2 \sum_{n\geq 0}\frac{1}{(2n+1)^2}=2\left[\zeta(2)-\frac{1}{4}\zeta(2)\right]=\frac{3}{2}\zeta(2)=\color{red}{\frac{\pi^2}{4}}. $$
For the evaluation of $\zeta(2)$ through contour integration, you may refer to this post.
A: Using the principal branch of the logarithm, let's integrate the function $$f(z) = \frac{\log^{2}(z)}{(1-z^{2})^{2}} $$ around an infinitely large wedge-shaped contour that makes an angle of $\frac{\pi}{2}$ with the positive real axis and is indented at the origin.
(The same contour was used here to evaluate $\int_{0}^{\infty} \frac{\log (x)}{x^{2}-1} \, \mathrm dx$.)
Integrating around the contour, we get $$\int_{0}^{\infty} \frac{\log^{2}(x)}{(1-x^{2})^{2}} \, \mathrm dx + \int_{\infty}^{0} \frac{\left(\log(x) + \frac{i \pi}{2} \right)^{2}}{(1-(it)^{2})^{2}} \, i \,  \mathrm dt =0. $$
Then equating the real parts on both sides of the equation, we get $$\int_{0}^{\infty} \frac{\log^{2}(x)}{(1-x^{2})^{2}} \, \mathrm dx = - \pi \int_{0}^{\infty}\frac{\log (t)}{(1+t^{2})^{2}} \, \mathrm d t. $$
See the answers to this question for ways to show that $$\int_{0}^{\infty} \frac{\log (t)}{(1+t^{2})^{2}} \, \mathrm dt = - \frac{\pi}{4}. $$
