# Integral $\int_0^\infty x^2\,e^{-x^2}\operatorname{erf}(x)\,\log(x)\,dx$

I need to evaluate this integral: $$I=\int_0^\infty x^2\,e^{-x^2}\operatorname{erf}(x)\,\log(x)\,dx\tag1$$ I tried to do this in Mathematica and it returned a result of the form $$I=\frac{(\pi+2)\,(1-\gamma)}{16\,\sqrt\pi}+\frac1{2\,\sqrt\pi}\left.\frac{d}{d\xi}\Bigg({_2F_1}\left(\tfrac12,\xi;\tfrac32;-1\right)\Bigg)\right|_{\xi=2}\tag2$$ I tried to find a closed form for the derivative using an integral representation of the hypergeometric function, but this way returned me back to my original integral.

Is it possible to represent $I$ in a closed form that does not contain unevaluated integrals or derivatives?

$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}% \newcommand{\dd}{{\rm d}}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\fermi}{\,{\rm f}}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\half}{{1 \over 2}}% \newcommand{\ic}{{\rm i}}% \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\ol}[1]{\overline{#1}}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$

$\ds{I \equiv \int_{0}^{\infty}x^{2}\expo{-x^{2}}{\rm erf}\pars{x}\ln\pars{x} \,\dd x}$. Let's $\ds{{\cal I}\pars{\mu} \equiv \int_{0}^{\infty}x^{\mu}\expo{-x^{2}}{\rm erf}\pars{x}\,\dd x}$ such that $\ds{I = \lim_{\mu \to 2}\totald{{\cal I}\pars{\mu}}{\mu}}$

Since $\ds{{\rm erf}\pars{x} \stackrel{{\rm def.}}{=}{2 \over \root{\pi}}\int_{0}^{x}\expo{-y^{2}}\,\dd y}$: \begin{align} {\cal I}\pars{\mu}&=\int_{0}^{\infty}x^{\mu}\expo{-x^{2}} {2 \over \root{\pi}}\int_{0}^{\infty}\Theta\pars{x - y}\expo{-y^{2}}\,\dd y\,\dd x \\[3mm]&= {2 \over \root{\pi}}\int_{0}^{\pi/2}\dd\theta\,\cos^{\mu}\pars{\theta} \Theta\pars{\cos\pars{\theta} - \sin\pars{\theta}} \overbrace{\int_{0}^{\infty}\dd r\,r^{\mu + 1}\expo{-r^{2}}} ^{\Gamma\pars{1 + \mu/2}/2} \\[3mm]&={1 \over \root{\pi}}\,\Gamma\pars{1 + {\mu \over 2}} \int_{0}^{\pi/4}\dd\theta\,\cos^{\mu}\pars{\theta} \end{align}

\begin{align} I&=\lim_{\mu \to 2}\totald{{\cal I}\pars{\mu}}{\mu}= {1 \over 2\root{\pi}}\,\overbrace{\Psi\pars{2}}^{\ds{1 - \gamma}}\ \overbrace{\int_{0}^{\pi/4}\dd\theta\,\cos^{2}\pars{\theta}}^{\ds{\pars{\pi + 2}/8}} \\[3mm]&+ {1 \over \root{\pi}}\,\overbrace{\Gamma\pars{2}}^{\ds{1}} \overbrace{% \int_{0}^{\pi/4}\dd\theta\,\cos^{2}\pars{\theta}\ln\pars{\cos\pars{\theta}}} ^{\ds{\braces{4G + \pi - 2\bracks{1 + \ln\pars{2}} - \pi\ln\pars{4}}/16}} \end{align} $\Gamma\pars{z}$ and $\Psi\pars{z}$ are the $\it Gamma$ and $\it Digamma$ functions, respectively. $\gamma$ and $G$ are the $\it Euler-Mascheroni$ and Catalan constants, respectively.
$$\begin{array}{|l|}\hline \mbox{}\\ \quad{\displaystyle\int_{0}^{\infty}x^{2}\expo{-x^{2}} \,\mathrm{erf}\pars{x}\ln\pars{x}\,\dd x}\quad \\[2mm] = \quad{{\displaystyle\quad\pars{\pi + 2}\pars{1 - \gamma} + 4G + \pi - 2\bracks{1 + \ln\pars{2}} - \pi\ln\pars{4}\quad} \over {\displaystyle 16\root{\pi}}}\quad \\ \mbox{}\\ \hline \end{array} \approx 0.0436462$$

• I don't have that much experience with integrals, could you please give a hint on a substitution/contour to find $$\int_0^{\pi/4} \cos^2(\theta)\log(\cos(\theta))\,d\theta?$$ Commented Jan 11, 2014 at 20:09
• @Ian Mateus: For the evaluation of $\int_0^{\pi/4} \cos^2(\theta)\log(\cos(\theta))\,d\theta$, you can refer to this calculation. Commented Jan 16, 2014 at 6:54

Below is almost a copypaste of my answer to equivalent question - which was asked one month earlier than this one.

We start with the standard integral representation of the hypergeometric function: \begin{align} _2F_1\left(\frac12,a,\frac32,-1\right)=\frac12\int_0^1\frac{dt}{\sqrt{t}\left(1+t\right)^{a}}. \end{align} Differentiating it w.r.t. $a$, one finds \begin{align} S:=\left[\frac{d}{da} {}_2F_1\left(\frac12,a,\frac32,-1\right)\right]_{a=2}= -\frac12\int_0^1\frac{\ln\left(1+t\right)dt}{\sqrt{t}\left(1+t\right)^{2}}. \end{align} After the change of variables $t=s^2$ the last integral can be expressed in terms of dilogarithms: \begin{align} S&=-\int_0^1\frac{\ln\left(1+s^2\right)ds}{\left(1+s^2\right)^2}=\\&= \frac{\pi}{8}\left[1-3\ln 2 +\ln\left(2+\sqrt{2}\right)\right]-\frac{1+\ln 2}{4}+\Im\left(\operatorname{Li}_2\left(-e^{i\pi/4}\right)-\operatorname{Li}_2\left(1-e^{i\pi/4}\right)\right)=\\ &=\frac{\pi\left(1-2\ln 2\right)}{8}-\frac{1+\ln 2}{4}+\frac12 \Im\operatorname{Li}_2\left(i\right)=\\ &=\frac{G}{2}+\frac{\pi\left(1-2\ln 2\right)}{8}-\frac{1+\ln 2}{4}. \end{align} where $G$ denotes the Catalan's constant. Note that $S$ is precisely what we need to compute.

Explanation: At the first step, the only nontrivial integrals (producing dilogarithms) are $\displaystyle \int\frac{\ln(1\pm i s)}{1\mp is}ds$. The other integrals are elementary. At the last step we used the formula $\operatorname{Li}_2(i)=iG-\frac{\pi^2}{48}$ from here.

$$I=\frac{2-\ln2}{16}\sqrt\pi-\frac{\gamma+\ln2}{16\,\sqrt\pi}(\pi+2)+\frac{G}{4\,\sqrt\pi},$$ where $\gamma$ is the Euler-Mascheroni constant: $$\gamma=-\int_0^1\ln(-\ln x)\,dx$$ and $G$ is the Catalan constant:

$$G=-\int_0^1\frac{\ln x}{x^2+1}dx$$

Let $$\displaystyle I(a) = \int_{0}^{\infty} e^{-a^{2}x^{2}} \text{erf}(x) \ dx$$

$$\displaystyle I(a) = \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} \int_{0}^{x} e^{-a^{2} x^{2}} e^{-t^{2}} \ dt \ dx = \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} \int_{0}^{1} xe^{-a^{2} x^{2}} e^{-x^{2} u^{2}} \ du \ dx$$

$$\displaystyle = \frac{2}{\sqrt{\pi}} \int_{0}^{1} \int_{0}^{\infty} xe^{-(a^{2}+u^{2})x^{2}} \ dx \ du = \frac{1}{\sqrt{\pi}} \int_{0}^{1} \frac{1}{a^{2}+u^{2}} \ du$$

$$\displaystyle = \frac{1}{a \sqrt{\pi}} \ \arctan \frac{1}{a}$$

Then

$$I'(a) = - 2a \int_{0}^{\infty} x^{2} e^{-a^{2}x^{2}} \text{erf}(x) \ dx = \frac{1}{\sqrt{\pi}} \frac{- \frac{a}{1+a^{2}}- \arctan \frac{1}{a}}{a^{2}}$$

And

$$\int_{0}^{\infty} x^{2} e^{-x^{2}} \text{erf}(x) \ dx = - \frac{1}{2 \sqrt{\pi}} \Big(- \frac{1}{2} - \frac{\pi}{4} \Big) = \frac{1}{4 \sqrt{\pi}} + \frac{\sqrt{\pi}}{8}$$

\begin{align} &\int_{0}^{\infty} x^{a} e^{-x^{2}} \text{erf}(x) \, dx \nonumber \\ &= \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} \int_{0}^{x} x^{a} e^{-x^{2}} e^{-t^{2}} \, dt \, dx \nonumber \\ &= \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} \int_{0}^{1} x^{a+1}e^{-x^{2}} e^{-x^{2} u^{2}} \, du \, dt \nonumber \\ &= \frac{2}{\sqrt{\pi}} \int_{0}^{1} \int_{0}^{\infty} x^{a+1} e^{-(1+u^{2})x^{2}} \, dx \, dt \nonumber \\ &= \frac{1}{\sqrt{\pi}} \Gamma \left(1+ \frac{a}{2} \right) \int_{0}^{1} \frac{1}{(1+u^{2})^{a/2+1}} \, du \nonumber \\ &= \frac{1}{2 \sqrt{\pi}} \Gamma \left(1+ \frac{a}{2} \right) \int_{0}^{1} \frac{w^{-1/2}}{(1+w)^{1+a/2}} \, dw \nonumber \\ &= \frac{1}{2 \sqrt{\pi}} \Gamma \left(1+ \frac{a}{2} \right) \beta \left( \frac{1}{2} ; \frac{1}{2}, \frac{a}{2} + \frac{1}{2} \right) \nonumber \end{align}

\begin{align} &\int_{0}^{\infty} x^{2} e^{-x^{2}} \text{erf}(x) \log x \, dx \nonumber \\ &= \frac{1}{2 \sqrt{\pi}} \left( \frac{1}{2} \Gamma'(2) \beta \left( \frac{1}{2}; \frac{1}{2}, \frac{3}{2} \right) + \frac{d}{da} \beta \left( \frac{1}{2}; \frac{1}{2}, \frac{a}{2} + \frac{1}{2} \right) \Bigg|_{a = 2} \right) \nonumber \end{align}

$$\Gamma'(2) = 1- \gamma$$

$$\beta \left( \frac{1}{2}; \frac{1}{2}, \frac{3}{2} \right) = 2 \int_{0}^{1} \frac{x^{-1/2}}{(1+x)^{2}} \, dx = 2 \int_{0}^{1} \frac{du}{(1+u^{2})^{2}} \, du \nonumber$$

\begin{align} &= 2 \int_{0}^{\pi/4} \cos^{2} w \, dw \nonumber \\ &= 2 \int_{0}^{\pi/4} \left( \frac{1}{2} + \frac{\cos 2w}{w} \right) \, dw \nonumber \\ &= 2 \left(\frac{\pi}{8} + \frac{1}{4} \right) \nonumber \end{align}

the calculation of $$\displaystyle \frac{d}{da} \beta \frac{1}{2}$$ $$\frac{1}{2}, \frac{a}{2} + \frac{1}{2}\Big|_{a = 2 }$$

From the definition of the incomplete beta function, it follows that

\begin{align*} \frac{d}{da} \beta \left( \frac{1}{2}; \frac{1}{2}, \frac{a}{2} + \frac{1}{2} \right) \Big|_{a = 2} &= \frac{1}{2}\int_0^{\frac{1}{2}} \frac{\sqrt{1-x}}{\sqrt{x}}\log(1-x)\; dx \\ &= \int_0^{1\over \sqrt{2}}\sqrt{1-x^2}\log(1-x^2)\; dx \quad (x\mapsto x^2) \\ &= 2\int_0^{\pi \over 4} \cos^2(x) \log(\cos x)\; dx \quad (x\mapsto \sin x) \\ &= 2\int_0^{\pi \over 4} \cos^2(x) \left(-\log(2)-\sum_{k=1}^\infty(-1)^k\frac{\cos(2kx)}{k} \right)dx \; \quad (\text{Use Fourier Series of } \log(\cos x)\; ) \\ &= -\log(2) \left( \frac{2+\pi}{4}\right)-2\sum_{k=1}^\infty \frac{(-1)^k}{k}\int_0^{\pi \over 4}\cos^2(x)\cos(2k x)\; dx \\ &= -\log(2) \left( \frac{2+\pi}{4}\right)+\frac{4+\pi}{8}-2\sum_{k=2}^\infty \frac{(-1)^k}{k}\int_0^{\pi \over 4}\cos^2(x)\cos(2k x)\; dx \\ &= -\log(2) \left( \frac{2+\pi}{4}\right)+\frac{4+\pi}{8}+\frac{1}{2}\sum_{k=2}^\infty \frac{(-1)^k}{k}\left\{ \frac{\cos \frac{\pi k}{2}}{k^2-1}-\frac{\sin \frac{\pi k}{2}}{k}\right\} \\ &= -\log(2) \left( \frac{2+\pi}{4}\right)+\frac{\pi}{8}+\frac{1}{2}\sum_{k=0}^\infty \frac{(-1)^n}{(2n+1)^2}+\frac{1}{8}\sum_{k=1}^\infty \frac{(-1)^k}{k(4k^2-1)} \\ &= -\log(2) \left( \frac{2+\pi}{4}\right)+\frac{\pi}{8}+\frac{G}{2}+\frac{\log(2)-1}{4} \\ &= -\frac{1}{4}+\frac{G}{2}+\frac{\pi }{8}-\frac{ \log(2)}{4}-\frac{1}{4} \pi \log(2) \end{align*}