How to evaluate this improper integral $\int_{-\infty}^\infty x^2 e^{-x^2}\cos x \, dx$? How to evaluate
$$
\int_{-\infty}^{\infty} x^2 e^{-x^2} \cos x \, dx?
$$
My Attempt:

Since the integrand is an even function, we have
$$
\int_{-\infty}^{\infty} x^2 e^{-x^2} \cos x \, dx = 2 \int_0^{\infty} x^2 e^{-x^2} \cos x \, dx. \tag{1} 
$$


Since $-1 \leq \cos x \leq 1$ and $x^2 e^{-x^2} > 0$ for all $x$ such that $0 \leq  x < \infty$, we have
$$
-x^2 e^{-x^2} \leq x^2 e^{-x^2} \cos x \leq x^2 e^{-x^2},
$$
which implies
$$
-\int_0^{\infty} x^2 e^{-x^2} \, dx \leq \int_0^{\infty} x^2 e^{-x^2} \cos x \, dx \leq \int_0^{\infty} x^2 e^{-x^2} \, dx, 
$$
and hence
$$
-2 \int_0^{\infty} x^2 e^{-x^2} \, dx \leq 2 \int_0^{\infty} x^2 e^{-x^2} \cos x \, dx \leq 2 \int_0^{\infty} x^2 e^{-x^2} \, dx.
$$

Now if we can show that
$$
\int_0^{\infty} x^2 e^{-x^2} \, dx = 0, 
$$
then would obtain
$$
\int_{-\infty}^{\infty} x^2 e^{-x^2} \cos x \, dx = 0.
$$
[ Refer to (1) above.]
Am I right? If so, then what next? How to proceed?
Or, is there another better way around this problem?

How to solve!
The actual result is different:
$$ \int_{-\infty}^{\infty} x^{2} \cdot e^{-x^{2}} \cdot \cos(x) ~ \mathrm{d}x = \frac{\sqrt{\pi}}{4 \cdot \sqrt[4]{e}} \approx 0.345097 $$
The easiest way to solve the problem would be to form one od the antiderivatives:
(You can easily do this by relating the trigonometric functions to the exponential functions:
$$ \cos(x) = \frac{e^{x \cdot \mathrm{i}} + e^{-x \cdot \mathrm{i}}}{2} $$
$$ \int x^{2} \cdot e^{-x^{2}} \cdot \cos(x) ~ \mathrm{d}x = \dfrac{\mathrm{e}^{-\frac{1}{4}}\cdot\left(\sqrt{{\pi}} \cdot \operatorname{erf}\left(x+\frac{\mathrm{i}}{2}\right)+\sqrt{{\pi}} \cdot \operatorname{erf}\left(x-\frac{\mathrm{i}}{2}\right)\right)}{16}+\dfrac{\mathrm{e}^{-x^2}\cdot\left(\sin\left(x\right)-2 \cdot x \cdot \cos\left(x\right)\right)}{4} $$
or
$$ \int x^{2} \cdot e^{-x^{2}} \cdot \cos(x) ~ \mathrm{d}x = 
\dfrac{\frac{\mathrm{e}^{-\frac{1}{4}}\mathrm{i}\cdot\left(\frac{\mathrm{i}\operatorname{\Gamma}\left(\frac{1}{2},\frac{\left(\mathrm{i}-2x\right)^2}{4}\right)\left(\mathrm{i}-2x\right)}{4\sqrt{\left(\mathrm{i}-2x\right)^2}}-\frac{\mathrm{i}\operatorname{\Gamma}\left(\frac{3}{2},\frac{\left(\mathrm{i}-2x\right)^2}{4}\right)\left(\mathrm{i}-2x\right)^3}{\left(\left(\mathrm{i}-2x\right)^2\right)^\frac{3}{2}}-\operatorname{\Gamma}\left(1,\frac{\left(\mathrm{i}-2x\right)^2}{4}\right)\right)}{2}+\frac{\mathrm{e}^{-\frac{1}{4}}\mathrm{i}\cdot\left(\frac{\mathrm{i}\operatorname{\Gamma}\left(\frac{1}{2},\frac{\left(-2x-\mathrm{i}\right)^2}{4}\right)\left(-2x-\mathrm{i}\right)}{4\sqrt{\left(-2x-\mathrm{i}\right)^2}}-\frac{\mathrm{i}\operatorname{\Gamma}\left(\frac{3}{2},\frac{\left(-2x-\mathrm{i}\right)^2}{4}\right)\left(-2x-\mathrm{i}\right)^3}{\left(\left(-2x-\mathrm{i}\right)^2\right)^\frac{3}{2}}+\operatorname{\Gamma}\left(1,\frac{\left(-2x-\mathrm{i}\right)^2}{4}\right)\right)}{2}}{2} $$
(calculated by Integralrechner, wich shows a step by step solution too)
or
$$ \int x^{2} \cdot e^{-x^{2}} \cdot \cos(x) ~ \mathrm{d}x = \frac{(\frac{\sqrt{\pi} \cdot \operatorname{erf}(\frac{2 \cdot x + \mathrm{i}}{2})}{\sqrt[4]{e}} - \frac{\mathrm{i} \sqrt(\pi) \operatorname{erfi}\frac{1}{2} + \mathrm{i} \cdot x)}{\sqrt[4]{e}} - 2 e^{-x \cdot (x + \mathrm{i})} \cdot (2 x + e^{2 \cdot \mathrm{i} \cdot x} (2 \cdot x + \mathrm{i}) - \mathrm{i}))}{16} + constant $$
(calculated by Wolfram|Alpha)
or
...
Now you have to form limes with from x to infinity and x to -infinity of you're formula and you will get you're sulution! (as shown above)
$$ \int_{-\infty}^{\infty} x^{2} \cdot e^{-x^{2}} \cdot \cos(x) ~ \mathrm{d}x = \lim_{{x} \to {\infty}} (\dfrac{\mathrm{e}^{-\frac{1}{4}}\cdot\left(\sqrt{{\pi}} \cdot \operatorname{erf}\left(x+\frac{\mathrm{i}}{2}\right)+\sqrt{{\pi}} \cdot \operatorname{erf}\left(x-\frac{\mathrm{i}}{2}\right)\right)}{16}+\dfrac{\mathrm{e}^{-x^2}\cdot\left(\sin\left(x\right)-2 \cdot x \cdot \cos\left(x\right)\right)}{4}) - \lim_{{x} \to {-\infty}} (\dfrac{\mathrm{e}^{-\frac{1}{4}}\cdot\left(\sqrt{{\pi}} \cdot \operatorname{erf}\left(x+\frac{\mathrm{i}}{2}\right)+\sqrt{{\pi}} \cdot \operatorname{erf}\left(x-\frac{\mathrm{i}}{2}\right)\right)}{16}+\dfrac{\mathrm{e}^{-x^2}\cdot\left(\sin\left(x\right)-2 \cdot x \cdot \cos\left(x\right)\right)}{4})$$
