how do I calculate this integral or more generally how do I calculate:
$$\int _{-\infty}^{\infty} x^n\cos(2x)e^{-x^2}dx$$
I tried to use the following formulas that I'm familiar with:
i) $\displaystyle \int _{-\infty}^{\infty} x^ne^{-ax^2}dx=\begin{cases} \dfrac {(n-1)!!\sqrt \pi}{2^{n/2}a^{(n+1)/2}} &\mbox{if } n \text{ is even}\\0 &\mbox{if } n\text{ is odd}\end{cases}$
ii) $\displaystyle \int _{-\infty}^{\infty} \cos(ax)e^{-x^2}dx=\sqrt \pi e^{-\frac{a^2}{4}}$
and somehow integrate by parts but it didn't work. any suggestions?
Take the negative second derivative of your result in ii):
$$-\frac{d^2}{da^2} \int_{-\infty}^{\infty} dx \, \cos{a x} \, e^{-x^2} = \int_{-\infty}^{\infty} dx \, x^2 \cos{a x} \, e^{-x^2} $$
Because the integrals are convergent, the switching of the order of integration and differentiation is justified.