Evaluating $ \int_{-\infty}^{+\infty} \frac{2x}{x^2+1} \,\mathrm{d}x$ in two ways gives different results Let's have the improper integral
$$ \int_{-\infty}^{+\infty} \frac{2x}{x^2+1} \,\mathrm{d}x  = \int_{-\infty}^{0} \frac{2x}{x^2+1}  \,\mathrm{d}x  + \int_{0}^{+\infty} \frac{2x}{x^2+1} \,\mathrm{d}x. $$
Since
$$ \int_{0}^{+\infty} \frac{2x}{x^2+1}  \,\mathrm{d}x = \int_{0}^{+\infty} \frac{1}{u+1}  \,\mathrm{d}u = \lim_{b\to\infty} \ln\lvert b+1\rvert - \ln\lvert 0+1 \rvert = \infty, $$
we can say that the integral from $-\infty$ to $\infty$ is divergent.
However, if we do
$$ \lim_{b\to\infty} \int_{-b}^{b} \frac{2x}{x^2+1} \,\mathrm{d}x = \lim_{b\to\infty} \ln \lvert b+1 \rvert -\ln\lvert -b+1\rvert = \lim_{b\to\infty} \ln\left\lvert \frac{b+1}{-b+1}\right\rvert = \ln \lvert -1\rvert = 0, $$
the integral is convergent.
How to explain these two different results?
 A: Because $$\lim\limits_{b\to\infty} \int_{-b}^b f(x)\,\mathrm d x$$ and $$\int_{-\infty}^\infty f(x) \,\mathrm dx$$ are not the same thing.
The short, intuitive answer is that you can approach $-\infty$ and $\infty$ differently. For example, you would also have to look at
$$\lim\limits_{b\to \infty} \int_{-b^2}^b f(x)\,\mathrm dx $$
and in general any way where the paths go to $-\infty$ and $\infty$. We say that
$$\int_{-\infty}^\infty f(x)\,\mathrm d x $$
converges (to $L$) if for any two sequences $a_n \to-\infty$ and $b_n\to \infty$ the limit
$$\lim\limits_{n\to\infty} \int_{a_n}^{b_n} f(x)\,\mathrm d x = L$$
exists and equals $L$.
A: The same thing occurs with $\int_{-\infty}^\infty x\,\mathrm dx$. This is why the definition of $\int_{-\infty}^\infty f(x)\,\mathrm dx$ involves the integrals $\int_a^\infty f(x)\,\mathrm dx$ and $\int_{-\infty}^af(x)\,\mathrm dx$ (the choice of $a$ doesn't matter): to avoid problems such as this one.
A: As it is written, the integral is undefined (see Eff's answer). However, its Cauchy principal value 
$$\lim_{b \to +\infty} \int_{-b}^b \frac{2x}{1+x^2}\, \mathrm{d}x$$
vanishes, as the function is odd.
A: If
$$
\int_{-\infty}^\infty\left|\frac{2x}{x^2+1}\right|\,\mathrm{d}x
$$
converges, then
$$
\int_{-\infty}^\infty\frac{2x}{x^2+1}\,\mathrm{d}x
$$
is said to converge absolutely, and we can break up the domain of integration in any way we want and add the pieces back together and get the same result.
The limit
$$
\lim_{b\to\infty}\int_{-b}^b\frac{2x}{x^2+1}\,\mathrm{d}x
$$
is often called the Cauchy Principal Value.  It exists in some cases where the integral is not absolutely convergent.
Since this integral is not absolutely convergent we can send the two limits to infinity at different rates in such a way as to get any limit desired.
