Code for reproducing is below:
Integrand[x_] := ((x + 1) Abs[x] Log[(x + 1)^2/Abs[x]^3])/((x + 1)^2 - Abs[x]^3);
NIntegrate[Integrand[x], {x, -10000000, 10000000}]
NIntegrate[Integrand[x], {x, -Infinity, Infinity}]
The first instance of NIntegrate
gives $2.48398$, and one can check by plotting the result of NIntegrate
as a function of the integration limits that the integral appears to converge to this answer for very large integration limits. However, the second instance of NIntegrate
gives a completely different answer of $1.75434 \times 10^{8}$. What's going on here, and how can I make the two integrals agree? I think something that NIntegrate
might be having trouble with is that the convergence of the integral requires the fact that the integrand is essentially odd for very large $|x|$ and these contributions tend to cancel out. Ideally I'd like to find some way to get Mathematica to deal with this properly with the infinite integration range, so that I don't have to keep remembering to exchange the infinite integration limits with large finite values every time I need to do an integral like this.
Series[((x + 1) RealAbs[x] *Log[(x + 1)^2/RealAbs[x]^3])/((x + 1)^2 - RealAbs[x]^3), {x, Infinity, 1}]
results in $O\left(\left(\frac{1}{x}\right)^2\right)+\frac{\log (x)}{x}$ andSeries[((x + 1) RealAbs[x] *Log[(x + 1)^2/RealAbs[x]^3])/((x + 1)^2 - RealAbs[x]^3), {x, -Infinity, 1}]
performs $\frac{\log (-x)}{x}+O\left(\left(\frac{1}{x}\right)^2\right)$. This implies the improper integral under consideration diverges. Maybe, the one exists as its principal value. In any case,NIntegrate
badly handles improper integrals over the reals. $\endgroup$