# Need a smart way to numerically take residues in a multidimensional integral

I'm trying to do an integral of the form $\int_C f(u,v)$, where $C$ is a set of contours in $u$ and $v$. In particular, each variable's contour starts at $-\infty+i \epsilon$, goes around a branch cut at $-2g$ (where $g$ is a parameter of the problem), then goes below the real line and out to $-\infty-i \epsilon$ before circling around to $\infty-i \epsilon$, coming back around a branch cut at $2g$ and ending up at $\infty+i \epsilon$. If this description is a bit unclear, there's a drawing of the contour in Figure 5 of this paper.

$f(u,v)$ has poles when $u=v-2i$ and when $v=u-2i$. While the paper suggests integrating above the real axis and replacing the integration below the real axis with analytic residues around these poles, that method isn't feasible for the case I'm working on. Instead, I'm trying to integrate along this contour numerically.

The problem I'm having is that when I try to approximate the (infinite) contour with a finite one, I inevitably end up with a contour that crosses the poles, since the poles in each variable depend on the other one.

I suspect that there's a smarter way to approach all of this, but I can't find much literature on taking residues numerically at all, let alone anything applicable to this particular situation. Any recommendations would be appreciated!

Edit: One thing that I should clarify, I need to have fixed contours in $u$ and $v$, neither can depend on the other. If I had a different $v$ contour for each value of $u$ then taking the $v$ residues analytically would be faster, and I'm trying to get a speedup over doing that.

• Residues (and Laurent series coefficients) are just Fourier coefficients of the function restricted to a circle around the pole: $f(p+re^{i\theta}) = \sum a_k r^k e^{i k \theta}$, so simply evaluating the function on equally spaced points on a circle around a pole and using Fourier transform (not even FFT, probably) would give you the residue numerically. I remember reading a paper that estimated the optimal choice of $r$ for numerical stability. But I can't quite tell if this helps you, the double contour integral sounds more complicated. – Kirill Jun 15 '15 at 22:31
• Yeah, the tricky part here is the double contour. Any finite circle won't work, unless the circle in one variable is allowed to vary in the other variable (this is possible, but likely to be very inefficient in this particular case). That said, if you remember where that paper with the optimal choice for r was that might be handy. – Matt Jun 16 '15 at 15:11
• I can't find the exact reference, but citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.386.3031 Section 13 and the references there. – Kirill Jun 16 '15 at 22:59
• Another thought is, for a fixed $u$, to try to split integration over $v$ so that the intervals with poles can be computed numerically separately in a principal value sense. Sometimes this can be as simple as replacing $\int_{-a}^a f(x)\,dx$ with $\int_0^a (f(x)+f(-x))\,dx$. – Kirill Jun 17 '15 at 0:36
• Unfortunately, in order for this to be of any use efficiency-wise I need to have a fixed $v$ contour that's independent of $u$. I'll edit the OP to reflect this. – Matt Jun 17 '15 at 13:42