How to evaluate $\int_{0}^{+\infty}\exp(-ax^2-\frac b{x^2})\,dx$ for $a,b>0$

$$\begin{align} I = & \int_0^{\infty} e^{-ax^2 - bx^{-2}} dx\\ \stackrel{\color{blue}{[1]}}{=} & \left(\frac{b}{a}\right)^{1/4}\int_0^{\infty} e^{-\sqrt{ab}(y^2 + y^{-2})} dy\\ = & \left(\frac{b}{a}\right)^{1/4}\left[ \int_0^{1} + \int_1^{\infty} \right] e^{-\sqrt{ab}(y^2 + y^{-2})} dy\\ \stackrel{\color{blue}{[2]}}{=} & \left(\frac{b}{a}\right)^{1/4} \int_1^{\infty} e^{-\sqrt{ab}(y^2 + y^{-2})} \left(\frac{1}{y^2} + 1\right) dy\\ = & \left(\frac{b}{a}\right)^{1/4} \int_1^{\infty} e^{-\sqrt{ab}((y-y^{-1})^2+2)} d\left( y - \frac{1}{y}\right)\\ \stackrel{\color{blue}{[3]}}{=} & \left(\frac{b}{a}\right)^{1/4} e^{-2\sqrt{ab}} \int_0^{\infty} e^{-\sqrt{ab}\,z^2} dz\\ = & \left(\frac{b}{a}\right)^{1/4} e^{-2\sqrt{ab}} \frac{\sqrt{\pi}}{2(ab)^{1/4}}\\ = & \sqrt{\frac{\pi}{4a}} e^{-2\sqrt{ab}} \end{align} $$ Notes

  • $\color{blue}{[1]}$ substitute $x$ by $y = \sqrt{\frac{a}{b}} x$.
  • $\color{blue}{[2]}$ substitute $y$ by $\frac{1}{y}$ over the interval $[0,1]$.
  • $\color{blue}{[3]}$ substitute $y$ by $z = y - \frac{1}{y}$.

Before you use a differentiation under the integral sign it is suitable to do the following variable exchange: $x=\frac{t}{\sqrt{a}}$

$$I=\frac{1}{\sqrt{a}}\int_{0}^{+\infty}\!e^{(-t^2-\frac{s^2}{t^2})}\,dt;s^2=ab$$ Now, consider it as a function of $s$ and differentiate it with respect to $s$:

$$\frac{dI}{ds}=\frac{-2}{\sqrt{a}}\int_{0}^{+\infty}\frac{e^{(-t^2-\frac{s^2}{t^2})}}{t^2}sdt=\frac{-2}{\sqrt{a}}\int_{0}^{+\infty}e^{(-t^2-\frac{s^2}{t^2})}dt=-2I$$

So, to get an answer we need to solve the differential equation

$$\frac{dI}{ds}=-2I$$ and use the fact that

$$I(0)=\frac{1}{\sqrt{a}}\int_{0}^{+\infty}\!e^{-t^2}\,dt=\frac{1}{\sqrt{a}}\frac{\sqrt{\pi}}{2}$$


The integral can be evaluated as follows $$ \begin{align} \int_{x=0}^\infty \exp\left(-a\left(x^2+\frac{b}{ax^2}\right)\right)\,dx&=2\int_{x=0}^\infty \exp\left(-a\left(x^2-2\sqrt{\frac{b}{a}}+\frac{b}{ax^2}+2\sqrt{\frac{b}{a}}\right)\right)\,dx\\ &=\int_{x=0}^\infty \exp\left(-a\left(x-\frac{1}{x}\sqrt{\frac{b}{a}}\right)^2-2\sqrt{ab}\right)\,dx\\ &=e^{\large-2\sqrt{ab}}\int_{x=0}^\infty \exp\left(-a\left(x-\frac{1}{x}\sqrt{\frac{b}{a}}\right)^2\right)\,dx. \end{align} $$ The trick to solve the last integral is by setting $$ I=\int_{x=0}^\infty \exp\left(-a\left(x-\frac{1}{x}\sqrt{\frac{b}{a}}\right)^2\right)\,dx. $$ Let $t=-\frac{1}{x}\sqrt{\frac{b}{a}}\;\rightarrow\;x=-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;dx=\frac{1}{t^2}\sqrt{\frac{b}{a}}\,dt$, then $$ I_t=\sqrt{\frac{b}{a}}\int_{t=0}^\infty \frac{\exp\left(-a\left(-\frac{1}{t}\sqrt{\frac{b}{a}}+t\right)^2\right)}{t^2}\,dt. $$ Let $t=x\;\rightarrow\;dt=dx$, then $$ I_t=\int_{t=0}^\infty \exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt. $$ Adding the two $I_t$s yields $$ 2I=I_t+I_t=\int_{t=0}^\infty\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)\exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt. $$ Let $s=t-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;ds=\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)dt$ and for $0<t<\infty$ is corresponding to $-\infty<s<\infty$, then $$ I=\frac{1}{2}\int_{s=-\infty}^\infty e^{-as^2}\,ds=\frac{1}{2}\sqrt{\frac{\pi}{a}}. $$ Thus $$ \begin{align} \int_{x=0}^\infty \exp\left(-a\left(x^2+\frac{b}{ax^2}\right)\right)\,dx&=e^{\large-2\sqrt{ab}}\int_{x=0}^\infty \exp\left(-a\left(x-\frac{1}{x}\sqrt{\frac{b}{a}}\right)^2\right)\,dx\\ &=\frac{1}{2}\sqrt{\frac{\pi}{a}}e^{\large-2\sqrt{ab}}. \end{align} $$