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}

The graph

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, -∞, +∞}]
  • $\begingroup$ It is difficult to provide help unless you provide the function and the code for what you have tried. $\endgroup$ – Bob Hanlon Sep 16 '16 at 15:03
  • $\begingroup$ FYI NIntegrate does take Infinity as a limit. Have you tried that? $\endgroup$ – george2079 Sep 16 '16 at 15:46
  • $\begingroup$ @george2079 yes yes,but it spits 10^999k at me. Clearly not the area underneath :D $\endgroup$ – Rena Sep 16 '16 at 15:49
  • $\begingroup$ you should give specific examples for Z and G $\endgroup$ – 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])

Then issue the commands

Series[integrand[x], {x, -∞, 1}]
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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.