Suppose we want to give a meaning to the divergent integral $$I = \int_{-\infty }^{\infty } \frac{x}{x^2+1} \, dx,$$ perhaps in the sense of distributions or something (similarly to how $\int_{-\infty }^{\infty } x e^{i k x} dx$ can be given meaning as the derivative of the delta function).
Because the integrand is odd, it seems sensible to say $I = 0$. But for all $a$ for which the integral converges, $$I = \int_{-\infty }^{\infty } \frac{x^{a-1}}{x^2+1} \, dx = \frac{1}{2} \pi \left( 1 -(-1)^a\right) \csc \left(\frac{\pi a}{2}\right).$$
Analytically continuing this to $a = 2$ gives $I = \pi i$. Added: $$\lim \limits_{\epsilon \rightarrow 0} \int_{-\infty }^{\infty } \frac{x \, e^{i \epsilon x}}{x^2+1}dx = \pi i.$$ I cannot justify switching integral and limit...
Is there a unique and 'useful' way to give a meaning to $I$ in some mathematically rigorous sense?
By the $\Gamma$ reflection formula it follows that: $$I(a)=\int_{-\infty}^{+\infty}\frac{x^{a-1}}{x^2+1}\,dx = \pi\sin\frac{\pi a}{2}$$ for any $a$ in the strip $0<\Re(a)<2$, so the analytic continuation gives $I(2)=0$, as expected.