Solution (source code)

= Solution

The function $e^{-z^2}$ is <entire>, so <Cauchy's integral theorem> makes its <contour integral> around the rectangle vanish. The lower horizontal integral tends to $\sqrt\pi$ by the <Gaussian integral>. On a vertical side $z=\pm R+it$, with $t$ between $0$ and $b$, its modulus is $e^{-R^2+t^2}\le e^{-R^2+b^2}$; hence both vertical integrals tend to zero. The upper side has the opposite orientation and contributes
$$
-e^{b^2}\int_{-\infty}^{\infty}e^{-x^2}e^{-2ibx}\,dx.
$$
Consequently the integral in this expression is $\sqrt\pi e^{-b^2}$. Its imaginary part vanishes because $e^{-x^2}\sin(2bx)$ is <odd>, and its real part is twice the positive-half-line integral because the integrand there is <even>. Therefore
$$
\boxed{\int_0^\infty e^{-x^2}\cos(2bx)\,dx=\frac{\sqrt\pi}{2}e^{-b^2}.}
$$
For negative $b$ the rectangle lies below the real axis and the same cancellation holds; alternatively use the even dependence on $b$.