# Residue theorem and a two-dimensional integral: not working?

Consider the following integral: \begin{align} \iint_{\mathbb{R}^2}d t\,dT\, \frac{e^{-i(t-T)}e^{-t^2}e^{-{T}^2}}{(t-T-i\epsilon)^2}\,. \end{align} The $$i\epsilon$$ prescription simply tells me that if I were to do this as a contour integral, I should deform the contour slightly from the real line to the lower complex plane near the poles.

Consider the following solution: since the integrand has a pole at $$t=T$$ for any given fixed $$T$$, using the residue theorem I get $$$$\int_{-\infty}^\infty\,dT \left(-2\pi i\right)\text{Res}(e^{-i(t-T)}e^{-t^2}e^{-{T}^2};T) = 2\pi i\int_{-\infty}^\infty dT\,e^{-2T^2}(i+2T) = -\pi\sqrt{2\pi}\,.$$$$ The minus sign follows from the fact that the residue is computed anti-clockwise due to the contour orientation. It can be shown that this is in fact wrong, and the right answer is $$$$\frac{\pi ^{3/2} \text{erfc}\left(\frac{1}{\sqrt{2}}\right)}{\sqrt{2}}-\frac{\pi }{\sqrt{e}}\,.$$$$ This is surprising to me at first, because the numerator looks very harmless and the denominator looks like a very standard second-order pole. The reason I know this is wrong is because there are ways to do this without this technique (in fact, I know two ways to do this, one by some coordinate transformation $$y=t-T,x=t+T$$, and another one numerically --- and I have two ways to do numerically) and show that the residue method above does not work. Curiously enough, if the denominator were instead $$(t-T-C)^2$$ where $$C$$ is a constant, it seems to work.

Would appreciate if there is a transparent explanation on what has gone wrong (or stupid mistakes I should have noticed).

P.S. This question started me thinking whether contour integration can be used as a larger embedded techniques in multidimensional integrals, i.e. using it as part of multi-dimensional integral without reducing the multidimensional integral to single-variable one (e.g. often the case if there is spherical symmetry); even in physics, for example, often contour integrals are only used once you reduce a particular integral to a simple, manageable integral that look amenable to standard complex analysis techniques.