A improper integral Can someone tell me what is wrong with this I cant seem to find the error
\begin{eqnarray*}
\int_{-\infty}^{\infty} \frac{2x}{1+x^{2}} dx &=& \displaystyle\int_{-\infty}^{0} \frac{2x}{1+x^{2}} dx + \int_{0}^{\infty} \frac{2x}{1+x^{2}} dx  \\ 
&=& \lim_{a \rightarrow -\infty}\int_{a}^{0} \frac{2x}{1+x^{2}} dx + \lim_{b \rightarrow \infty}\int_{0}^{b} \frac{2x}{1+x^{2}} dx \\ 
&=& \lim_{a \rightarrow -\infty}\int_{1+a^{2}}^{1} \frac{du}{u} + \lim_{b \rightarrow \infty}\int_{1}^{1+b^{2}} \frac{du}{u} \\ 
&=& \lim_{a \rightarrow -\infty} \Big[ \ln u \Big]_{1+a^{2}}^{1} + \lim_{b \rightarrow \infty}\Big[ \ln u \Big]_{1}^{1+b^{2}} \\ & = & \Big[0-\ln (1+a^{2})\Big]_{a\rightarrow \infty}+\Big[ \ln (1+b^{2})-0 \Big]_{b\rightarrow \infty}  \\ &=& -\infty + -\infty.
\end{eqnarray*} 
which is an indeterminate form, but by definition of a convergent improper integral we can conclude that this integral is divergent. 
On the other hand
\begin{eqnarray*}
\int_{-\infty}^{\infty} \frac{2x}{1+x^{2}} dx &=& \lim_{a \rightarrow \infty}\int_{-a}^{a} \frac{2x}{1+x^{2}} dx \\ 
&=&  \lim_{a \rightarrow \infty} \Big[ \ln u \Big]_{1+a^{2}}^{1+a^{2}}   \\ &=& \lim_{a \rightarrow \infty} 0 = 0
\end{eqnarray*} 
 A: You have discovered conditional convergence.  You will also find that for this function,
$$
\lim_{a\to\infty} \int_{-a}^a \ne \lim_{a\to\infty} \int_{-a}^{2a\quad \longleftarrow \text{ “}2a\text{'', not “}a\text{''}}.
$$
This sort of thing happens only if the integral of the absolute value is infinite.  One has
$$
\int_{-\infty}^\infty \left| \frac{2x}{1+x^2} \right| \,dx = \infty. 
$$
When the integral of the absolute value is infinite, then the value of the integral can be changed by rearrangement.  Another example is this:
$$
\int_0^1\int_0^1 \frac{x^2-y^2}{(x^2+y^2)^2}\, \underbrace{ \, dx\,dy} \ne \int_0^1\int_0^1 \frac{x^2-y^2}{(x^2+y^2)^2}\, \underbrace{ \, dy\,dx} \quad (dx\,dy\  \text{ versus }\  dy\,dx)
$$
A: Your work is nearly all correct except for the last line in your first computation. The limits actually evaluate to $-\infty+\infty$.
The integral from $-\infty$ to $0$ diverges to $-\infty$ and the integral from $0$ to $\infty$ diverges to $\infty$. 
Since an integral diverges if any part diverges, your integral diverges (in this case $-\infty+\infty$ is indeterminate).
On the other hand your second calculation doesn't actually compute the value of the integral, but instead you have computed the Cauchy principal value (and you've computed it correctly -- it's zero).
If an integral converges, it will match its principal value. However, just because the principal value exists, does not mean that the integral's value does!
In general when computing improper integrals you need to be careful. I tell my students that "you can only approach one side of each bad spot at a time". Limits such as $-\infty$ and $\infty$ are always "bad spots" (maybe I should say "places you need to handle with care"). You need to deal with them one at a time. :)
