In my research I use (or at least try to) some tools of complex analysis in order to evaluate infinite series arising from expressions involving the eigenvalues of an elliptic operator. The key ingredient is to use Cauchy's Residue Theorem (or equivalently Argument Principle) to rewrite a sum as a contour integral in the complex plane.

Both incarnations basically state that it is possible to evaluate the closed integral of a meromorphic function just by looking at the residues that the contour encloses.

If we have a function $f(z)$ holomorphic in a region $U\backslash\{z_0\}$ with a simple pole at $z=z_0$, then the integral

$\int_\gamma f(z)dz$

fails to be zero just in its imaginary part. In some sense $f(z)$ provides a conservative field up to a phase. Namely, one can think of the pole inside $\gamma$ to be like a

*source*of the field, and hence the failure of the integral to be zero. Since the integral only contributes with an imaginary part, it is possible to think that this constitutes something like a Berry phase, since it is proportional to the angle that the contour goes around the pole and the residue (*charge*) of it.
For instance, in the configuration on the left the contour makes an angle of $2\pi$ around the pole, while on the right it make only an angle of $\pi$ (if the contour is differentiable at the pole). If the pole lies on the contour, then the angle will be the difference of the angles made by the two tan gets at the point (the limit from the left and the right). In the case of a smooth contour, the only difference in both tangents is their direction, hence the angle of $\pi$.

If we denote by $\alpha(\gamma,z)$ the overall angle made by when we span the lines joining the point $z$ with points in $\gamma$, then we have a more general version of Cauchy's residue theorem

$\int_\gamma f(z)dz=\alpha(\gamma,z_0)\text{ Res }(f(z),z_0) i$

Note that for this result it is not needed for the contour $\gamma$ to be smooth, and it provides an extension of the usual residue theorem that uses the winding number.

If the contour $\gamma$ is finite, it is customary to understand for the

*inside*of the contour to be the bounded pieces of the plane delimited by $\gamma$, but whenever we deal with infinite contour (e.g. a line) it is not so clear.
In the first place, this result is valid only for bounded contours, so why bother with the infinite ones? If we extrapolate this results to the Riemann sphere, dealing with infinite contours make sense, since they constitute great circles on the sphere. So in order to extend this to the Riemann sphere it is necessary to get rid of the ambiguity of what we understand for the

*inside*of a contour. Or perhaps it is not.
Following a little bit more the physical analogy for this result, one can also think that something like a

*conservation*of charges might happen. In this case, the integral will give the same answer with any convention of*inside*only up to a sign difference. As the integral over a closed path in a region where the function is holomorphic is always zero, one could think of the*total charge*of the complex plane (or Riemann sphere) to be zero.
For this reason, it is usual to define the residue of a function at infinity to be such that the sum of all the residues of the function give zero, including the residue at infinity. Hence the negative sign in its definition

$\text{ Res }(f(z),\infty)=-\text{ Res }\left(\frac{1}{z^2}f\left(\frac{1}{z}\right),0\right)$

and the residue theorem for infinite contours (or equivalently for the Riemann sphere) reads

$\int_\gamma f(z)dz =i \sum_{\text{ poles }}\alpha(\gamma,w) \text{ Res }(f(z),w)$

where the poles $w$ can include residue at infinity.

Therefore expression like

$\int_{-i\infty}^{i\infty} \frac{1}{z-1}dz$

can be evaluated using the residue theorem without any ambiguity on to which half plane to look for residues. As the function $f(z)=\frac{1}{z-1}$ has a residue at infinity of $-1$ and the contour $\gamma$ passes through infinity, this residue only contributes with $(\pi)(-1)$ to the integral. Choosing the convention of inside meaning to be to the left of the contour, it is just needed to analyze the left half plane. Thus this integral gives

$\int_{-i\infty}^{i\infty} \frac{1}{z-1}dz=-\pi i$

When grabbing the right half plane, we have to include the residue at $z=1$, but we have to change sign to the integral, hence it will give

$\int_{-i\infty}^{i\infty} \frac{1}{z-1}dz=-i\alpha(\gamma, 1)\text{ Res }(f(z),1)-i\alpha(\gamma, \infty)\text{ Res }(f(z),\infty)$

$=-2\pi i+\pi i=-\pi i$