# Precision of NIntegrate

At the moment I am considering a "difficult", highly-oscillatory integral in Mathematica. It calculates the integral without any complaints. However, I am also trying out a numerical method with which I am calculating the same integral. The relative difference between the two results is of $\mathcal{O}(10^{-3})$. It appears that this difference stays the same if I reduce the stepsize of my numerical method. This is strange, as the difference should become smaller (provided my method is correct, of course).

Hence my question:

If Mathematica does not give any errors when evaluating an expression, can we be absolutely certain that its answer is reliable up to a decent precision (say, $\mathcal{O}(10^{-10})$?

And a related question:

Is there a way to let Mathematica print the precision with which it has obtained a certain answer?

• You'd better add a concrete example. BTW, have you tried the WorkingPrecision option? Feb 9 '15 at 9:23
• As to your second question, have you looked at Precision? Feb 9 '15 at 13:07
• tutorial/NIntegrateOverview contains lots of information. The pages on the integration rules discussed how the error is estimated. There is an example that shows how it can get fooled. Feb 9 '15 at 14:20

If NIntegrate returns a value with no error or warning messages, I think it is safe to assume that the algorithm's error estimate meets the criterion set by PrecisionGoal and AccuracyGoal. But as the tutorial shows, that is not a guarantee that it has actually been met.
• One possibility is to try, if applicable, various applicable methods and compare their results against the method you are developing yourself. This can be done with a "toy" version of the integral being evaluated (hopefully with a known closed form!) as well as the actual integral itself. For the truly paranoid, one can also check against NDSolve[] which often has to be more careful than NIntegrate[]. May 27 '15 at 5:32