# NIntegrate with infinite boundaries

I would love to appreciate some tips on a problem I have. I am calculating moments for some functions that do not have analytic solution at all. Therefore NIntegrate should be my friend. But it's not :(

Long story short I would love to integrate something like this in range {-Infinity,+Infinity} As you see, function converges at both ends. When I try NIntegrate, it gives me pretty impossible results (especially when plot comes near x axis). What would you? Is there some specific method? Some mathematical magic trick I am not aware? Should I chop my function somewhere? (If yes then where?)

Edit: Adding a sample of some function I am trying to valuate expectation value:

Somthing[Z_?NumericQ, G_?NumericQ] :=
NIntegrate[((4 E^(-Z (π + 2 ArcTan[(2 x)/G])) G Z x)/(
G^2 + 4*x^2))/(1 - Exp[-2*π*Z]), {x, -∞, +∞}]

• It is difficult to provide help unless you provide the function and the code for what you have tried. – Bob Hanlon Sep 16 '16 at 15:03
• FYI NIntegrate does take Infinity as a limit. Have you tried that? – george2079 Sep 16 '16 at 15:46
• @george2079 yes yes,but it spits 10^999k at me. Clearly not the area underneath :D – Rena Sep 16 '16 at 15:49
• you should give specific examples for Z and G – george2079 Sep 16 '16 at 15:55

The integral does not converge when integrated over the range $(-\infty, \infty)$. The easiest way to see this is to use the Series functionality of Mathematica. Define:
 integrand[x_] = ((4 E^(-Z (π + 2 ArcTan[(2 x)/G])) G Z x)/(G^2 + 4*x^2))/(1 - Exp[-2*π*Z])

Series[integrand[x], {x, -∞, 1}]

The results are: $$\frac{G Z e^{\pi\sqrt{\frac{1}{G^2}} G Z+\pi Z}}{x \left(e^{2 \pi Z}-1\right)}+O\left(\left(\frac{1}{x}\right)^2\right)$$ and $$\frac{G Z e^{-\pi\sqrt{\frac{1}{G^2}} G Z+\pi Z}}{x \left(e^{2 \pi Z}-1\right)}+O\left(\left(\frac{1}{x}\right)^2\right)$$ respectively. Since the integrand is proportional to $1/x$ as $x \to \pm \infty$, its integral will diverge logarithmically as we take the limits of integration to $\pm \infty$. Thus, the integral over $(-\infty, \infty)$ is not well-defined.