# Error in $\int\limits_0^{\infty}dx\,\frac {\log^2 x}{a^2+x^2}$

This is my work for solving the improper integral$$I=\int\limits_0^{\infty}dx\,\frac {\log^2x}{x^2+a^2}$$I feel like I did everything write, but when I substitute values into $a$, it doesn’t match up with Wolfram Alpha.

First substitute $x=\frac {a^2}u$ so\begin{align*}I & =-\int\limits_{\infty}^0du\,\frac {2\log^2a-\log^2 u}{x^2+a^2}\\ & =\int\limits_0^{\infty}du\,\frac {2\log^2a}{a^2+x^2}-\int\limits_0^{\infty}du\,\frac {\log^2 u}{a^2+x^2}\end{align*}Hence\begin{align*}I & =\int\limits_0^{\infty}du\,\frac {\log^2a}{a^2+x^2}\\ & =\frac {\log^2a}{a^2}\int\limits_0^{\pi/2}dt\,\frac {a\sec^2t}{1+\tan^2t}\\ & =\frac {\pi\log^2a}{2a}\end{align*}However, when $a=e$ Wolfram Alpha evaluates the integral numerically as$$I\approx 2.00369$$however the input that I arrived at evaluates numerically$$\frac {\pi}{2e}\approx0.5778$$Where did I go wrong? And how would you go about solving this integral?

• First of all the way you write the integrals is not proper. – Kal S. Nov 29 '17 at 18:28
• @Test123 this is common practice in physics. The idea is that the integration variable is declared before the integrand. This way you think of $\int dx$ as an operator on a function. – Joel Dec 18 '17 at 16:20

Note $$\log^2\left(\frac{a^2}{u}\right)\neq2\log^2a-\log^2u.$$

$I =-\int_{\infty}^0du\,\frac {2\log^2a-\log^2 u}{x^2+a^2}$

You are mixing $x's$ and $u's$

$I =\int_0^{\infty}\frac {\ln^2 x}{x^2+a^2}\ dx\\ x = \frac {a^2}{u}, dx = -\frac {a^2}{u^2} du\\ \int_{\infty}^0\frac {(\ln \frac {a^2}{u})^2}{\frac {a^4}{u^2}+a^2} (-\frac {a^2}{u^2})\ du\\ \int_0^{\infty}\frac {(2\ln a - \ln u)^2}{a^2+u^2} \ du$

Which is not

$\int_0^{\infty}\frac {2\ln^2 a - \ln^2 u}{a^2+u^2} \ du$

• Isn't it $x^2$ so $\left(\frac {a^2}u\right)^2$ instead of $\frac {a^2}{u^2}$? Also how would you go about integrating this then? – Crescendo Nov 29 '17 at 18:57
• Thanks, my mistake there. There is still the problem that $\ln^2 \frac {a^2}{u} \ne \ln^2 a^2 - \ln^2 u$ – Doug M Nov 29 '17 at 19:02
• Yes I realize that now. But is there some other technique that you can use to integrate it? – Crescendo Nov 29 '17 at 19:02

Here is one way to evaluate your integral (there are no doubt other ways).

Let $$I = \int^\infty_0 \frac{\ln^2 x}{a^2 + x^2} \, dx, \quad a > 0.$$ Setting $x = \dfrac{a}{u}$ then $dx = -\dfrac{a}{u^2} \, du$ and we have \begin{align*} I &= a \int^\infty_0 \frac{\ln^2 \left (\frac{a}{u} \right )}{\frac{a^2}{u^2} + a^2} \cdot \frac{du}{u^2}\\ &= \frac{1}{a} \int^\infty_0 \frac{\ln^2 \left (\frac{a}{u} \right )}{1 + u^2} \, du\\ &= \frac{1}{a} \int^\infty_0 \frac{\left [\ln a - \ln u \right ]^2}{1 + u^2} \, du\\ &= \frac{\ln^2 a}{a} \int^\infty_0 \frac{du}{1 + u^2} - \frac{2 \ln a}{a} \int^\infty_0 \frac{\ln u}{1 + u^2} \, du + \frac{1}{a} \int^\infty_0 \frac{\ln^2 u}{1 + u^2} \, du\\ &= \frac{\ln^2 a}{a} I_1 - \frac{2 \ln a}{a} I_2 + \frac{1}{a} I_3. \end{align*}

Now evaluating each of these integrals. The first is trival. We have $$I_1 = \int^\infty_0 \frac{du}{1 + u^2} = \left [\tan^{-1} u \right]^\infty_0 = \frac{\pi}{2}.$$

For the second, setting $u = \dfrac{1}{y}, du = -\dfrac{1}{y^2} \, dy$. Thus $$I_2 = \int^\infty_0 \frac{\ln u}{1 + u^2} \, du = \int^\infty_0 \frac{\ln \left (\frac{1}{y} \right )}{1 + \frac{1}{y^2}} \cdot \frac{dy}{y^2} = - \int^\infty_0 \frac{\ln y}{1 + y^2},$$ or $I_2 = 0$.

For the third integral we begin by dividing the interval of integration as follows $$I_3 = \int^\infty_0 \frac{\ln^2 u}{1 + u^2} \, du = \int^1_0 \frac{\ln^2 u}{1 + u^2} \, du + \int^\infty_1 \frac{\ln^2 u}{1 + u^2} \, du.$$ If in the rightmost integral we set $u = \dfrac{1}{y}, du = -\dfrac{1}{y^2} \, dy$, then \begin{align*} I_3 &= \int^1_0 \frac{\ln^2 u}{1 + u^2} \, du + \int^1_0 \frac{\ln^2 \left (\frac{1}{y} \right )}{1 + \frac{1}{y^2}} \cdot \frac{dy}{y^2}\\ &= \int^1_0 \frac{\ln^2 u}{1 + u^2} \, du + \int^1_0 \frac{\ln^2 y}{1 + y^2} \, dy\\ &= 2 \int^1_0 \frac{\ln^2 u}{1 + u^2} \, du. \end{align*}

Noting the term $1/(1 + u^2)$ can be written as the sum of a geometric series, namely $$\frac{1}{1 + u^2} = \sum^\infty_{n = 0} (-1)^n u^{2n}, \quad |u| < 1$$ replacing the term in the integral with this sum, after interchanging the integral sign with the summation we have $$I_3 = 2 \sum^\infty_{n = 0} (-1)^n \int^1_0 u^{2n} \ln^2 u \, du.$$ After performing integration by parts twice, we are left with $$I_3 = 4 \sum^\infty_{n = 0} \frac{(-1)^n}{(2n + 1)^3}.$$

From the definition for the Dirichlet beta function $\beta (s)$, namely $$\beta (s) = \sum^\infty_{n = 0} \frac{(-1)^n}{(2n + 1)^s},$$ we recognise our sum as corresponding to $\beta (3)$. Thus $$I_3 = 4 \beta (3).$$ The value for $\beta (3)$ can be readily found (see here for example). It is $$\beta (3) = \frac{\pi^3}{32},$$ giving $$I_3 = 4 \cdot \frac{\pi^3}{32} = \frac{\pi^3}{8}.$$

So we finally have $$I = \frac{\ln^2 a}{a} \cdot \frac{\pi}{2} + \frac{1}{a} \cdot \frac{\pi^3}{8},$$ or $$\int^\infty_0 \frac{\ln^2 x}{a^2 + x^2} \, dx = \frac{\pi}{2a} \left (\ln^2 a + \frac{\pi^2}{4} \right ).$$

It appears that you wrote $$\log\left(\frac{a^2}u\right)^2=2\log(a)^2-\log(u)^2$$ when it should be $$4\log(a)^2-4\log(a)\log(u)+\log(u)^2$$

Using the Dirichlet beta function as evaluated in this answer \begin{align} &\int_0^\infty\frac{\log(x)^2}{a^2+x^2}\,\mathrm{d}x\tag1\\ &=\frac1a\int_0^\infty\frac{\log(x)^2+2\log(a)\log(x)+\log(a)^2}{1+x^2}\,\mathrm{d}x\tag2\\ &=\frac1a\int_{-\infty}^\infty\frac{x^2+2\log(a)x+\log(a)^2}{2\cosh(x)}\,\mathrm{d}x\tag3\\ &=\frac1a\int_0^\infty\frac{x^2+\log(a)^2}{\cosh(x)}\,\mathrm{d}x\tag4\\ &=\frac2a\int_0^\infty\left(x^2+\log(a)^2\right)\sum_{k=0}^\infty (-1)^ke^{-(2k+1)x}\,\mathrm{d}x\tag5\\ &=\frac2a\sum_{k=0}^\infty\int_0^\infty\frac{(-1)^k}{(2k+1)^3} x^2e^{-x}\,\mathrm{d}x+\frac{2\log(a)^2}a\sum_{k=0}^\infty\int_0^\infty \frac{(-1)^k}{2k+1}e^{-x}\,\mathrm{d}x\tag6\\ &=\frac{2\Gamma(3)}a\beta(3)+\frac{2\Gamma(1)\log(a)^2}a\beta(1)\tag7\\[6pt] &=\frac{\pi^3}{8a}+\frac{\pi\log(a)^2}{2a}\tag8 \end{align} Explanation:
$(2)$: substitute $x\mapsto ax$
$(3)$: substitute $x\mapsto e^x$
$(4)$: remove the integral of the odd function and apply symmetry
$(5)$: write $\frac1{\cosh(x)}$ for $x\gt0$ as a series
$(6)$: split the sum and substitute $x\mapsto\frac{x}{2k+1}$
$(7)$: apply the beta sum and Gamma integral
$(8)$: evaluate the beta and Gamma functions

With substitution $x=a\tan\theta$ (here WLOG $a>0$) $$I=\int_0^\infty\dfrac{\ln^2x}{x^2+a^2}\,\mathrm{dx}=\dfrac{1}{a}\int_0^\frac{\pi}{2}\left(\ln a+\ln\sin\theta-\ln\cos\theta\right)^2\,\mathrm{d\theta}$$ since $\displaystyle\int_0^\frac{\pi}{2}\ln\sin\theta\,\mathrm{d\theta}=\int_0^\frac{\pi}{2}\ln\cos\theta\,\mathrm{d\theta}$ then $$I=\dfrac{\pi}{2a}\ln^2a+\dfrac{1}{a}\int_0^\frac{\pi}{2}\ln^2\tan\theta\,\mathrm{d\theta}=\color{blue}{\dfrac{\pi}{2a}\ln^2a+\dfrac{\pi^3}{8a}}$$ the last obtains from $\displaystyle\int_0^\frac{\pi}{2}\ln^2\tan\theta\,\mathrm{d\theta}=\dfrac{\pi^3}{8}$.

I’m posting this answer because I’ve found a way to evaluate it using contour integration. First, set$$f(z)=\frac {\log^2z}{a^2+z^2}$$And choose a semi circle contour with a small semi circular detour around the origin on the upper half of the complex plane. Let the larger circle have a radius of $R$ and samaller circle have a radius of $r$.

Therefore$$\oint\limits_{C}dz\, f(z)=\int\limits_r^Rdx\, f(x)+\int\limits_{\gamma_R}dz\, f(z)+\int\limits_{-R}^{-r}dx\,\frac {(\log|x|+\pi i)^2}{a^2+x^2}+\int\limits_{\gamma_r}dz\, f(z)$$The residue at $z=ai$ is$$\operatorname{Res}(f,ai)=\frac {\pi\log a}{2a}+\frac {4\log^2a-\pi^2}{8ai}$$So the residue theorem gives$$\oint\limits_Cdz\, f(z)=\frac {4\pi\log^2a-\pi^3}{4a}+\frac {\pi^2 i\log a}a$$Both arc integrals vanish as $R\to\infty$ and $r\to0$ so we are left with$$2\int\limits_0^{\infty}dx\, f(x)-\frac {\pi^3}{2a}=\frac {4\pi\log^2a-\pi^3}{4a}$$Hence$$\int\limits_0^{\infty}dx\,\frac {\log^2x}{a^2+x^2}=\color{blue}{\frac {\pi}{2a}\left(\log^2a+\frac {\pi^2}4\right)}$$