TITLE: Solve this integral:$\int_0^\infty\frac{\arctan x}{x(x^2+1)}\mathrm dx$
QUESTION [7 upvotes]: I occasionally found that $\displaystyle\int_0^{\Large\frac{\pi}{2}}\dfrac{x}{\tan x}=\dfrac{\pi}{2}\ln 2$.
I tried that 
$$\int_0^{\Large\frac{\pi}{2}}\dfrac{x}{\tan x}=\int_0^{\Large\frac{\pi}{2}}x   \ \mathrm d(\ln \sin x)=-\int_0^{\Large\frac{\pi}{2}}\ln (\sin x)=\dfrac{\pi}{2}\ln 2$$
Then I tried another method 
$$\int_0^{\Large\frac{\pi}{2}}\dfrac{x}{\tan x}=\int_0^\infty\dfrac{\arctan x}{x(x^2+1)}\mathrm dx$$
I tried to expand $\arctan x$ and $\dfrac{1}{1+x^2}$, but got nothing, also I was confused that whether $\displaystyle\int_0^\infty$ and $\displaystyle\sum_{i=0}^\infty$ can exchange or not? If yes, on what condition?
Sincerely thanks your help!

REPLY [3 votes]: $\begin{align} J&=\int_0^\infty\frac{\arctan x}{x(x^2+1)}\mathrm dx\tag1\\
&=\int_0^1\frac{\arctan x}{x(x^2+1)}\mathrm dx+\int_1^\infty\frac{\arctan x}{x(x^2+1)}\mathrm dx
\end{align}$
In the latter integral perform the change of variable $y=\dfrac{1}{x}$,
$\begin{align} J&=\int_0^1\frac{\arctan x}{x(x^2+1)}\mathrm dx+\int_0^1\frac{x\arctan\left(\dfrac{1}{x}\right)}{x^2+1}\mathrm dx\\
&=\left(\int_0^1\frac{\arctan x}{x}\mathrm dx-\int_0^1\frac{x\arctan x}{1+x^2}\mathrm dx\right)+\dfrac{\pi}{2}\int_0^1 \dfrac{x}{x^2+1}dx-\int_0^1\frac{x\arctan x}{x^2+1}\mathrm dx\\
&=\left(\int_0^1\frac{\arctan x}{x}\mathrm dx-2\int_0^1\frac{x\arctan x}{1+x^2}\mathrm dx\right)+\dfrac{\pi}{4}\ln 2
\end{align}$
In $(1)$ perform the change of variable $x=\dfrac{2y}{1-y^2}$,
$\begin{align}
J&=\int_0^1 \dfrac{(1-y^2)\arctan\left(\dfrac{2y}{1-y^2}\right)}{y(1+y^2}dy\\
&=2\int_0^1 \dfrac{(1-y^2)\arctan y}{y(1+y^2}dy\\
&=2\left(\int_0^1\frac{\arctan x}{x}\mathrm dx-2\int_0^1\frac{x\arctan x}{1+x^2}\mathrm dx\right)
\end{align}$
Therefore,
$\displaystyle \int_0^1\frac{\arctan x}{x}\mathrm dx-2\int_0^1\frac{x\arctan x}{1+x^2}\mathrm dx=\dfrac{J}{2}$
Therefore,
$\displaystyle J=\dfrac{J}{2}+\dfrac{\pi}{4}\ln 2$
Finally,
$\boxed{J=\displaystyle \dfrac{\pi}{2}\ln 2}$