How to evaluate the following integral involving a gaussian?

Integrating by parts we get $-\frac 1 {2a^{2}} e^{-a^{2}x^{2}} \sin(px)|_0^{\infty}+ \frac p {2a^{2}}\int_0^{\infty} e^{-a^{2}x^{2}} cos(px)dx$. The first term is $0$ and the second term is the real part of a Gaussian characteristic function up to a constant factor.

The answer is $\frac {p\sqrt{\pi}} {4a^{3}} e^{-p^{2}/2a^{2}}$


Start with: $$I\left( p \right)=\int_{0}^{\infty }{\cos \left( px \right)\exp (-{{a}^{2}}{{x}^{2}})dx}$$ We can use differentiation under the integral sign:

$${I}'\left( p \right)=-\int_{0}^{\infty }{x\sin \left( px \right)\exp (-{{a}^{2}}{{x}^{2}})dx}$$ Integration by parts using $u=\sin \left( px \right)\quad and\quad dv=-x\exp \left( -{{a}^{2}}{{x}^{2}} \right)dx$ $${I}'\left( p \right)=\left. \sin \left( px \right)\frac{\exp \left( -{{a}^{2}}{{x}^{2}} \right)}{2{{a}^{2}}} \right|_{0}^{\infty }-\frac{p}{2{{a}^{2}}}\int_{0}^{\infty }{\cos \left( px \right)\exp \left( -{{a}^{2}}{{x}^{2}} \right)dx}$$ The first term on the right vanishes, and we have the first-order differential equation: $$\frac{{I}'\left( p \right)}{I\left( p \right)}=-\frac{p}{2{{a}^{2}}}\Rightarrow \ln \left( I\left( p \right) \right)=-\frac{{{p}^{2}}}{4{{a}^{2}}}+C$$ Using $$I\left( 0 \right)=\frac{\sqrt{\pi }}{a}$$ We can find $C=\ln \left( \frac{\sqrt{\pi }}{a} \right)$ hence $$\ln \left( I\left( p \right) \right)=-\frac{{{p}^{2}}}{4{{a}^{2}}}+\ln \left( \frac{\sqrt{\pi }}{a} \right)$$ So $$I\left( p \right)=\frac{\sqrt{\pi }}{a}\exp \left( -\frac{{{p}^{2}}}{4{{a}^{2}}} \right)$$ Finally the integral in question equals $$-{I}'\left( p \right)=-\frac{d}{dp}\left( \frac{\sqrt{\pi }}{a}\exp \left( -\frac{{{p}^{2}}}{4{{a}^{2}}} \right) \right)$$


$$ \begin{align} \int_0^\infty x\sin{px}\exp{(-a^2x^2)}\ dx & =\int_0^\infty x\sum_{n\geq0}\dfrac{(-1)^n(px)^{2n+1}}{(2n+1)!}\exp{(-a^2x^2)}\ dx \\ & =\sum_{n\geq0}\dfrac{(-1)^np^{2n+1}}{(2n+1)!}\int_0^\infty x^{2n+2}\exp{(-a^2x^2)}\ dx \\ & =\sum_{n\geq0}\dfrac{(-1)^np^{2n+1}}{(2n+1)!}\dfrac{1}{2a^{2n+3}}\int_0^\infty u^{n+\frac12}e^{-u}\ du ~~~;~~~{a^2x^2=u}\\ & =\sum_{n\geq0}\dfrac{(-1)^np^{2n+1}(2n+2)}{\Gamma(2n+3)}\dfrac{1}{2a^{2n+3}}\Gamma(n+\frac32)\\ & =\sum_{n\geq0}\dfrac{(-1)^np^{2n+1}(2n+2)}{2^{2n+2}\sqrt{\pi}^{-1}\Gamma(n+2)\Gamma(n+\frac32)}\dfrac{1}{2a^{2n+3}}\Gamma(n+\frac32)\\ & =\sqrt{\pi}\sum_{n\geq0}\dfrac{(-1)^np^{2n+1}}{2^{2n+2}}\dfrac{1}{2a^{2n+3}}\\ & =\sqrt{\pi}\dfrac{p}{4a^3}\sum_{n\geq0}\left(\dfrac{-p^2}{4a^2}\right)^n\dfrac{1}{n!}\\ & =\sqrt{\pi}\dfrac{p}{4a^3}\exp\left(\dfrac{-p^2}{4a^2}\right) \end{align} $$