0
$\begingroup$

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

$$\int^{1}_{0}\frac{y(1-y)}{|1-M^2y(1-y)|}\,dy$$

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.

$\endgroup$

closed as off-topic by Michael E2, J. M. is away Mar 31 '18 at 4:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – J. M. is away
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
1
$\begingroup$

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.

$\endgroup$
  • $\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.