I have an issue :

NIntegrate[x^2 *Exp[-x^2], {x, 0, Infinity}]

gives out 0.443113

But :

NIntegrate[x^2 *Exp[-x^2], {x, 0, 6857}]

gives an error:

NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.

and a zero as a result


NIntegrate[x^2 *Exp[-x^2], {x, 0, 6855}]

gives the correct answer of 0.443113.

What is the difference of integrating over 6855 or 6857 ? (I am not really aware of the insides of mathematica and how it calculates the integrals numerically).

Addition to my question - how to access the properties of integration and play with the parameters.

Thank you a lot for your help :)

  • $\begingroup$ Note that NIntegrate's message "izero" pretty much tells you how to get a better result. As for "how to access the properties of integration and play with the parameters." -- all of these are answered in the advanced NIntegrate documentation. $\endgroup$ – Anton Antonov Jan 28 '19 at 15:42
  • $\begingroup$ What version have you observed this with? I cannot reproduce your results and message in 11.3: for both sets of limits I get 0.443113 . $\endgroup$ – Anton Antonov Jan 28 '19 at 18:56
  • $\begingroup$ @AntonAntonov One guess is that in V11.3, machine underflow (General::munfl) is used as a signal for recursive subdivision. Certainly a Trace[] indicates that the underflow message is suppressed. $\endgroup$ – Michael E2 Jan 29 '19 at 3:48
  • $\begingroup$ @AntonAntonov On 11.3, I had to go a little higher than 6857 to induce the problem, but I didn't think it was important enough to highlight in my answer. $\endgroup$ – John Doty Jan 29 '19 at 12:31

x^2*Exp[-x^2] is effectively 0 at most points in your interval.

Reduce[x^2*Exp[-x^2] >= $MinMachineNumber]
(* -26.7389 <= x <= -1.49167*10^-154 || 1.49167*10^-154 <= x <= 26.7389 *)

NIntegrate works by sampling the function. If it never finds a nonzero sample, you'll see the error. But the message gives you the advice to fix the problem.

NIntegrate[x^2*Exp[-x^2], {x, 0, 10000}, MinRecursion -> 5]
(* 0.443113 *)

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.