I am trying to evaluate a highly oscillatory integral using NIntegrate. I fear that due to limited resources (time and/or memory), I will not be able to evaluate the integral to the desired precision. Thus, I would like to programmatically access the error estimates that are e.g. reported by the messages NIntegrate::maxp, NIntegrate::ncvb, or NIntegrate::eincr. I could not find an option of NIntegrate that would directly make these error estimates available. However, given that I have to evaluate a multitude of integrals, it is impractical to obtain the errors from the warnings by hand.
The following example generates the NIntegrate::maxp message (obviously this very integral has an analytical solution):
NIntegrate[Sin[x]/Sqrt[x], {x, 0, 100}, Method -> "MonteCarlo",PrecisionGoal -> 6]
NIntegrate::maxp: The integral failed to converge after 50100 integrand evaluations. NIntegrate obtained 1.1787733508261242
and 0.07678430788995934
for the integral and error estimates.
How to get (if necessary, extract) the error estimate (0.07678430788995934`)?
Remark: The example from the help of NIntegrate::eincr, i.e. ref/message/NIntegrate/eincr, does not produce the expected message in version 8.0; unfortunate my integrals still do.
NIntegrate[]
." - then, why"MonteCarlo"
? There's"DoubleExponential"
or"ClenshawCurtisOscillatoryRule"
which you could have used... unless your actual integrals are in fact multidimensional, and you've just grossly oversimplified. $\endgroup$