# Evaluate $\int_0^\infty x^{n+\frac12}e^{-\frac x2}\log^2x\,dx$ and $\int_0^\infty x^ne^{-\frac x2}\log^2x\,dx$

Determine the closed forms of $$\mathfrak I_1=\int_0^\infty x^{n+\frac12}e^{-\frac x2}\log^2x\,dx\quad\text{and}\quad\mathfrak I_2=\int_0^\infty x^ne^{-x/2}\log^2x\,dx$$ where $$s>0$$ is an integer.

This problem arose while determining the Jeffreys prior of the $$\chi^2$$-distribution as I tried to evaluate the Fisher information matrix $$\mathcal I(k)=\int_0^\infty f(x\mid k)\left(\frac d{dk}\log f(x\mid k)\right)^2\,dx$$ where $$f(x\mid k)$$ is the p.d.f. of the distribution. After splitting the integral into three components, the matrix became $$\mathcal I(k)=K_1^2-K_1K_2+\frac{2^{k/2-2}}{\Gamma(k/2)}\color{red}{\int_0^\infty x^{k/2}e^{-x/2}\log^2x\,dx}$$ where $$K_1=\frac12\log2+\frac1{\psi^{(0)}(k/2)}\quad\text{and}\quad K_2=\log2+\psi^{(0)}(k/2).$$ The integrals $$\mathfrak I_1$$ and $$\mathfrak I_2$$ are obtained by setting $$k=2n+1$$ and $$2n$$ respectively in the integral in red. Plugging in some values into WolframAlpha, I found that they are of the forms \begin{alignat}2\mathfrak I_1&=\sqrt{\frac\pi2}\left(a+b\pi^2+\gamma\left(-c+2b\gamma+4b\log2\right)-(c-2b\log2)\log2\right)\tag1\\\mathfrak I_2&=2^q(r+s\pi^2-\gamma(t-6s\gamma+12s\log2)+(t+6s\log2)\log2)\tag2\end{alignat} where $$b=(2n+1)!/(2^n\cdot n!)$$, $$\gamma$$ is the Euler-Mascheroni constant and $$a,c,q,r,s,t$$ are positive constants.

Is there a relationship between the values of $$a,c$$ and $$b$$, and similarly between the values of $$q,r,t$$ and $$s$$? Note that I have not been able to find an expression for $$s$$.

Can the forms of $$(1)$$ and $$(2)$$ be proven analytically?

Here is an analytic evaluation for $$\mathfrak I_2$$. The evaluation for $$\mathfrak I_1$$ is similar.

Enforcing a substitution of $$x \mapsto 2x$$ one has \begin{align} \mathfrak I_2 &= 2^{n + 1} \int_0^\infty e^{-x} x^n \log^2 (2x) \, dx\\ &= 2^{n + 1} \log^2 2 \int_0^\infty e^{-x} x^n \, dx + 2^{n + 2} \log 2 \int_0^\infty e^{-x} x^n \log x \, dx\\ & \qquad + 2^{n + 1} \int_0^\infty e^{-x} x^n \log^2 x \, dx. \tag1 \end{align}

For the first integral: $$\int_0^\infty e^{-x} x^n \, dx = \Gamma (n + 1) = n!, \quad \text{since} \,\,n = 0,1,2, \ldots$$

For the second integral: \begin{align} \int_0^\infty e^{-x} x^n \log x \, dx &= \frac{d}{ds} \left [\int_0^\infty e^{-x} x^{n + s} \, dx \right ]_{s = 0}\\ &= \frac{d}{ds} \left [\Gamma (n + s + 1) \right ]_{s = 0}\\ &= \Gamma'(n + s + 1) \Big{|}_{s = 0}\\ &= \Gamma (n + s + 1) \psi^{(0)}(n + s + 1) \Big{|}_{s = 0}\\ &= \Gamma (n + 1) \psi^{(0)} (n + 1)\\ &= n! \, \psi^{(0)} (n + 1). \end{align}

For the third integral: \begin{align} \int_0^\infty e^{-x} x^n \log^2 x \, dx &= \frac{d^2}{ds^2} \left [\int_0^\infty e^{-x} x^{n + s} \, dx \right ]_{s = 0}\\ &= \frac{d^2}{ds^2} \Gamma (n + s + 1) \Big{|}_{s = 0}\\ &= \frac{d}{ds} \Gamma'(n + s + 1) \Big{|}_{s = 0}\\ &= \frac{d}{ds} \Gamma (n + s + 1) \psi^{(0)}(n + s + 1) \Big{|}_{s = 0}\\ &= \Gamma (n + s + 1) \left (\psi^{(0)} (n + s + 1) \right )^2 + \Gamma (n + s + 1) \psi^{(1)} (n + s + 1) \Big{|}_{s = 0}\\ &= \Gamma (n + 1) \left (\psi^{(1)} (n + 1) \right )^2 + \Gamma (n + 1) \psi^{(1)} (n + 1)\\ &= n! \left [\left (\psi^{(0)} (n + 1) \right )^2 + \psi^{(1)} (n + 1) \right ]. \end{align}

So (1) becomes $$\mathfrak I_2 = 2^{n + 1} n! \left [\log^2 2 + 2 \log 2 \psi^{(0)} (n + 1) + \left (\psi^{(0)} (n + 1) \right )^2 + \psi^{(1)} (n + 1) \right ].$$ Since $$n = 0,1,2,\ldots$$ the above expression in terms of the polygamma function can be further reduced to an expression containing the $$n$$th order harmonic number $$H_n$$ and the $$n$$th order generalised harmonic number of order two $$H^{(2)}_n$$. Since $$\psi^{(0)}(n + 1) = -\gamma + \sum_{k = 1}^n \frac{1}{k} = -\gamma + H_n,$$ and $$\psi^{(1)} (n + 1) = \zeta (2) - \sum_{k = 1}^n \frac{1}{k^2} = \frac{\pi^2}{6} - H^{(2)}_n,$$ then $$\mathfrak I_2 = 2^{n + 1} n! \left [\log^2 2 - 2 \gamma \log 2 + 2 \log 2 H_n + \gamma^2 - 2 \gamma H_n + H^2_n + \frac{\pi^2}{6} - H^{(2)}_n \right ],$$ valid for $$n = 0,1,2, \ldots$$. Here $$\gamma$$ denotes the Euler-Mascheroni constant.

Both integrals we can calculate by considering the following function:

$$I(s) = \int_0^\infty x^se^{-\frac{x}{2}}\log^2(x)\:dx = \frac{d^2}{ds^2}\int_0^\infty x^se^{-\frac{x}{2}}\:dx$$

Then with an appropriate change of variables we get that

$$I(s) = \frac{d^2}{ds^2}2^{s+1}\Gamma(s+1) = 2^{s+1}\left[\log^2(2)\Gamma(s+1)+2\log(2)\Gamma'(s+1)+\Gamma''(s+1)\right]$$

$$= 2^{s+1}\Gamma(s+1)\left[\log^2(2) + 2\log(2)\psi(s+1) + \psi^2(s+1)+\psi^{(2)}(s+1)\right]$$

where $$\psi$$ are the polygamma functions, with the first terms being just the digamma function. All that's left is to plug $$s=n+\frac{1}{2}$$ and $$s=n$$, respectively, for the two integrals.

For $$s>-1$$, I found the following: $$\int_0^{ + \infty } {x^s e^{ - x/2} \log ^2 xdx} = 2^{s + 1} \int_0^{ + \infty } {t^s e^{ - t} \log ^2 (2t)dt} \\ = 2^{s + 1} \int_0^{ + \infty } {t^s e^{ - t} \log ^2 tdt} + 2^{s + 2} \log 2\int_0^{ + \infty } {t^s e^{ - t} \log tdt} + 2^{s + 1} \log ^2 2\int_0^{ + \infty } {t^s e^{ - t} dt} \\ = 2^{s + 1} \left[ {\frac{{d^2 }}{{dz^2 }}\int_0^{ + \infty } {t^{z + s} e^{ - t} dt} } \right]_{z = 0} + 2^{s + 2} \log 2\left[ {\frac{d}{{dz}}\int_0^{ + \infty } {t^{z + s} e^{ - t} dt} } \right]_{z = 0} + 2^{s + 1} \log ^2 2\int_0^{ + \infty } {t^s e^{ - t} dt} \\ = 2^{s + 1} \left[ {\frac{{d^2 }}{{dz^2 }}\Gamma (z + s + 1)} \right]_{z = 0} + 2^{s + 2} \log 2\left[ {\frac{d}{{dz}}\Gamma (z + s + 1)} \right]_{z = 0} + (2^{s + 1} \log ^2 2)s! \\ = 2^{s + 1} s!\left[ {s!\psi ^2 (s + 1) + \psi (s + 1)\log 4 + \psi '(s + 1) + \log ^2 2} \right].$$