# How to evaluate $\int_{-\infty}^{\infty}\frac{x\arctan\frac1x\ \log(1+x^2)}{1+x^2}dx$

While browsing similar questions on this site I came up with the following integral because I thought I could evaluate it. $$I=\int_{-\infty}^{\infty}\frac{x\arctan x\ \log(1+x^2)}{1+x^2}dx$$ I've been able to simplify it a bit. We first notice that $$I=\int_0^{\infty}\frac{\arctan x\ \log(1+x^2)}{1+x^2}2xdx$$ The substitution $$u=x^2+1$$ gives $$I=\int_1^{\infty}\arctan\sqrt{u-1}\ \log u\ \frac{du}u$$ Then $$w=\log u$$ gives $$I=\int_{0}^{\infty}\arctan\sqrt{e^w-1}\ dw$$ Which I do not know how to proceed with.

Another approach I tried was this. Starting with the original integral,

$$x=\tan u$$: $$I=2\int_0^{\pi/2}u\tan u\log\sec^2u\ du$$ Which I also do not know how to do. Please help me proceed or give me a value of the integral (and show how you got it).

If no closed form exists (AKA you have an answer in terms of a series or special function), I'm fine with that.

cheers!

Edit: In the comments it is discussed that the integral is not integrable over the positive reals, but the following related integral is:

$$J=\int_0^{\infty}\frac{\log(1+x^2)\arctan\frac1x}{1+x^2}xdx$$ So. How do we find the value for $$J$$?

• No, wait, as $x\to +\infty$ the integrand function behaves like $\frac{\pi x \log(x)}{1+x^2}$, which is not integrable on $\mathbb{R}^+$. The strategy in my deleted answer (integration by parts and second derivative of a Beta function) works if $\arctan(x)$ is replaced by $\arctan(1/x)$. Nov 4, 2018 at 3:52
• It leads to $$\int_{\mathbb{R}}\frac{x\arctan(1/x)\log(1+x^2)}{1+x^2}\,dx = \frac{\pi^3}{12}+\pi\log^2(2).$$ Nov 4, 2018 at 3:54
• @JackD'Aurizio so the original integral cannot be found? Nov 4, 2018 at 3:56
• The original integral is simply divergent. But I guess you are still in time to update the post and replace $\arctan(x)$ with $\arctan(1/x)$. Nov 4, 2018 at 3:57
• I am sure, no matter what a CAS can say, $\frac{x}{1+x^2}$ is not integrable on $\mathbb{R}^+$. (And you are just pointing out that $f(x)\to 0$ as $x\to +\infty$, which is not a sufficient condition for integrability) Nov 4, 2018 at 4:00

Integration by parts reduces the original problem to the evaluation of $$\int_{0}^{+\infty}\frac{\log^2(1+x^2)}{1+x^2}\,dx$$ which is pretty straightforward: since $$\int_{0}^{+\infty}(1+x^2)^{s-1}\,dx =\frac{\Gamma\left(\frac{1}{2}\right)\Gamma\left(\frac{1}{2}-s\right)}{\Gamma(1-s)}$$ by applying $$\frac{d^2}{ds^2}$$ to both sides, then considering $$\lim_{s\to 0^+}$$, we get: $$\int_{0}^{+\infty}\frac{\log^2(1+x^2)}{1+x^2}\,dx =\frac{\pi^3}{6}+2\pi\log^2(2).$$ You may find another example of this technique at page 81 of my notes.

• I'm a bit lost on your train of thinking, could you elaborate on your steps? Nov 4, 2018 at 3:49
• Okay I looked on page 81 of your notes and I am still confused. In your proof of $$K=\int_0^{\pi/2}\log^3(\sin x)dx=-\frac{\pi}{8}(\pi^2\log2+4\log^3 2+6\zeta(2))$$ You say that differentiation under the integral sign gives $$K=.5\Gamma(.5)D^3\frac{\Gamma(\frac{\alpha+1}2)}{\Gamma(1+\frac\alpha2)}\bigg|_{\alpha=0}$$ Where in the integral did you put $\alpha$? Nov 4, 2018 at 19:02
• @clathratus: $$\log(\sin x) = \left.\frac{d}{d\alpha}(\sin x)^{\alpha}\right|_{\alpha=0}$$ Nov 4, 2018 at 19:03
• Oh. wow I feel like an idiot. Thanks! Nov 4, 2018 at 19:04

\begin{align*} I(a,b)&=\int_{0}^{+\infty}\frac{x\ln\left(1+b^{2}x^{2}\right)\arctan\left(bx\right)}{a^{4}+x^{4}}\,\mathrm{d}x\\ &=\Im\left[\int_{0}^{+\infty}\frac{z\ln^2(1+ibx)}{a^{4}+x^{4}}\,\mathrm{d}x\right] \end{align*}

Now the residue theorem give

$$\color{red}{\frac{\pi}{2a^{2}}\ln\left(1+\sqrt{2}ab+a^{2}b^{2}\right)\arctan\left(\frac{ab}{\sqrt{2}+ab}\right)\,}$$

How about below integral?

$$\int_{0}^{+\infty}\frac{x\ln\left(1+b^{2}x^{2}\right)\arctan\left(cx\right)}{a^{4}+x^{4}}\,\mathrm{d}x$$

Let $$g(x)$$ be $$2x\ln(1 + x^{2})$$

Let $$f(x)$$ be $$\arctan(x)$$

$$2I = \int g(x)f(x)f'(x)dx$$

Note that:

• $$f'(x) = \frac{1}{1+x^{2}}$$
• Let $$u = f(x)$$. Then, $$F(x) = \int f(x)f'(x)dx = \int u du = \frac{1}{2}f(x)^{2}$$
• Let $$v = 1 + x^{2}$$. Then, $$G(x) = \int \ln(v)dv = v[\ln(v) - 1] = (1 + x^{2})[\ln(1 + x^{2}) - 1]$$

$$\color{red}{2I = f(x)G(x) - \int f'(x)G(x)dx}$$

$$= f(x)G(x) - \int (1 + x^{2})[\ln(1 + x^{2}) - 1] \frac{1}{1+x^{2}} dx$$

$$= f(x)G(x) - \int \ln(1+x^{2}) - 1 dx$$

$$= f(x)G(x) + x - \int \ln(1+x^{2}) dx$$

Let $$a(x) = x$$ and $$b(x) = \ln(1+x^{2})$$

$$\int 1 \cdot \ln(1+x^{2}) dx$$ $$= \int b(x) a'(x) dx = a(x)b(x) - \int a(x)b'(x) dx$$ $$\int a(x)b'(x) dx = \int x \frac{2x}{1 + x^{2}} dx$$ $$= 2\int \frac{x^{2}}{1 + x^{2}} dx$$ $$= 2(x - \arctan(x))$$

• Wonderful!!! Thank you so much! Nov 4, 2018 at 17:09
• This is indefinite integral. I think what Jack say about your original problem is correct.
– R zu
Nov 4, 2018 at 17:11
• Would you prefer it if I accepted his answer? Nov 4, 2018 at 18:49
• Either way is fine. I up-voted his answer because it looks like a useful technique for me.
– R zu
Nov 4, 2018 at 18:51
• @Rzu, you wrote that $$2I = f(x)G(x) - \int f'(x)G(x)dx\;\;,$$ but you should have written that $$2I = f(x)f’(x)G(x) - \int \big(f(x)f'(x)\big)’G(x)dx\;\;,$$ so you did not calculate the integral correctly. Jan 2, 2023 at 12:40

Continuing from Jack D'A.'s post-IBP integral:

\begin{align*} J &= \int_0^\infty \frac{\log^2(1+x^2)}{1+x^2} \, dx \\[1ex] &= \int_0^1 \frac{\log^2(1+x^2) + \log^2\left(1+\frac1{x^2}\right)}{1+x^2} \, dx \tag{1} \\[1ex] &= \frac12 \int_0^1 \left(\log^2\left(\frac2{1+\sqrt{1-x^2}}\right) + \log^2\left(\frac2{1-\sqrt{1-x^2}}\right)\right) \, \frac{dx}{\sqrt{1-x^2}} \tag{2} \\[1ex] &= \log^2(2) \int_0^1 \frac{dx}{\sqrt{1-x^2}} - \log(2) \int_0^1 \frac{\log(1-x^2)}{\sqrt{1-x^2}}\,dx \\ &\qquad + \frac12 \int_0^1 \frac{\log^2(1+x) + \log^2(1-x)}{\sqrt{1-x^2}} \, dx \tag{3} \\[1ex] &= \log^2(2) \int_0^1 \frac{dx}{\sqrt{1-x^2}} - \log(2) \int_0^1 \frac{\log(1-x^2)}{\sqrt{1-x^2}}\,dx \\ &\qquad + \frac12 \int_0^1 \frac{\log^2(1-x^2)}{\sqrt{1-x^2}} \, dx - \int_0^1 \frac{\log(1+x)\log(1-x)}{\sqrt{1-x^2}} \, dx \tag{4} \\[1ex] &= \log^2(2) \int_0^{\frac\pi2} dx - 2\log(2) \int_0^{\frac\pi2} \log(\cos(x)) \, dx \\ &\qquad + 2 \int_0^{\frac\pi2} \log^2(\cos(x)) \, dx - \underbrace{\int_0^{\frac\pi2} \log(1+\sin(x)) \log(1-\sin(x)) \, dx}_{K} \tag{5} \\[1ex] &= \boxed{2\pi\log^2(2) + \frac{\pi^3}6} \tag{6a,b,c,d} \end{align*}

##### Steps
• $$(1)$$ : fold up the integral at $$x=1$$, i.e. substitute $$x\mapsto\dfrac1x$$ over $$[1,\infty)$$
• $$(2)$$ : substitute $$x\mapsto\dfrac{2x}{x^2+1}$$
• $$(3)$$ : substitute $$x\mapsto\sqrt{1-x^2}$$
• $$(4)$$ : rewrite the logarithm
• $$(5)$$ : substitute $$x\mapsto\sin^{-1}(x)$$
• $$(6\rm a)$$ : the first integral is trivial
• $$(6\rm b)$$ : see here for the second integral
• $$(6\rm c)$$ : see here for the third integral
• $$(6\rm d)$$ : substitute $$x\mapsto\dfrac\pi2-x$$ and follow J.D'A.'s comment here to evaluate $$K$$ by expanding into Fourier series:

\begin{align*} K &= \int_0^{\frac\pi2} \log(1+\cos(x)) \log(1-\cos(x)) \, dx \\[1ex] &= \int_0^{\frac\pi2} \left(\log(2) + \sum_{k=1}^\infty \frac{2\cos(kx)}k\right) \left(\log(2) + \sum_{k=1}^\infty \frac{2(-1)^k\cos(kx)}k\right) \, dx \\[1ex] &= \int_0^{\frac\pi2} \left[\log^2(2) + \log(2) \sum_{k=1}^\infty \frac{2\left(1+(-1)^k\right) \cos(kx)}k \right. \\ & \qquad \qquad \left. {} + 4 \left(\sum_{k=1}^\infty \frac{\cos(kx)}k\right) \left(\sum_{k=1}^\infty \frac{(-1)^k\cos(kx)}k\right)\right] \, dx \\[1ex] &= \frac\pi2 \log^2(2) + \log(2) \sum_{k=1}^\infty \frac2k \underbrace{\int_0^{\frac\pi2} \cos(2kx) \, dx}_{=0} \\ &\qquad {} + 4 \left[\sum_{k=1}^\infty \frac{(-1)^k}{k^2} \underbrace{\int_0^{\frac\pi2} \cos^2(kx) \, dx}_{=\pi/4} + 2 \sum_{k=2}^\infty \sum_{\ell=1}^{k-1} \frac{(-1)^k}{k\ell} \int_0^{\frac\pi2} \cos(kx) \cos(\ell x) \, dx\right] \\[1ex] &= \frac\pi2 \log^2(2) + \pi \sum_{k=1}^\infty \frac{(-1)^k}{k^2} \\ &\qquad {} + 4 \sum_{k=2}^\infty \sum_{\ell=1}^{k-1} \frac{(-1)^k}{k\ell} \underbrace{\int_0^{\frac\pi2} \bigg(\cos((k-\ell)x) + \cos((k+\ell)x)\bigg) \, dx}_{=0} \\[1ex] &= \frac\pi2 \log^2(2) - \frac{\pi^3}{12} \end{align*}

We may also try attacking the third integral in line $$(3)$$ in my first answer,

$$L = \int_0^1 \frac{\log^2(1+x)+\log^2(1-x)}{\sqrt{1-x^2}} \, dx$$

by exploiting the generating function of $$\dfrac{H_{2k-1}}k$$, with $$H_k$$ the $$k^{\rm th}$$ harmonic number. Using the Cauchy product, we find

$$-\log(1\pm x) = \sum_{n=1}^\infty \frac{(\pm x)^n}n \\ \implies \log^2(1\pm x) = \sum_{n=2}^\infty \sum_{m=1}^{n-1} \frac{x^n}{m(n-m)} = \sum_{n=2}^\infty \frac{2 H_{n-1}}n (\pm x)^n \\ \implies \log^2(1+x) + \log^2(1-x) = \sum_{n=2}^\infty \frac{2H_{n-1}}{n} \left(1+(-1)^n\right) (\pm x)^n = \sum_{n=1}^\infty \frac{H_{2n-1}}{n} x^{2n}$$

Multiply by $$\frac1{\sqrt{1-x^2}}$$ and integrate to recover an Euler sum:

\begin{align*} L &= \sum_{n=1}^\infty \frac{H_{2n-1}}{n} \int_0^1 \frac{x^{2n}}{\sqrt{1-x^2}} \, dx \\[1ex] &= \frac12 \sum_{n=1}^\infty \frac{H_{2n-1}}{n} \int_0^1 x^{n-\frac12} (1-x)^{-\frac12} \, dx \\[1ex] &= \frac12 \sum_{n=1}^\infty \frac{H_{2n-1}}{n} \operatorname{B}\left(n+\frac12,\frac12\right) \\[1ex] &= \frac12 \sum_{n=1}^\infty \frac{H_{2n-1}}{n\cdot4^n} \binom{2n}n \end{align*}

where in the second line, we substitute $$x\mapsto\sqrt x$$. Now we can use

$$\sum_{n=1}^\infty \frac{H_n}{n\cdot4^n} \binom{2n}n = \frac{\pi^2}3$$

(see the proof following equation $$(20)$$) together with

$$H_{2n-1} = \frac12 \left(H_n + H_{n-\frac12}\right) + \log(2)$$

to determine $$\displaystyle L=\frac{\pi^3}3+\pi\log^2(2)$$.

Integration by parts yields \begin{aligned} I & =\int_{-\infty}^{\infty} \frac{x \arctan \frac{1}{x} \ln \left(1+x^2\right)}{1+x^2} d x \\ & =2 \int_0^{\infty} \frac{x \arctan \frac{1}{2} \ln \left(1+x^2\right)}{1+x^2} d x \\ & =\frac{1}{2} \int_0^{\infty} \arctan \frac{1}{x} d\left(\ln ^2\left(1+x^2\right)\right) \\ & =\frac{1}{2} \int_0^{\infty} \ln ^2\left(1+x^2\right) \frac{1}{1+\frac{1}{x^2}} \cdot \frac{d x}{x^2} \\ & =\frac{1}{2} \int_0^{\infty} \frac{\ln ^2\left(1+x^2\right)}{1+x^2} d x\end{aligned} Letting $$x\mapsto \tan \theta$$ transforms the integral into a Beta function. \begin{aligned} I & =2 \int_0^{\frac{\pi}{2}} \ln ^2(\cos \theta) d \theta \\ & =\left.2 \frac{d^2}{d a^2} \int_0^{\frac{\pi}{2}} \cos ^a \theta d \theta\right|_{a=0} \\ & =\left.\frac{d^2}{d a^2} B\left(\frac{1}{2}, \frac{a+1}{2}\right)\right|_{a=0} \\ & =\boxed{\frac{\pi^3}{12}+\pi \ln ^2 2} \end{aligned}