# Solve the following integral: $\int_{x_0}^\infty \log(x) e^{-(x-a)^2/b}dx \quad x_0,b>0$

I want to compute this integral preferably in closed-form without expanding the $\log$ function; however, efficiently computable approximations might also solve my problem:

$\int_{x_0}^\infty \log(x) e^{-\frac{(x-a)^2}{b}}dx \quad x_0,b>0$

Background: I am trying to compute the expectation of a logarithmic function of random variables from a truncated normal distribution:

$\mathbb{E}_{x\sim \mathcal{N}(\mu,\sigma^2|x\geq x_0>0)}[\log(x)]$

Equivalently, I need to solve the follwing integral:

$\int_{x_0}^\infty \log(x) \frac{e^{-\frac{(x-\mu)^2}{2\sigma^2}}}{\sigma^2\sqrt{2\pi}(1-\Phi(\frac{x_0-\mu}{\sigma}))}dx=\frac{1}{\sigma^2\sqrt{2\pi}(1-\Phi(\frac{x_0-\mu}{\sigma}))}\int_{x_0}^\infty \log(x) e^{-\frac{(x-\mu)^2}{2\sigma^2}}dx$

I'm stuck here.

Thanks for any help.

Here is a suggested solution. Recall that $$\frac{\partial}{\partial t} x^t = x^t\log(x)$$

and notice that the above derivative will be equal to $\log(x)$ when $t = 0$. Therefore, $$I = \int^\infty_{x_0} \log(x) \exp\left(-\frac{1}{2} \left[\frac{x - \mu}{\sigma}\right]^2\right)dx = \left.\int^\infty_{x_0} \left[\frac{\partial}{\partial t} x^t\right] \exp\left(-\frac{1}{2} \left[\frac{x - \mu}{\sigma}\right]^2\right)dx\right|_{t = 0}$$

Using Leibniz integral rule, the above integral can be rewritten as $$I = \left.\dfrac{d}{dt} \int^\infty_{x_0} x^t \exp\left(-\frac{1}{2} \left[\frac{x - \mu}{\sigma}\right]^2\right)dx\right|_{t = 0}.$$

Let $u = \frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2$, accordingly, $\frac{\sigma}{\sqrt{2}} u^{-\frac{1}{2}} du = dx$. Hence,

$$I = \frac{\sigma}{\sqrt{2}} \left.\dfrac{d}{dt} \int^\infty_{\xi_0} u^{1 - \frac{t}{2} - 1} e^{-u}du\right|_{t = 0} = \frac{\sigma}{\sqrt{2}} \left.\dfrac{d}{dt} \Gamma\left(1 - \frac{t}{2}, \xi_0 \right)\right|_{t = 0}$$ where $\xi_0 = \frac{1}{2}\left(\frac{x_0 - \mu}{\sigma}\right)^2$. Using the definition of the first-order derivative of the upper incomplete gamma function $\Gamma(\cdot, \cdot)$ that was given by Geddes et. al. (1990), the above integral reduces to: $$I = -\frac{\sigma}{2\sqrt{2}} \left.\left[\log \xi_0 \Gamma\left(1 - \frac{t}{2}, \xi_0 \right) + \xi_0 T\left(3, 1 - \frac{t}{2}, \xi_0\right) \right]\right|_{t = 0} = -\frac{\sigma}{2\sqrt{2}} \left[\log \xi_0 \Gamma\left(1, \xi_0 \right) + \xi_0 T\left(3, 1, \xi_0\right) \right]$$ where $$T\left(3, 1, \xi_0\right) = G^{3,0}_{2,3} \left(\xi_0 \left| \begin{matrix} 0 , 0 \\ -1, 0, - 1 \end{matrix} \right. \right)$$ is a special case of the Meijer G-function.

Reference:

K.O. Geddes, M.L. Glasser, R.A. Moore and T.C. Scott (1990), Evaluation of Classes of Definite Integrals Involving Elementary Functions via Differentiation of Special Functions. Applicable Algebra in Engineering, Communication and Computing, vol. 1, pp. 149-165

• Thanks a lot! This looks very promising. Excuse my ignorance, but could you elaborate the details of how we get the re-written integration in the second line? (I mean, how you got rid of the $\log$?) – Alt Sep 2 '16 at 22:18
• You are welcome @Alt. Regarding your question, I used Leibniz integral rulelink and the definition of the derivative of $x^t$ with respect to $t$. I'll add some details in the solution. – FALAM Sep 2 '16 at 23:33
• All the suggested solutions were great, but your solution was the closest to what I needed. I wanted to award the bounty to your solution, but unfortunately, the auto award has randomly assigned to another one. I'm sorry for that and thanks again. – Alt Sep 4 '16 at 15:49
• That's OK @Alt, I'm here to help whenever I can. – FALAM Sep 5 '16 at 3:39

Too long for a comment : Even the simple case $\color{#0055AA}{a=x_0}$ yields an expression in terms of
$($ generalized $)$ hypergeometric functions :

$$I(a,b)~=~\frac14~\sqrt{\frac\pi b}~\bigg[2a^2\cdot~_2F_2\bigg(\{1,1\},\bigg\{\frac32,~2\bigg\},-\frac{a^2}b\bigg)-b\cdot J(a,b)\bigg],$$

with

$$J(a,b)~=~\gamma~+~\ln\frac4b~+~\text{erf}~\bigg(\frac a{\sqrt b}\bigg)\cdot\bigg(\gamma-2+\ln\frac{a^2}b\bigg),$$

where $\text{erf}$ represents the error function, and $\gamma$ stands for the Euler-Mascheroni constant.

It is therefore highly doubtful that the more general definite integral posted in the original question possesses a closed form even in terms of these special functions. Perhaps Meijer's G-function might sweep in and save the day ? Just a thought $\ldots$

• Thanks! I will learn more and will think about the Meijer's G-function. In the meanwhile, I appreciate it if you can update your answer if you could come up with a solution to the original question. Even a good approximation will solve my problem. – Alt Sep 1 '16 at 2:56
• @Alt: The only solution I can come up with is that which you expressly forbade in the post; namely, expanding the integrand (or one of its equivalents, following various possible substitutions) into its Taylor series, and then switching the order of summation and integration. – Lucian Sep 1 '16 at 21:18
• I see. That was one of the things that I came up with too, but I'm curious to know your solution as well. Therefore, I changed the question's statement. Thanks again. – Alt Sep 1 '16 at 23:09
• The next question that I'll have: In the case of using the Taylor expansion of the $\log$ function, what can we say about the (joint) convexity of the solution in $a$ and $b$. – Alt Sep 1 '16 at 23:14

A quick approximation for large $a$ using the saddle point method: The integrand can be written as $e^{f(x)}$, where $$f(x) = \log\log x - \frac{(x-a)^2}{b}.$$ We find $$f'(x) = \frac{1}{x\log x} - \frac{2(x-a)}{b}.$$ Thus, for large $a$ we find $f'(a)=\frac{1}{a\log a}\approx 0$. We find $f(a) = \log\log a$ and $$f''(a) = -\frac{2}{b} + O\left(\frac{1}{a^2\log a}\right) \approx -\frac{2}{b}.$$ Therefore, \begin{align*} \int_{x_0}^\infty \log(x) e^{-(x-a)^2/b}dx &\approx \int_{x_0}^\infty \exp\left(\log\log a -\frac{1}{b}(x-a)^2\right) dx \\ &= \sqrt{\pi b}\log a\, \Phi\left(\sqrt{\frac{2}{b}}(a-x_0)\right). %&= \frac{1}{2}\sqrt{\pi b}\log a %\left(1+\mathrm{erf}\left(\frac{a-x_0}{\sqrt{b}}\right)\right). \end{align*} (It can be shown that the same result holds if we assume instead that $b$ is small.)

Addendum: Below we plot the absolute relative error and the absolute error using this approximation for $x_0=1$.

• Thank you for the solution. In my problem, I do not have any control over $a$, and it is not necessarily large. $x_0$ can vary, and could be much smaller. In your simulation, is there a way to show the absolute error as well. Thanks again. – Alt Sep 2 '16 at 21:32
• Glad to help. It can be shown that this approximation also holds if $b$ is small. I have added a plot of the absolute error above. – user26872 Sep 3 '16 at 20:21