# ${\displaystyle \int_0^\infty e^{-x^2} (\log x)^2 \,\mathrm{d}x}$
> Author: Junner
> Date: 05/01/24
## Stage 1
First, let me introduce a simple version of this kind of problem:
$$\newcommand{\d}{\mathrm{d}}
\newcommand{\alb}{\begin{align*}}
\newcommand{\ale}{\end{align*}}
\newcommand{\dis}{\displaystyle}
\newcommand{\i}[2]{\int_0^\infty #1 \,\d #2}
\newcommand{\dd}[1]{\frac{\d}{\d #1}}
\newcommand{\pp}[1]{\frac{\partial}{\partial #1}}
\newcommand{\ddt}[1]{\frac{\d^2}{\d #1^2}}
\newcommand{\ppt}[1]{\frac{\partial^2}{\partial #1^2}}
\newcommand{\G}{\Gamma}
\newcommand{\g}{\gamma}
\newcommand{\red}{\color{red}}
\newcommand{\brown}{\color{brown}}
\newcommand{\lrr}[1]{\left( #1 \right)}
\text{Evaluate }\quad{\int_0^\infty e^{-x^2} \log(x) \,\d x}
$$
Set ${\displaystyle \mathrm{I} = \int_0^\infty e^{-x^2} \log(x) \,\d x}$
And let ${\dis u = x^2,\, \d x = \frac{1}{2\sqrt{u}} \d u}$
$$\alb
\mathrm{I}
&= \i{ e^{-x^2} \log(x) }{x}\\
&= \i{ e^{-u} \frac{1}{2} \log(u) \frac{1}{2\sqrt{u}} }{u}\\
&= \frac{1}{4} \i{ e^{-u} u^{-\frac{1}{2}} \log(u) }{u}\\
&= \frac{1}{4} \i{ e^{-x} x^{-\frac{1}{2}} \log(x) }{x}
\ale
$$
Make a function that is similar to $\Gamma$ function
$$ \mathrm{K}(t) = \i{ e^{-x} x^t }{x}
$$
Note that ${\dis \pp{t}x^t = x^t\log x }$
$$\alb
\dd{t} \mathrm{K}(t)
&= \dd{t} \i{ e^{-x} x^t}{x}\\
&= \i{ e^{-x} \pp{t} x^t}{x}\\
&=\i{ e^{-x} x^{\color{red}t} \log x}{x}\\
\ale
$$
Compare with $\Gamma(t)$
$$\alb
\Gamma(t)
&= \i{ e^{-x} x^{\color{red}{t-1}} }{x}\\
&= \mathrm{K} (t-1)
\ale
$$
Compare with $\mathrm{I}$
$$\alb
\mathrm{I}
&= \frac{1}{4} \i{ e^{-x} x^{\color{red}{-\frac{1}{2}}} \log x }{x}\\
&= \frac{1}{4} \mathrm{K}\red' \!\left( -\frac{1}{2} \right)\\
&= \frac{1}{4} \Gamma\red' \!\left( \frac{1}{2} \right)
\ale
$$
For alternative, now we need to evaluate $\Gamma' \!\left( \frac{1}{2} \right)$.
:::warning
Introducing two important formulas:
$$ \G(t+1) = t\,\G(t) \quad\cdots (1)
$$ $$
\G(t)\ \G \!\lrr{ t+\frac{1}{2} } = \sqrt{\pi}\ 2^{1-2t}\ \G(2t) \quad\cdots (2)
$$
:::
Derivative both sides of $\brown{(1)}$, and note that $\G\!\lrr{\frac12} = \sqrt{\pi}$ :
$$\G'(t+1) = \G(t) + t\,\G'(t) \brown{\quad\cdots(1')}
$$ $$\alb
&\G'\!\lrr{ \frac{3}{2} } = \G\!\lrr{\frac{1}{2}} + \frac{1}{2}\,\G'\!\lrr{\frac{1}{2}}\\
\implies& \G'\!\lrr{\frac{1}{2}} = 2 \lrr{ \G'\!\lrr{ \frac{3}{2} } - \sqrt{\pi} }
\ale
$$
Derivative both sides of $\brown{(2)}$ :
$$\alb
\G'(t)\ \G \!\lrr{ t+\frac{1}{2} } + \G(t)\ \G' \!\lrr{ t+\frac{1}{2} } = \sqrt{\pi}\ 2^{2-2t}\Big( \G'(2t) - \G(2t) \log 2 \Big) &\\
\brown{\quad\cdots(2')}&
\ale
$$
Substitute $t$ with $1$, and note that $\brown{ \G'(1) = -\g }$. This constant $\g$ is known as [Euler's constant](https://en.wikipedia.org/wiki/Euler%27s_constant).
$$\implies -\g\,\G\!\lrr{\frac32} + \G'\!\lrr{\frac32} = \sqrt{\pi}\,\Big( \G'(2) - \log 2 \Big)
$$
By using $\brown{(1)}$
$$\alb
\G\!\lrr{\frac{3}{2}}
&=\frac12\,\G\!\lrr{\frac12}\\
&= \frac{\sqrt{\pi}}{2}
\ale
$$
By using $\brown{(1')}$
$$\alb
\G'(2)
&= \G(1) + \,\G'(1)\\
&= 1 - \g
\ale
$$
And we get
$$\alb\implies \G'\!\lrr{\frac32} &= \sqrt{\pi}\,\Big( 1 - \g - \log2 \Big) + \g\,\frac{\sqrt{\pi}}{2}\\
&= \frac{\sqrt{\pi}}{2}\Big( 2 - \g - \log4 \Big)
\ale
$$
For $\G'\!\lrr{\dis \frac{1}{2} }$, we get
$$\alb
\G'\!\lrr{\frac{1}{2}}
&= 2 \lrr{ \G'\!\lrr{ \frac{3}{2} } - \sqrt{\pi} }\\
&= -\sqrt{\pi}\,\big( \g + \log4 \big)
\ale
$$
Finally
$$\alb
\mathrm{I}
&= \frac{1}{4} \Gamma'\!\left( \frac{1}{2} \right)\\
&= -\frac{\sqrt{\pi}}{4}\,\Big( \g + \log4 \Big)
\ale
$$
---
## Stage 2
$$
\mathrm{I} = \int_0^\infty e^{-x^2} (\log x)^2 \,\d x
$$
Still, let ${\dis u = x^2,\, \d x = \frac{1}{2\sqrt{u}} \d u}$
$$\alb
\mathrm{I}
&= \i{ e^{-u} \frac{1}{4} \big(\log u \big)^2\, \frac{1}{2\sqrt{u}} }{u}\\
&= \frac{1}{8} \i{ e^{-u} u^{-\frac{1}{2}} \big(\log u \big)^2\, }{u}\\
&= \frac{1}{8} \i{ e^{-x} x^{-\frac{1}{2}} \big(\log x \big)^2\, }{x}
\ale
$$
Well, at stage 1, we make a function $\mathrm K$ and partial derivative the component $x^t$ so that we got $(x^t \log\!x)$ inside the integral. And here, all the steps are quite alike, we only need to derivative $\mathrm K$ twice.
$$ \mathrm{K}(t) = \i{ e^{-x} x^t }{x}
$$
Note that ${\dis \ppt{t}x^t = x^t(\log x)^2 }$
$$\alb
\ddt{t} \mathrm{K}(t)
&= \ddt{t} \i{ e^{-x} x^t}{x}\\
&= \i{ e^{-x} \ppt{t} x^t}{x}\\
&=\i{ e^{-x} x^{\color{red}t} \big( \log x \big)^2}{x}\\
\ale
$$
Compare with $\Gamma(t)$
$$\alb
\Gamma(t)
&= \i{ e^{-x} x^{\color{red}{t-1}} }{x}\\
&= \mathrm{K} (t-1)
\ale
$$
Compare with $\mathrm{I}$
$$\alb
\mathrm{I}
&= \frac{1}{8} \i{ e^{-x} x^\red{-\frac{1}{2}} \big(\log x \big)^2\, }{x}\\
&= \frac{1}{8} \mathrm{K}\red{''} \!\left( -\frac{1}{2} \right)\\
&= \frac{1}{8} \Gamma\red{''} \!\left( \frac{1}{2} \right)
\ale
$$
So let's turn to find out $\Gamma'' \!\left( \frac{1}{2} \right)$
Derivative both sides of $\brown{(1')}$ :
$$\G''(t+1) = t\,\G''(t) + 2\,\G'(t) \brown{\quad\cdots(1'')}
$$
Substitute $t$ with $\frac12$
$$ \G''\!\lrr{ \frac{3}{2} } = \frac{1}{2}\,\G''\!\lrr{\frac{1}{2}} + 2\,\G'\!\lrr{\frac{1}{2}}
$$ $$\alb
\implies \G''\!\lrr{\frac{1}{2}}
&= 2 \lrr{ \G''\!\lrr{ \frac{3}{2} } - 2\,\G'\!\lrr{\frac12} }\\
&= 2 \lrr{ \G''\!\lrr{ \frac{3}{2} } - 2\sqrt{\pi}\Big( \g + \log 4 \Big) }
\ale
$$
Derivative both sides of $\brown{(2')}$ :
$$\alb
\G''(t)&\ \G \!\lrr{ t+\frac{1}{2} } + \G'(t)\ \G' \!\lrr{ t+\frac{1}{2} } + \G(t)\ \G'' \!\lrr{ t+\frac{1}{2} }\\
& = \sqrt{\pi}\ 2^{3-2t}\Big( \G(2t) ( \log 2 )^2 - 2\,\G'(2t) \log(2) + \G''(2t) \Big)&\\
&&\!\!\!\!\!\!\!\!\!\!\!\!\brown{\cdots(2'')}
\ale
$$
Substitute $t$ with $1$
$$\alb
\implies\G''(1)&\ \G \!\lrr{ \frac{3}{2} } + \G'(1)\ \G' \!\lrr{ \frac{3}{2} } + \G(1)\ \G'' \!\lrr{ \frac{3}{2} }\\
& = 2\sqrt{\pi}\,\Big( \G(2) ( \log 2 )^2 - 2\,\G'(2) \log(2) + \G''(2) \Big)
\ale
$$
And we've already known that
$$\G'(1) = -\g,\ \G'(2) = 1 - \g
$$ $$
\G\!\lrr{\frac32} = \frac{\sqrt{\pi}}{2}
,\ \G'\!\lrr{\frac32} = \frac{\sqrt{\pi}}{2}\Big( 2 - \g - \log4 \Big)
$$
So we get
$$\alb
\implies\G'' \!\lrr{ \frac{3}{2} }
&= 2\sqrt{\pi}\,\Big( (\log 2)^2 - 2\,(1 - \g) \log(2) + \G''(2) \Big)\\
&\qquad - \frac{\sqrt{\pi}}{2}\,\G''(1) -\g\lrr{\frac{\sqrt{\pi}}{2}\Big( 2 - \g - \log4 \Big)}\\
\ale
$$
But we don't know how to evaluate $\G''(1)$ and $\G''(2)$.
Let me introduce a new function, $\psi(\cdot)$, that is called digamma function or first degree polygamma function.
$$\psi(x) = \frac{\G'(x)}{\G(x)}
= -\g + \sum_{n=0}^{\infty} \lrr{\frac{1}{n+1} - \frac{1}{n+x}}
$$
Therefore, we can rewrite the derivative function of $\G(x)$
$$\G'(x) = \G(x)\,\psi(x)
$$
Derivative both sides
$$\G''(x) = \G'(x)\,\psi(x) + \G(x)\,\psi'(x) \quad\brown{\cdots(3)}
$$
Evaluate $\psi'(x)$ with the series representation
$$\alb
\psi'(x)
&= \dd{x} \lrr{ -\g + \sum_{n=0}^{\infty} \lrr{\frac{1}{n+1} - \frac{1}{n+x}} }\\
&= \sum_{n=0}^{\infty} \frac{1}{(n+x)^2} \quad\brown{\cdots(4)}
\ale
$$
Break $\G''(2)$ down with $\brown{(1'')}$
$$\G''(t+1) = t\,\G''(t) + 2\,\G'(t)
$$ $$\alb
\implies \G''(2)
&= \G''(1) + 2\,\G'(1)\\
&= \G''(1) - 2\g
\ale
$$
With $\brown{(3)}$ and $\brown{(4)}$
$$\alb
\G''(1)
&= \G'(1)\,\psi(1) + \G(1)\,\psi'(1)\\
&= \G'(1)\,\frac{\G'(1)}{\G(1)} + \sum_{n=0}^{\infty} \frac{1}{(n+1)^2}
\ale
$$
And ${\dis \sum_{n=0}^{\infty} \frac{1}{(n+1)^2} }$ is well-known as Besel problem or $\zeta(2)$, the value of it is ${\dis \frac{\pi}{6}}$. Now we have
$$\G''(1) = \g^2 + \frac{\pi}{6}
$$ $$
\G''(2) = \g^2 - 2\g + \frac{\pi}{6}
$$
Back to $\G'' \!\lrr{ \frac{3}{2} }$
$$\alb
\G'' \!\lrr{ \frac{3}{2} }
&= 2\sqrt{\pi}\,\Big( (\log 2)^2 - 2\,(1 - \g) \log(2) + \G''(2) \Big)\\
&\qquad - \frac{\sqrt{\pi}}{2}\,\G''(1) -\g\lrr{\frac{\sqrt{\pi}}{2}\Big( 2 - \g - \log4 \Big)}\\
&= 2\sqrt{\pi}\,\bigg( (\log 2)^2 - 2\,(1 - \g) \log(2) + \lrr{ \g^2 - 2\g + \frac{\pi}{6} } \bigg)\\
&\qquad - \frac{\sqrt{\pi}}{2}\lrr{ \g^2 + \frac{\pi}{6} } -\g\lrr{\frac{\sqrt{\pi}}{2}\Big( 2 - \g - \log4 \Big)}\\
&= \frac{\sqrt{\pi}}{4} \Big( 2\g^2 + 4\g\log(4) - 8\g + 2(\log 4)^2 - 8\log(4) + \pi^2 \Big)
\ale
$$
Finally
$$\alb
\G''\!\lrr{\frac12}
&= 2 \lrr{ \G''\!\lrr{ \frac{3}{2} } - 2\sqrt{\pi}\Big( \g + \log 4 \Big) }\\
&= \frac{\sqrt{\pi}}{2} \Big( \pi^2 + 2 \,\big( \g^2 + 2\g\log(4) - 4\g + (\log 4)^2\\
&\qquad\qquad\qquad\quad\ - 4\log(4) + 4\log(4) + 4\g \big) \Big)\\
&= \frac{\sqrt{\pi}}{2} \Big( \pi^2 + 2\,\big( \g^2 + 2\g\log(4) + (\log 4)^2 \big) \Big)\\
&= \frac{\sqrt{\pi}}{2} \Big( \pi^2 + 2\,\big( \g + \log 4 \big)^2 \Big)
\ale
$$
And the last
$$
\mathrm{I} = \frac18\G''\!\lrr{\frac12} = \frac{\sqrt{\pi}}{16} \Big( \pi^2 + 2\,\big( \g + \log 4 \big)^2 \Big)
$$
<!-- ## other
Several proofs of formulas and constants
1. [${\G\!\lrr{\frac12} = \sqrt{\pi} }$](https://hackmd.io/@JunnerX/Gamma-of-one-half) -->
<!-- 2. [$\G'(1) = -\g$](https://hackmd.io/@JunnerX/Gamma-prime-of-one) -->
<!-- 3. [$\G(t+1) = t\,\G(t) \quad\cdots (1)$]() -->
<!-- 4. [${\dis \G(t)\ \G \!\lrr{ t+\frac{1}{2} } = \sqrt{\pi}\ 2^{1-2t}\ \G(2t) \quad\cdots (2) }$]() -->
<!-- 5. [${\dis \psi(x) = -\g + \sum_{n=0}^{\infty} \lrr{\frac{1}{n+1} - \frac{1}{n+x}} }$]() -->
<!-- 6. [${\dis \sum_{n=0}^{\infty} \frac{1}{(n+1)^2} = \frac\pi6 }$]() -->