Computing $\int_0^\infty \frac{\ln x}{(x^2+1)^2}dx$ I'm trying to compute
$$I=\int_0^\infty \frac{\ln x}{(x^2+1)^2}dx$$

The following is my effort,
$$I(a)=\int_0^\infty\frac{\ln x}{x^2+a^2}dx$$
Let $x=a^2/y$ so that $dx=-(a^2/y^2)dy$ which leads to
$$I(a)=\int_0^\infty \frac{\ln(a/y)}{a^2+y^2}dy=\int_0^\infty\frac{\ln a}{y^2+a^2}dy-I(a)$$
$$I(a)=\frac{1}{2}\int_0^\infty\frac{\ln a}{y^2+a^2}dy=\frac{1}{2}\frac{\ln a}{a}\arctan\left( \frac{y}{a}\right)_0^\infty=\frac{\ln a}{a}\frac{\pi }{4}$$
Differentiating with respect to $a$ then
$$\frac{dI(a)}{a}=-2aI'(a)=\frac{\pi}{4}\left( \frac{1}{a^2}-\frac{\ln a}{a^2}\right)$$
where $$I'(a)=\int_0^\infty \frac{\ln y}{(y^2+a^2)^2}dx$$
$$I'(a)=\frac{\pi}{-8a}\left( \frac{1}{a^2}-\frac{\ln a}{a^2}\right)$$
$$I'(a=1)=-\frac{\pi}{8}$$
But the correct answer is $-\pi/4$.

Can you help me figure where I mistake? Please give some method if there is which is much better than what I have done?
 A: Contour Integration Approach
Consider the keyhole contour, $\gamma$, that goes from $0$ to $\infty$ just above the positive real axis, circles the complex plane counterclockwise, then returns to $0$ just below the positive real axis.
Now compute the integral
$$\newcommand{\Res}{\operatorname*{Res}}
\begin{align}
\int_\gamma\frac{\log(z)^2}{\left(1+z^2\right)^2}\,\mathrm{d}z
&=\int_0^\infty\frac{\log(x)^2}{\left(1+x^2\right)^2}\,\mathrm{d}x
-\int_0^\infty\frac{(\log(x)+2\pi i)^2}{\left(1+x^2\right)^2}\,\mathrm{d}x\tag1\\
&=-4\pi i\int_0^\infty\frac{\log(x)}{\left(1+x^2\right)^2}\,\mathrm{d}x
+4\pi^2\int_0^\infty\frac1{\left(1+x^2\right)^2}\,\mathrm{d}x\tag2\\
&=2\pi i\left(\color{#C00}{\Res_{z=i}\left(\frac{\log(z)^2}{\left(1+z^2\right)^2}\right)}+\color{#090}{\Res_{z=-i}\left(\frac{\log(z)^2}{\left(1+z^2\right)^2}\right)}\right)\tag3\\
&=2\pi i\left(\color{#C00}{-\frac\pi4+i\frac{\pi^2}{16}}+\color{#090}{\frac{3\pi}4-i\frac{9\pi^2}{16}}\right)\tag4\\[9pt]
&=i\pi^2+\pi^3\tag5
\end{align}
$$
Explanation:
$(1)$: integrate along the contour above and below the positive real axis
$\phantom{\text{(1):}}$ the integral along the huge circle vanishes
$\phantom{\text{(1):}}$ the integral near zero also vanishes
$(2)$: expand $(\log(x)+2\pi i)^2$ and combine
$(3)$: the original integral is $2\pi i$ times the sum of the residues of the integrand
$(4)$: compute the residues
$(5)$: simplify
Thus, we get not only that
$$
\int_0^\infty\frac{\log(x)}{\left(1+x^2\right)^2}\,\mathrm{d}x=-\frac\pi4\tag6
$$
but also that
$$
\int_0^\infty\frac1{\left(1+x^2\right)^2}\,\mathrm{d}x=\frac\pi4\tag7
$$

A Real Approach
This is similar to what is attempted in the question.
$$
\begin{align}
\int_0^\infty\frac{\log(x)}{x^2+a^2}\,\mathrm{d}x
&=\frac1a\int_0^\infty\frac{\log(x)+\log(a)}{x^2+1}\,\mathrm{d}x\tag8\\
&=\frac{\log(a)}a\int_0^\infty\frac1{x^2+1}\,\mathrm{d}x\tag9\\
&=\frac{\pi\log(a)}{2a}\tag{10}
\end{align}
$$
Explanation:
$\phantom{1}\text{(8)}$: substitute $x\mapsto ax$
$\phantom{1}\text{(9)}$: substituting $x\mapsto1/x$ shows that $\int_0^\infty\frac{\log(x)}{x^2+1}\,\mathrm{d}x=0$
$(10)$: evaluate the integral
Taking the derivative of $(10)$ in $a$ and dividing by $-2a$ gives
$$
\int_0^\infty\frac{\log(x)}{\left(x^2+a^2\right)^2}\,\mathrm{d}x=\frac\pi4\frac{\log(a)-1}{a^3}\tag{11}
$$
Plug in $a=1$
A: Integrate by parts
\begin{align}
\int_0^\infty \frac{\ln x}{(x^2+1)^2}dx
&= \int_0^\infty \frac{\ln x}{2x}\>d(\frac{x^2}{x^2+1})\\
&\overset{ibp}= \frac12\int_0^\infty \underset{=\ 0}{\frac{\ln x}{x^2+1}dx }- \frac12\int_0^\infty \frac{1}{x^2+1}dx
= -\frac\pi4
\end{align}
A: Consider the function $\displaystyle f(x) = \frac{1-x^2}{(1+x^2)^2} $. The Maclaurin series of $f$ is given by:
$$\displaystyle \sum_{k \ge 0}  [k(-1)^k x^{2k} - k(-1)^k x^{2k-2}]$$
The integral is equal to $\displaystyle \int_0^1 f(x)\log{x}\,\mathrm{d}x $. Using the series expansion you should get
$$\displaystyle I = \sum_{k \ge 0} \bigg(\frac{k(-1)^k}{(2k-1)^2} + \frac{k(-1)^{k+1}}{(2k+1)^2}\bigg) = \sum_{k \ge 0} \frac{(-1)^{k+1}}{(2k+1)} = -\frac{\pi}{4}.$$
A: Here is an easy way to compute it :
Let's substitute $ \left\lbrace\begin{matrix}y=\frac{1}{x}\ \ \\ \mathrm{d}x=-\frac{\mathrm{d}y}{y^{2}}\end{matrix}\right. $, we get : \begin{aligned}\int_{0}^{+\infty}{\frac{\ln{x}}{\left(x^{2}+1\right)^{2}}\,\mathrm{d}x}&=-\int_{0}^{+\infty}{\frac{y^{2}\ln{y}}{\left(1+y^{2}\right)^{2}}\,\mathrm{d}y}\\ &=\left[\frac{y\ln{y}}{2\left(1+y^{2}\right)}\right]_{0}^{+\infty}-\frac{1}{2}\int_{0}^{+\infty}{\frac{1+\ln{y}}{1+y^{2}}\,\mathrm{d}y}\\ &=-\frac{1}{2}\int_{0}^{+\infty}{\frac{\ln{y}}{1+y^{2}}\,\mathrm{d}y}-\frac{1}{2}\int_{0}^{+\infty}{\frac{\mathrm{d}y}{1+y^{2}}}\\ &=-\frac{1}{2}\left[\arctan{y}\right]_{0}^{+\infty}\\ \int_{0}^{+\infty}{\frac{\ln{x}}{\left(x^{2}+1\right)^{2}}\,\mathrm{d}x}&=-\frac{\pi}{4}\end{aligned}
$\textbf{Note :}$ We first integrated by parts, setting $ u':y\mapsto -\frac{y}{\left(1+y^{2}\right)^{2}} $, and $ v:y\mapsto y\ln{y} $. From the third to the fourth line, we used the fact that $ \int_{0}^{+\infty}{\frac{\ln{y}}{1+y^{2}}\,\mathrm{d}y}=0 $, which can be proven substituting $ y=\frac{1}{x} $.
$\textbf{Bonus :}$ Using the same method, prove that $ \left(\forall x>0 \right) $, we have : $$ \int_{\frac{1}{x}}^{x}{\frac{\ln{y}}{\left(1+y^{2}\right)^{2}}\,\mathrm{d}y}=\frac{1}{2}\left(\frac{\pi}{2}-2\arctan{x}\right)+\frac{x\ln{x}}{1+x^{2}} $$
A: I would like to find a more general integral using trigonometric substitution  $x=a\tan \theta.$
$\displaystyle \begin{aligned} \int_0^{\infty} \frac{\ln x}{\left(a^2+x^2\right)^2} d x &=\frac{1}{a^3} \int_0^{\frac{\pi}{2}} \cos ^2 \theta \ln (a \tan \theta) d \theta\\ &=\frac{\ln a}{a^3}\int _0^\frac{\pi}{2} \cos ^2 \theta d \theta+\frac{1}{a^3} \int^{\frac{\pi}{2}} \cos ^2 \theta \ln (\tan \theta) d \theta\\ &=\frac{\ln a}{2 a^3} \int_0^{\frac{\pi}{2}}\left(1+\cos 2 \theta\right) d \theta+\frac{1}{2a^3} \int_0^{\frac{\pi}{2}}(1+\cos 2 \theta) \ln (\tan \theta) d \theta \\ &=\frac{\pi\ln a}{4 a^3}+\frac{1}{4a^3} \int_0^{\frac{\pi}{2}} \ln (\tan \theta) d(\sin 2 \theta)\quad \left(\textrm{ By }\int_0^{\frac{\pi}{2}} \ln (\tan \theta) d \theta=0 \right)\\&=\frac{\pi \ln a}{4a^3}+\frac{1}{4a^3}[\sin 2 \theta \ln (\tan \theta)]_0^{\frac{\pi}{2}}-\frac{1}{4a^3} \int_0^{\frac{\pi}{2}} \frac{\sin 2 \theta \sec ^2 \theta}{\tan \theta} d \theta \\&=\frac{\pi}{4 a^3}(\ln a-1)\end{aligned} \tag*{} $
A: Noticing that
by which $$I= \left.\frac{\partial}{\partial a} I(a)\right|_{a=0} $$
where$$I(a)= \int_0^{\infty} \frac{x^a}{\left(1+x^2\right)^2} d x =\frac{1}{2} \int_0^1 y^{\frac{1-a}{2}}(1-y)^{\frac{a-1}{2}} d y\\ \quad \qquad =\frac{1}{2} B\left(\frac{3-a}{2},\frac{a+1}{2}\right) =\frac{1}{2} \Gamma\left(\frac{3-a}{2}\right) \Gamma\left(\frac{a+1}{2}\right)   $$
Differentiating both sides w.r.t. to $a$ at $a=0$ yields $$
\begin{aligned}
I=\left.\frac{\partial}{\partial a} I(a)\right|_{a=0} &=\frac{1}{2} I\left(\frac{3}{2}\right) \Gamma\left(\frac{1}{2}\right)\left(-\frac{1}{2} 4\left(\frac{3}{2}\right)+\frac{1}{2} \psi\left(\frac{1}{2}\right)\right) \\
&=-\frac{1}{8} \Gamma^2\left(\frac{1}{2}\right)\left(4\left(\frac{3}{2}\right)-4\left(\frac{1}{2}\right)\right) \\
&=-\frac{\pi}{8} \cdot 2 \\
&=-\frac{\pi}{4}
\end{aligned}
$$
A: $$\begin{align*}
I &= \int_0^\infty \frac{\ln x}{(x^2+1)^2} \, dx \\[1ex]
&= \int_0^1 \frac{\ln x}{(x^2+1)^2} \, dx + \int_1^\infty \frac{\ln x}{(x^2+1)^2} \, dx \\[1ex]
&= \int_0^1 \frac{1-x^2}{(x^2+1)^2} \ln(x) \, dx \tag{1} \\[1ex]
&= 2 \int_0^1 \frac{\ln(x)}{(x^2+1)^2} \, dx - \int_0^1 \frac{\ln(x)}{x^2+1} \, dx \tag{2} \\[1ex]
&= 2 \sum_{n=0}^\infty (-1)^n (n+1) \int_0^1 x^{2n} \ln(x) \, dx - \sum_{n=0}^\infty (-1)^n \int_0^1 x^{2n} \ln(x) \, dx \tag{3} \\[1ex]
&= \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)^2} - 2 \sum_{n=0}^\infty \frac{(-1)^n(n+1)}{(2n+1)^2} \tag{4} \\[1ex]
&= \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)^2} - \sum_{n=0}^\infty (-1)^n \left(\frac1{2n+1} + \frac1{(2n+1)^2}\right) \tag{5} \\[1ex]
&= - \sum_{n=0}^\infty \frac{(-1)^n}{2n+1} \\[1ex]
&= -\arctan(1) = \boxed{-\frac\pi4} \tag{6}
\end{align*}$$


*

*$(1)$ : substitute $x\mapsto\frac 1x$ in the latter integral

*$(2)$ : polynomial division

*$(3)$ : exploit the Maclaurin series of $\frac1{1-x}$

*$(4)$ : integrate by parts

*$(5)$ : partial fractions

*$(6)$ : recognize the Maclaurin series of $\arctan(x)$ evaluated at $x=1$
A: Using the result $\int_0^{\infty} \frac{\ln x}{x^2+1} d x=0$, we have
$$
\begin{aligned}
\int_0^{\infty} \frac{\ln x}{x^2+a^2} d x &=\frac{1}{a} \int_0^{\infty} \frac{\ln a+\ln y}{y^2+1} d y \\
&=\frac{\ln a}{a} \int_0^{\infty} \frac{d y}{y^2+1}+\frac{1}{a} \int_0^{\infty} \frac{\ln y}{y^2+1} d y \\
&=\frac{\pi \ln a}{2 a}
\end{aligned}
$$
Differentiating both sides w.r.t. $a$ yields a general integral
$$
\boxed{\int_0^{\infty} \frac{\ln x}{\left(x^2+a^2\right)^2}=\frac{\pi}{4 a^3}(\ln a-1)}
$$
Putting $a=1$ gives our integral $$
\int_0^{\infty} \frac{\ln x}{\left(x^2+1\right)^2} d x=-\frac{\pi}{4}
$$
