I want to calculate the integral $$\int_{-\infty}^{\infty} x^2 \cos(ax)e^{-x^2}dx$$ using complex analysis. I have a hint to look at the rectangle $(-R,0), (R,0), (R,h), (-R,h)$ for a certain $h>0$, and use the function $f(z)=z^2e^{az}e^{-z^2}$.
So I wrote down the following paths in order to try using Chauchy's theorem: $$\gamma_1(t) = t \hspace{1cm} t \in [-R,R]\\ \gamma_2(t) = R + iht \hspace{1cm} t \in [0,1]\\ \gamma_3(t) = -t + ih \hspace{1cm} t \in [-R,R]\\ \gamma_1(t) = -R + ih(1-t) \hspace{1cm} t \in [0,1]$$
Now I get $$\int_{\gamma_1} f(z)dz = \int_{-R}^{R} x^2 \cos(ax)e^{-x^2}dx$$ which is good because if I can calculate the other three integrals, I can send $R$ to $\infty$ and apply Cauchy's theorem.
But how do I calculate integrals like the following? $$\int_{\gamma_2} f(z)dz = \int_{0}^{1} f(R+iht)(ih)dt$$
Here are some useful things to look out for in the integrals: symmetry properties (some parts are zero because the function is anti-symmetric), Gaussian integrals, chosing $h$ such that difficult parts cancel.