TITLE: Using the Residue Theorem for a contour integral along the Riemann sphere
QUESTION [7 upvotes]: Given the integral $\int_{-\infty}^{\infty}\frac{x}{x^2+1}dx,$ we can clearly see this is the integral of an odd function with limits which are symmetric about the origin, and thus its integral is zero.
However, if I treat this as a curve along the real axis on the Riemann sphere (since the function is zero at infinity), then I can consider the interior of the curve to be the upper-half of the complex plane where it has a single singularity of order $1$ at $i$.  Thus, applying the residue theorem, I obtain:
$$\int_{-\infty}^{\infty}\frac{x}{x^2+1}dx = 2\pi i\lim_{x\rightarrow i}(x-i)\frac{x}{(x-i)(x+i)} = 2\pi i\frac{i}{2i} = \pi i\neq 0.$$
Clearly I'm doing something wrong, can someone explain to me my misconception(s)?
Thanks

REPLY [2 votes]: The integral is zero.  The closed contour integral should equal $i\pi$ but the integral over the semi circle is not zero.  Set $x=r\text{e}^{i\theta}$, and $0\leq \theta \leq \pi$, and $r\rightarrow \infty$.  Then $dx = ir\text{e}^{i\theta} d\theta$, integrate over theta from 0 to $\pi$, and remember $\frac{1}{1+\Delta} = 1 -\Delta + \Delta^2 - \Delta^3...$ and you will find the integral over the arc equals $i\pi$.  Since the total integral should also equal $i\pi$ the intgral along the real x axis is zero as for ALL ODD FUNCTIONS.  Infinity may be defined differently but you should just do the integral for symmetric cases, instead of giving up because the question wasnt framed unmistakably.