Using the Residue Theorem for a contour integral along the Riemann sphere 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
 A: It is not true that the integral from -∞ to ∞ of odd function is always 0.
The upper half plane method is not applicable in this question because the integral along the circle with radius appoaching infinity is not 0.
So basicly both of your approaches are incorrect. This integral is the expected value of t(lamda)-distribution with lamda = 1, which is not defined.
A: This is my understanding. 
Although $\frac{x}{x^2+1}$ is well behaved at $x = \infty$, $dx$ isn't.
This is because $x$ itself cannot be used as a complex coordinate
on neighborhood of $x = \infty$ of the Riemann sphere.
Let us look at the same integral using a proper complex coordinate $z = \frac{1}{x}$ 
there. We have:
$$\frac{xdx}{x^2+1} \to -\frac{dz}{z(z^2+1)}$$
A $\frac{1}{z}$ singularity becomes apparent in the new coordinate. To properly use the Cauchy Integral theorem, we cannot complete the contour directly at $z = 0$. Instead, we have to circle around it with a small half circle (clockwisely). The contour integral pick up a factor $\pi i = -(-\pi i)$ from this small half circle around $z = 0$ from the $-\frac{1}{z}$ pole. 
Translating this back into $x$ world, we cannot complete the contour directly at $x = \infty$. Instead, we have to circle around it with a large half circle  (counter-closewisely w.r.t the origin). Since the integrand $\frac{x}{x^2+1}$ doesn't go to $0$ fast enough, the integral pick up a factor $\pi i$ from the large half circle.
A: 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.
A: I think the cheating is that
$$\int_0^\infty \frac x{x^2+1}=+\infty$$
does not converge, and the symmetry manipulation just yields $\infty-\infty$ then, which is undefined.
