I am working on a Mathematica project that involves many numeric integrals, each of which should be integrated over the domain {k, 0, Infinity}
. I assumed that Mathematica would have an easier time integrating to a large finite number, so for all my integrals I used the domain {k, 0, kMax}
so I could play with large values of kMax
later.
The trouble is, each integral is a "step-like" function that drops off exponentially quickly after some cutoff value, though this cutoff is different for each integral. If I make kMax
big enough to capture the important contribution from the integrals with the largest cutoffs, then the integrals with small cutoffs start to have issues.
As an example, observe that NIntegrate[E^(-x^2), {x, 0, 1000}]
yields the correct value, whereas NIntegrate[E^(-x^2), {x, 0, 10000}]
yields zero and throws an error.
What are some standard solutions to this issue? I've considered several approaches, but all have their setbacks:
- Use
{k, 0, Infinity}
for each integral. Perhaps Mathematica is smarter about finding cutoff values in this case. The downside is I don't really know what Mathematica is doing. - Use "smart" cutoffs for each integral, that I have to figure out and program in. The downside is the messiness of this approach, and the assumptions I'd have to make about where the "right" cutoff location is for a good approximation.
- Use one large cutoff
kMax
value and also a veryMinRecursion
,MaxRecursion
, and precision/accuracy settings. The downside is huge computation times, perhaps becoming unfeasible.