Whether the integral is converging or diverging. $\int_{-\infty} ^{ \infty} \frac{x \ dx}{x^2+1}$ Find whether the integral is converging or diverging.
$\int_{-\infty} ^{ \infty} \frac{x \ dx}{x^2+1}$
My solution:
$\int_{-\infty} ^{ \infty} \frac{x \ dx}{x^2+1} = \int_{-\infty} ^{ 0} \frac{x \ dx}{x^2+1} + \int_{0} ^{ \infty} \frac{x \ dx}{x^2+1}$
Now if in the first part if I substitute $t=-x $  and $ dt=-dx$ and then I swap the limits the equation becomes $ - \int_{0} ^{ \infty} \frac{t \ dt}{t^2+1} + \int_{0} ^{ \infty} \frac{x \ dx}{x^2+1}$. Now I can just replace $t$ with $ x$ and the whole thing becomes $0$. Therefore it is converging.
The solution:
The solution says diverging. The inegrals were found with respect to a placeholder $eg. R $ and then the limit of $R$ to $\infty$ was put. And hence we get $log\ \infty$ which is $ \infty$ which is divergent.
My question is:  Why is there a difference in solutions between both the approaches ?  Can I not add integrals like I did in the final step when infinity is involved ? And in the log method, I shall get one integral as $+ \infty$ and the other as $- \infty$ so wouldn't the whole thing still be zero ?
 A: By definition, this is an improper Riemann integral. Your integral exists if BOTH of the following limits exist
$$\lim_{a\rightarrow \infty}\int_{0}^{a}\frac{x}{1+x^2}dx,\qquad
\lim_{b\rightarrow -\infty}\int_{b}^{0}\frac{x}{1+x^2}dx$$
Neither of these limits exist (the non-existence of one limit is enough to
conclude the non-existence of the integral). The first limit
is
$$\lim_{a\rightarrow \infty}\int_{0}^{a}\frac{x}{1+x^2}dx=\frac{1}{2}
\lim_{a\rightarrow \infty} \log(1+a^2)=\infty.$$
Similarly
$$\lim_{b\rightarrow -\infty}\int_{b}^{0}\frac{x}{1+x^2}dx=-\frac{1}{2}
\lim_{b\rightarrow \infty} \log(1+b^2)=-\infty.$$
What you are trying to compute is the principal value of the integral which is indeed zero.
$$P.V.\int_{-\infty}^{\infty}\frac{x}{1+x^2}dx= \lim_{a\rightarrow \infty}\int_{-a}^{a}\frac{x}{1+x^2}dx=
\lim_{a\rightarrow \infty}(\log(1+a^2)-\log(1+a^2))=0
$$
where $P.V.$ stands for the principal value of the integral.
Another typical example is the integral $\int_{-1}^{1}\frac{dx}{x}$
which does not exist but has principal value, also zero.
A: To highlight the main problem, let me introduce a simpler problem. Let $(a_n)$ be the sequence
$$
a_n = 
\begin{cases}
1 & \text{for } n = 1,2,3,\ldots, \\
-1 & \text{for } n = -1,-2,-3,\ldots, \\
0 & \text{for } n = 0.
\end{cases}
$$
The infinite sum $\sum_{n \in \mathbb{Z}} a_n$ is divergent. However, you could argue  that the positive and negative parts cancel each other - this is not rigorous, but can be summed up as the following observation:
$$
\sum_{n=-N}^{N} a_n \longrightarrow 0 \quad \text{as } N \to \infty.
$$

Your problem is similar. There is no rule saying that the difference of two infinite quantities is zero, therefore the first method (as it's written) is wrong. However, it is true that
$$
\int_{-R} ^{R} \frac{x \ dx}{x^2+1} \longrightarrow 0 \quad \text{as } R \to \infty,
$$
and the effect of this procedure is sometimes called the principal value of the integral. Note that this strongly depends on choosing the same $R$ on both sides, for example $\int_{-R} ^{2R} \frac{x \ dx}{x^2+1}$ would give you a different answer.
