Gaussian type integral $\int_{-\infty}^{\infty} \frac{\mathrm{e}^{-a^2 x^2}}{1 + x^2} \mathrm{d}x$

Let $F$ be the function $$F(a)=\int_{-\infty}^{\infty}\frac{e^{-a^{2}x^{2}}}{1+x^2}dx$$ We take the derivative w.r.t $a$ $$F^{\prime}(a)=\frac{d}{da}\left(\int_{-\infty}^{\infty}\frac{e^{-a^{2}x^{2}}}{1+x^2}dx\right)=\int_{-\infty}^{\infty}\frac{d}{da}\left(\frac{e^{-a^{2}x^{2}}}{1+x^2}\right)dx =\int_{-\infty}^{\infty}\frac{-2ax^{2}e^{-a^{2}x^{2}}}{1+x^2}dx$$ $$=\int_{-\infty}^{\infty}\frac{-2a\big((x^{2}+1)-1\big)e^{-a^{2}x^{2}}}{1+x^2}dx =-2a\int_{-\infty}^{\infty}e^{-a^{2}x^{2}}dx+2aF(a) =-2a\sqrt{\frac{\pi}{a^2}}+2aF(a)$$ Then $$F^{\prime}(a)=2a\left(F(a)-\sqrt{\pi}\,\frac{1}{\vert{a}\vert}\right) =2aF(a)-2\sqrt{\pi}\mathrm{sign}(a).$$ Then you have a differential equation: $$ F^{\prime}(a)-2a\,F(a)=-2\sqrt{\pi}\mathrm{sign}(a) $$ with initial condition $F(0)=\pi$. This fisrt order ode has integrant factor: $$\mu(a)=\displaystyle{e^{\displaystyle{\int{-2ada}}}}=e^{-a^2}$$ Then $$ \left(e^{-a^2}F(a)\right)^{\prime}=-2\sqrt{\pi}\mathrm{sign}(a) e^{-a^2} $$ this implies $$ e^{-a^2}F(a)=-2\sqrt{\pi}\int{\mathrm{sign}(a) e^{-a^2}}da+C $$ Finaly $$F(a)=e^{a^2}\left(C-2\sqrt{\pi}\mathrm{sign}(a)\int{e^{-a^2}da}\right)$$


Let $f(a)=\int_{-\infty}^\infty \frac{e^{-a^2x^2}}{1+x^2}\,dx$. Then, we have

$$\begin{align} f(a)&=2\int_0^\infty e^{-a^2x^2}\int_0^\infty e^{-s(1+x^2)}\,ds\,dx\\\\ &=2\int_0^\infty e^{-s}\int_0^\infty e^{-(s+a^2)x^2}\,dx\,ds\\\\ &=\int_0^\infty e^{-s} \frac{\sqrt{\pi}}{\sqrt{s+a^2}}\,ds\\\\ &=\sqrt{\pi}e^{a^2}\int_0^\infty \frac{e^{-(s+a^2)}}{\sqrt{s+a^2}}\,ds\\\\ &=\sqrt{\pi}e^{a^2}\int_{a^2}^\infty \frac{e^{-t}}{\sqrt t}\,dt\\\\ &=2\sqrt{\pi}e^{a^2}\int_{|a|}^\infty e^{-u^2}\,du\\\\ &=\pi e^{a^2}\text{erfc}(|a|) \end{align}$$


Here is another approach where we first make use of an auxiliary function.

Before proceeding we recall the definitions for the error function $\text{erf}(x)$ and the complementary error function $\text{erfc}(x)$: $$\text{erf}(x) = \frac{2}{\sqrt{\pi}} \int^x_0 e^{-t^2} \, dt$$ and $$\text{erfc}(x) = \frac{2}{\sqrt{\pi}} \int^\infty_x e^{-t^2} \, dt,$$ respectively such that $$\text{erf}(x) = 1 - \text{erfc}(x).$$

The idea here is to consider an auxiliary function, related to our function of interest $f(a)$, but which turns our to be a constant function for all $a$ in its domain.

Start by considering the following auxiliary function \begin{equation} I(a) = \left (\int^a_0 e^{-t^2} \, dt \right )^2 + \int^1_0 \frac{e^{-a^2 (t^2 + 1)}}{1 + t^2} \, dt, \,\, a > 0. \tag1 \end{equation} Note the term appearing between the brackets is nothing more than the error function. On differentiating the auxiliary function with respect to $a$ we obtain $$I'(a) = 2 e^{-a^2} \int^a_0 e^{-t^2} \, dt - 2a e^{-a^2} \int^1_0 e^{-a^2 t^2} \, dt.$$ In obtaining this result, Leibniz' rule for differentiating under the integral sign has been used. In the second integral, if a substitution of $u = at$ is made, the result $I'(a) = 0$ quickly follows showing the auxiliary function is indeed constant for all $a > 0$. To find the value for this constant, letting $a \to 0^+$ gives $$I(a) \to \int^1_0 \frac{dt}{1 + t^2} = \frac{\pi}{4},$$ so that $I(a) = \pi/4$ for all $a > 0$.

As the first of the integrals appearing in (1) can be written in terms of the error function we have \begin{equation} \int^1_0 \frac{e^{-a^2 (t^2 + 1)}}{1 + t^2} \, dt = \frac{\pi}{4} \left (1 - \text{erf}^2 (a) \right ). \tag2 \end{equation}

A similar thing can be done for the complementary error function. In this case we start by considering the following auxiliary function \begin{equation} J(a) = \left (\int^\infty_a e^{-t^2} \, dt \right )^2 - \int^\infty_1 \frac{e^{-a^2 (t^2 + 1)}}{1 + t^2} \, dt, \,\, a > 0. \tag3 \end{equation} Again observe the term appearing between the brackets in nothing more than the complementary error function. On differentiating with respect to $a$ we have $$J'(a) = -2 e^{-a^2} \int^\infty_a e^{-t^2} \, dt + 2a e^{-a^2} \int^\infty_1 e^{-a^2 t^2} \, dt.$$ A substitution of $u = at$ in the second integral once again reduces the derivative of the auxiliary function to zero, showing $J(a)$ is constant. Letting $a \to \infty$ in (3) we see $J(a) \to 0$. Thus $J(a) = 0$ for all $a > 0$. Writing the first of the integrals in (3) in terms of the complementary error function, one finds \begin{equation} \int^\infty_1 \frac{e^{-a^2 (1 + t^2)}}{1 + t^2} \, dt = \frac{\pi}{4} \text{erfc}^2 (a). \tag4 \end{equation}

Adding (2) to (4) yields \begin{align*} \int^\infty_0 \frac{e^{-a^2(1 + t^2)}}{1 + t^2} \, dt &= \frac{\pi}{4} \left [\text{erfc}^2 (a) + 1 - \text{erf}^2 (a) \right ]\\ &= \frac{\pi}{4} \left [\text{erfc}^2 (a) + 1 - (1 - \text{erfc}(a))^2 \right ]\\ &= \frac{\pi}{2} \text{erfc} (a). \end{align*} Rearranging gives $$e^{-a^2} \int^\infty_0 \frac{e^{-a^2 t^2}}{1 + t^2} \, dt = \frac{\pi}{2} \text{erfc}(a),$$ or $$\int^\infty_0 \frac{e^{-a^2 t^2}}{1 + t^2} \, dt = \frac{\pi}{2} e^{a^2} \text{erfc}(a).$$

So for $f(a)$ we finally have $$f(a) = 2 \int^\infty_0 \frac{e^{-a^2 t^2}}{1 + t^2} \, dt = \pi e^{a^2} \text{erfc}(a), \quad a > 0.$$