# Integrate $\left[\arctan\left(x\right)/x\right]^{2}$ between $-\infty$ and $+\infty$

I have tried to calculate $$\int_{-\infty}^{\infty}\left[\arctan\left(x\right) \over x\right]^{2}\,{\rm d}x$$ with integration by parts and that didn't work.

I looked up the indefinite integral and found it contained a polylogarithm which I don't know how to use so I tried contour integration but got stuck.

$${\tt\mbox{Wolfram Alpha said the answer is}}\,\,\,{\large \pi\log\left(4\right)}$$

Can anyone show me how to do this integral ?.

\begin{align} \int_{-\infty}^\infty\left(\frac{\arctan(x)}{x}\right)^2\mathrm{d}x &=2\int_0^\infty\left(\frac{\arctan(x)}{x}\right)^2\mathrm{d}x\tag{1}\\ &=2\int_0^\infty\left(\frac\pi2-\arctan(u)\right)^2\mathrm{d}u\tag{2}\\ &=2\int_0^{\pi/2}\left(\frac\pi2-v\right)^2\,\mathrm{d}\tan(v)\tag{3}\\ &=4\int_0^{\pi/2}\tan(v)\left(\frac\pi2-v\right)\,\mathrm{d}v\tag{4}\\ &=4\int_0^{\pi/2}w\cot(w)\,\mathrm{d}w\tag{5}\\ &=4\int_0^{\pi/2}w\,\mathrm{d}\log(\sin(w))\tag{6}\\ &=-4\int_0^{\pi/2}\log(\sin(w))\,\mathrm{d}w\tag{7} \end{align} Explanation:
$(1)$: integrand is even, halve the domain and double
$(2)$: substitute $x=1/u$
$(3)$: substitute $u=\tan(v)$
$(4)$: integrate by parts
$(5)$: substitute $v=\pi/2-w$
$(6)$: $\mathrm{d}\log(\sin(w))=\cot(w)\,\mathrm{d}w$
$(7)$: integrate by parts

Steven Stadnicki suggests that we should mention
$\ \$In the explanation of $(4)$, note that $\lim\limits_{v\to\pi/2}\left(\frac\pi2-v\right)^2\tan(v)=0$
$\ \$In the explanation of $(7)$, note that $\lim\limits_{w\to0}w\log(\sin(w))=0$

Note that \begin{align} &\int_0^{\pi/2}\log(\sin(w))\,\mathrm{d}w\\ &=\int_0^{\pi/2}\log(2\sin(w/2)\cos(w/2))\,\mathrm{d}w\\ &=\frac\pi2\log(2)+\int_0^{\pi/2}\log(\sin(w/2))\,\mathrm{d}w+\int_0^{\pi/2}\log(\cos(w/2))\,\mathrm{d}w\\ &=\frac\pi2\log(2)+2\int_0^{\pi/4}\log(\sin(w))\,\mathrm{d}w+2\int_0^{\pi/4}\log(\cos(w))\,\mathrm{d}w\\ &=\frac\pi2\log(2)+2\int_0^{\pi/4}\log(\sin(w))\,\mathrm{d}w+2\int_{\pi/4}^{\pi/2}\log(\sin(w))\,\mathrm{d}w\\ &=\frac\pi2\log(2)+2\int_0^{\pi/2}\log(\sin(w))\,\mathrm{d}w\tag{8} \end{align} Therefore, $$\int_0^{\pi/2}\log(\sin(w))\,\mathrm{d}w=-\frac\pi2\log(2)\tag{9}$$ Combining $(7)$ and $(9)$ yields $$\int_{-\infty}^\infty\left(\frac{\arctan(x)}{x}\right)^2\mathrm{d}x =2\pi\log(2)\tag{10}$$

• One tiny additional thing I'd add: in going from $(3)$ to $(4)$, you have to do a little bit of massage to get rid of the 'non-integral' term in the integration by parts (i.e., the $(\frac\pi2-v)^2\tan(v)$ term); it's obviously $0$ at $v=0$, but you have to show that the limit as $v\to\frac\pi2$ is 0 (which is easy because $\tan(v)$ goes to infinity as $(\frac\pi2-v)^{-1}$ but maybe deserves an explicit note). – Steven Stadnicki Aug 8 '14 at 20:22
• I considered that simply part of the mechanics of integration by parts, but if we add that for $(4)$, we also need to add a similar comment for $(7)$. – robjohn Aug 8 '14 at 20:52
• Good point; I'd missed that one. I consider it trivial when the result is well-defined at both inputs, but since there's a necessary limit here (you can't simply evaluate the result at the endpoint) I like calling it out explicitly. (And since I didn't note it before, this is really an excellent answer. I virtually never bother answering integration questions here; I'm not nearly as good at analytics in general, and your answers are consistently among the highest-quality on this site.) – Steven Stadnicki Aug 8 '14 at 21:15
• I have not seen a cleaner answer on Math.SE. +1. – Ahaan S. Rungta Aug 10 '14 at 1:44

You can use the following way to evaluate. It is pretty neat and simple. Let $$I(a,b)=\int_{-\infty}^\infty\frac{\arctan(ax)\arctan(bx)}{x^2}dx.$$ Clearly $I(0,b)=I(a,0)=0$ and $I(1,1)=I$. Now \begin{eqnarray} \frac{\partial^2I(a,b)}{\partial a\partial b}&=&\int_{-\infty}^\infty\frac{1}{(1+a^2x^2)(1+b^2x^2)}dx\\ &=&\frac{1}{a^2-b^2}\int_{-\infty}^\infty\left(\frac{a^2}{1+a^2x^2}-\frac{b^2}{1+b^2x^2}\right)dx\\ &=&\frac{1}{b^2-a^2}\pi(a-b)\\ &=&\frac{\pi}{a+b}. \end{eqnarray} Hence $$I=\int_0^1\int_0^1\frac{\pi}{a+b}dadb=2\pi\ln2.$$

• Nice! I think there's an algebraic error though? the second line should be $\frac{1}{a^2-b^2}\int_{-\infty}^\infty\left(\frac{a^2}{1+a^2x^2}-\frac{b^2}{1+b^2x^2}\right)$, and the third line adjusted also. – Holographer Aug 8 '14 at 12:39
• @Holographer, you are right. Thanks. – xpaul Aug 8 '14 at 12:56
• +1, very slick trick; convert a single integral to a double integral to make it easier. – robjohn Aug 8 '14 at 18:41
• @robjohn, thanks. – xpaul Aug 10 '14 at 23:49

\begin{align} \int^{\infty}_{-\infty}\frac{(\arctan{x})^2}{x^2}dx &=2\int^{\infty}_{0}\frac{(\arctan{x})^2}{x^2}dx\tag1\\ &=2\int^{\pi/2}_0u^2\csc^2{u} \ du\tag2\\ &=4\int^{\pi/2}_0u\cot{u} \ du\tag3\\ &=-4\int^{\pi/2}_0\ln\sin{u} \ du\tag4\\ &=2\pi\ln{2}\tag5\\ \end{align} Explanation:
$1)$ Integrand is even
$2)$ Use the substitution $x=\tan{u}$
$3), 4)$ Integrate by parts
$5)$ See here

Since you mentioned you tried contour integration, I'll add an approach using contour integration.

Consider $\displaystyle f(z) = \frac{\log^{2}(1-iz)}{z^{2}}$ where the branch cut runs down the imaginary axis from $z=-i$.

And notice that the singularity at the origin is removable.

Now integrate around a contour that consists of the line segment $[-R,R]$ and the upper half of the circle $|z|=R$.

As $R \to \infty$, $\displaystyle \int f(z) \ dz$ vanishes along the upper half of $|z|=R$.

Therefore,

$$\int_{-\infty}^{\infty} \frac{\big( \log|1-ix| - i \arctan (x) \big)^{2}}{x^{2}} \ dx = 0$$

which implies $$\int_{-\infty}^{\infty} \frac{\frac{1}{4} \log^{2}(1+x^{2}) -i \log(1+x^{2}) \arctan (x) - \arctan^{2}(x) }{x^{2}} =0 .$$

And equating the real parts on both sides of the equation we have \begin{align} \int_{-\infty}^{\infty} \frac{\arctan^{2} (x)}{x^{2}} \ dx &= \frac{1}{4} \int_{-\infty}^{\infty} \frac{\log^{2} (1+x^{2})}{x^{2}} \ dx \\ &= \frac{1}{2} \int_{0}^{\infty} \frac{\log^{2}(1+x^{2})}{x^{2}} \ dx \\ &= \frac{1}{4} \int_{0}^{\infty} \frac{\log^{2}(1+u)}{u^{3/2}} \ du \\ &= \frac{1}{4} (8 \pi \log 2)\tag{1} \\ &= 2 \pi \log 2 . \end{align}

EDIT:

As was stated in Gennaro Marco Devincenzis' answer, integrating by parts shows that $$\int_{-\infty}^{\infty} \frac{\arctan^{2}(x)}{x^{2}} \ dx = 2 \int_{-\infty}^{\infty} \frac{\arctan x}{x(1+x^{2})} \ dx.$$

And that integral as well can be evaluated using contour integration, which is probably preferable since it's just a residue calculation.

• (+1) log and arctan are nicely related via complex analysis. – robjohn Aug 8 '14 at 18:54
• Good point about integrating by parts then using contour integration on it. The second contour integral looks much easier. – Maxwell Aug 8 '14 at 23:01

Disclaimer: It's one of the first times I evaluate an integral whose primitive cannot be found in terms of elementary functions. God it's a drug.

Integrating by parts

$$\int_{-\infty}^{+\infty} \frac{\arctan^2 x}{x^2}dx=\bigg[-\frac{\arctan^2 x}{x}\bigg]_{-\infty}^{+\infty}+2\int_{-\infty}^{+\infty}\frac{\arctan x}{(1+x^2)x}dx$$ The first part yields $0$. For the second consider: $$I(t)=\int_{-\infty}^{+\infty}\frac{\arctan tx}{x(1+x^2)}dx$$ Differentiating under the integral sign: $$I'(t)=\int_{-\infty}^{+\infty}\frac{1}{(1+t^2x^2)(1+x^2)}dx=\frac{\pi}{t+1}$$ $$I(t)=\pi\log(t+1)+C$$ So: $$\int_{-\infty}^{+\infty}\frac{\arctan tx}{x(1+x^2)}dx=\pi\log(t+1)+C$$ Letting $t=0$ we recover $C=0$. So, letting t=1: $$\int_{-\infty}^{+\infty}\frac{\arctan x}{x(1+x^2)}dx=\pi\log(2)$$ Since there was a $2$ in the integration by parts we have: $$\int_{-\infty}^{+\infty} \frac{\arctan^2 x}{x^2}dx=2\int_{-\infty}^{+\infty}\frac{\arctan x}{x(1+x^2)}dx=2\pi\log2=\pi\log4$$

• I have always liked the differentiating under the integral sign trick. Sweet. – Asier Calbet Aug 8 '14 at 18:15
• Me too! But it's one of the first times I succeed in using it effectively. :P – Gennaro Marco Devincenzis Aug 8 '14 at 18:17
• There are tons of classical examples online if you want to practice using it. ;) – Asier Calbet Aug 8 '14 at 18:19
• I am pretty annoyed at myself for not using differentiation under the integral sign. The success I have had with contour integration lately made me over look it. This is great. – Maxwell Aug 8 '14 at 22:59


\begin{align}&\color{#66f}{\large\int_{-\infty}^{\infty}% \bracks{\arctan\pars{x} \over x}^{2}\,\dd x} =\int_{x\ \to\ -\infty}^{x\ \to\ \infty} \arctan^{2}\pars{x}\,\dd\pars{-\,{1 \over x}} \\[3mm]&=\int_{-\infty}^{\infty} {1 \over x}\bracks{2\arctan\pars{x}\,{1 \over 1 + x^{2}}}\,\dd x =2\,\Im\ \overbrace{\int_{-\infty}^{\infty}{\ln\pars{1 + x\ic} \over x\pars{1 + x^{2}}} \,\dd x}^{\ds{\mbox{Set}\ 1 + x\ic \equiv t\ \imp\ x = \pars{1 - t}\ic}} \\[3mm]&=2\,\Im\int_{1 - \infty\ic}^{1 + \infty\ic} {\ln\pars{t} \over \pars{1 - t}\ic\pars{2 - t} t}\,\pars{-\ic\,\dd t} =2\,\Im\int_{1 - \infty\ic}^{1 + \infty\ic} {\ln\pars{t} \over t\pars{t - 1}\pars{t - 2}}\,\dd t \\[3mm]&=2\,\Im\bracks{2\pi\ic\,{\ln\pars{2} + \ic 0^{+} \over 2\pars{2 - 1}}} =\color{#66f}{\large 2\pi\ln\pars{2}} \approx {\tt 4.3552} \end{align}

In the above calculation we took the $\ds{\ln}$-branch cut: $$\ln\pars{z} = \ln\pars{\verts{z}} + {\rm Arg}\pars{z}\ic\,,\quad\verts{{\rm Arg}\pars{z}} < \pi\,,\quad z \not= 0$$ The integration path is closed with the arc $\ds{\braces{\pars{x,y}\quad \mid\quad \pars{x - 1}^{2} + y^{2} = R^{2}\,,\quad x \geq 1\,,\quad R > 1}}$ such that the 'arc contribution' vanishes out in the limit $\ds{R \to \infty}$.