I have a question about NIntegrate. I want to evaluate numerically the following integral


where M is a constant. I know that this integral converges, but I want to evaluate it numerically because I need to use it in a plot. However, when I try to use NIntegrate, Mathematica gives me an error saying that

"NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small."

"NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.400375}. NIntegrate obtained 10.5643 +0. I and 0.7919336440001783` for the integral and error estimates."

Can anybody explain to me what I am doing wrong?

Thank you.

  • 2
    $\begingroup$ Please, provide the code you have used. This should include the value of M so we can reproduce your errors... $\endgroup$ – José Antonio Díaz Navas Feb 28 '18 at 21:36
  • $\begingroup$ Analizing the singularities in your integrand, -2<M<2 to guarantee that your integral converges for $y\in (0,1)$..., beyond this range you should take care of them... $\endgroup$ – José Antonio Díaz Navas Feb 28 '18 at 21:51

Mathematica can do this integral symbolically:

Integrate[(y(1-y))/Abs[1-M^2 y(1-y)], {y, 0, 1}, Assumptions->-2<M<2]

(-M Sqrt[4 - M^2] + 4 ArcTan[M/Sqrt[4 - M^2]])/(M^3 Sqrt[4 - M^2])

If your M had a magnitude larger than 2, then the integral diverges.

| improve this answer | |
  • $\begingroup$ Thank you. I need my mass M to be above 2 actually. I guess I was making a mistake when I said that it always converges. Thank you for pointing that out. $\endgroup$ – Christian Mar 1 '18 at 3:22

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