# Evaluating the definite integral $\int_0^\infty x \mathrm{e}^{-\frac{(x-a)^2}{b}}\,\mathrm{d}x$

To evaluate $\int_0^\infty x \mathrm{e}^{-\frac{(x-a)^2}{b}}\,\mathrm{d}x$, I have applied the substitution $u=\frac{(x-a)^2}{b}$, $x-a=(ub)^{1/2}$, and $\frac{\mathrm{d}u}{\mathrm{d}x}=\frac{2(x-a)}{b}$. I would first like to ask if $x-a$ should actually equal $\pm (ub)^{1/2}$ (i.e., is it valid to ignore the minus sign, and why?). Applying this substitution, \begin{align} I &=\int_0^\infty x \mathrm{e}^{-\frac{(x-a)^2}{b}}\, \mathrm{d}x \\ &=\int_0^\infty x \mathrm{e}^{-u} \frac{b\,\mathrm{d}u}{2(x-a)} \\ &=\int_{\frac{a^2}{b}}^\infty \left((ub)^{1/2} + a\right)\cdot{}\mathrm{e}^{-u} \frac{b\,\mathrm{d}u}{2(ub)^{1/2}} \\ &=\frac{b}{2}\int_{\frac{a^2}{b}}^\infty \mathrm{e}^{-u}\,\mathrm{d}u + ab^{-1/2}\mathrm{e}^{-u} u^{-1/2}\,\mathrm{d}u \\ &=\frac{b}{2}\int_{\frac{a^2}{b}}^\infty \mathrm{e}^{-u}\,\mathrm{d}u + \frac{a\sqrt{b}}{2}\int_{\frac{a^2}{b}}^\infty \mathrm{e}^{-u} u^{-1/2}\,\mathrm{d}u, \end{align} I find that I am unable to evaluate the second term because the domain is from a non-zero constant to $+\infty$. Were the domain $[0,+\infty)$, the second integral would simply be a $\Gamma$ function. Seeing that the substitution I have attempted has not worked, could someone please propose an alternate route to evaluating this definite integral? Thank you.

• Just to answer the first question: should you write $(ub)^{\pm1/2}$. You should NOT! $(ub)^{1/2}$ and $(ub)^{-1/2}$ are two completely different expressions. The first one is simply $(ub)^{1/2}$, however there second one is $\frac{1}{(ub)^{1/2}}$. When you have the $\frac{1}{2}$ power you are already implying two solutions.
– E.O.
Feb 20, 2012 at 10:26
• Whoops, I meant $\pm(ub)^{1/2}$. Fixed. Feb 20, 2012 at 16:01

We assume that $b>0$ otherwise the integral is not convergent. "The" good substitution is $u=\frac{x-a}{\sqrt b}$, so $\sqrt bu+a=x$ and $dx=\sqrt bdu$. We have \begin{align*} I_{a,b}&:=\int_0^{+\infty}x\exp\left(-\frac{(x-a)^2}b\right)dx\\ &=\int_{-a/\sqrt b}^{+\infty}(\sqrt bu+a)\exp(-u^2)\sqrt bdu\\ &=a\sqrt b\int_{-a/\sqrt b}^{+\infty}\exp(-u^2)du+ b\left[-\frac{\exp(-u^2)}2\right]_{-a/\sqrt b}^{+\infty}\\ &=\frac b2\exp\left(-\frac{a^2}b\right)+a\sqrt b \int_0^{+\infty}\exp(-u^2)du-a\sqrt b\int_0^{a/\sqrt b}\exp(-u^2)du\\ &=\frac b2\exp\left(-\frac{a^2}b\right)+a\sqrt b\int_0^{+\infty}\exp\left(-\frac{t^2}2\right)du\frac 1{\sqrt 2}-a\sqrt b\frac{\sqrt \pi}2\operatorname{erf}\left(\frac a{\sqrt b}\right) \\ &=\frac b2\exp \left(-\frac{a^2}b\right)+\frac{a\sqrt b\sqrt \pi}2\left(\frac 1{\sqrt 2}-\operatorname{erf}\left(\frac a{\sqrt b}\right)\right), \end{align*} where $\operatorname{erf}\left(x\right)=\frac 2{\sqrt \pi}\int_0^xe^{-t^2}dt$.
• Thanks, Davide. Since you have factored out the constant $a$, should the coefficient of the second term in the third line be $\sqrt b/a$? How did you integrate that term (from second line to third line)? It appears that you have written $\int_{-a/\sqrt{b}}^\infty bu\exp(-u^2)\,\mathrm{d}u = \sqrt b/a \left.\left[-\exp(-u^2)/2\right]\right|_{-a/\sqrt b}^{\infty}$, which I do not entirely follow. Feb 20, 2012 at 2:34
• Thanks for pointing out this mistake. For the step between the second and third line I just used a primitive of $u\exp(-u^2)$. Feb 20, 2012 at 10:15