Is the improper integral between plus infinity and plus infinity necessarily equal to zero? Is the improper integral $\int_{\infty}^{\infty} f(x) \,dx $ necessary equals zero?
The question is simple, but if the function diverges when it goes to infinity?
In my opinion, it is not a valid improper integral when the function diverges. But if we define this object as $\lim_{a \to +\infty} \int_{a}^{a} f(x) \,dx$ it is zero.
 A: Since the improper integral $\int_{a}^{\infty}f(x)\,dx$ is defined as
$$
\int_{a}^{\infty}f(x)\,dx \overset{\text{def}}{=} 
\lim_{b \to \infty}\int_{a}^{b}f(x)\,dx,
$$
it is natural to define $\int_{\infty}^{\infty}f(x)\,dx$ as
$$
\int_{\infty}^{\infty}f(x)\,dx \overset{\text{def}}{=}
\lim_{a \to \infty} \int_{a}^{\infty}
f(x)
\,dx.
$$
With this definition, if $\int_{a}^{\infty}f(x)\,dx$ exists and is finite for all sufficiently large $a$, then for all $A > 0$,
$$
\int_{a}^{\infty}f(x)\,dx - \int_{a+A}^{\infty}f(x)\,dx
=
\int_{a}^{a+A}f(x)\,dx
\to
0
\text{ as }
a \to \infty.
$$
Hence, if $\int_{a}^{\infty}f(x)\,dx$ exists and is finite for all sufficiently large $a$, then
$$
\int_{\infty}^{\infty}f(x)\,dx = 0.
$$
If, on the other hand, $\int_{a}^{\infty}f(x)\,dx = \pm\infty$ for all sufficiently large $a$, then
$$
\int_{\infty}^{\infty}f(x)\,dx
=
\lim_{a \to \infty}\int_{a}^{\infty}f(x)\,dx
=
\lim_{a \to \infty} \pm\infty
=
\pm\infty.
$$
Finally, if $\int_{a}^{\infty}f(x)\,dx$ diverges for all $a$ without going to $\pm\infty$, then $\int_{\infty}^{\infty}f(x)\,dx$ is not defined.
------ Edit ------
When interchanging the limits in the above definition, a sign change occurs. To fix this, we could instead define $\int_{\infty}^{\infty}f(x)\,dx$ as
$$
\int_{\infty}^{\infty}f(x)\,dx \overset{\text{def}}{=} 
\lim_{a \to \infty}
\lim_{b \to \infty}
(-1)^{[b < a]}\int_{a}^{b}f(x)\,dx
$$
where
$$
[b < a] \overset{\text{def}}{=} \begin{cases}
1 & \text{if }b < a,\\
0 & \text{if }b \ge a.
\end{cases}
$$
This has the effect of undoing the sign-change since
$$
(-1)^{[b<a]}\int_{a}^{b}f(x)\,dx
=
\begin{cases}
\int_{b}^{a}f(x)\,dx & \text{ if }b < a,\\
\int_{a}^{b}f(x)\,dx & \text{ if }b \ge a,
\end{cases}
$$
which means
$$
\begin{aligned}
\lim_{b \to \infty}\lim_{a \to \infty}
(-1)^{[b<a]}\int_{a}^{b}f(x)\,dx
&=
\lim_{b \to \infty}\lim_{a \to \infty}
-\int_{a}^{b}f(x)\,dx
\\&=
\lim_{b \to \infty}\lim_{a \to \infty}
\int_{b}^{a}f(x)\,dx
\\&=
\int_{\infty}^{\infty}f(x)\,dx.
\end{aligned}
$$
