This is a generic question about the NIntegrate function. I am attempting to numerically integrate a function which may or may not be highly oscillatory, based on it's inputs. For a certain sets of function inputs I get the NIntegrate::slwcon message. The function does not have any singularities. In the case of the NIntegrate::slwcon message, I am confident that the integral over the desired region is ~0. Is there any way to make sure that as soon as NIntegrate realises that the result is converging slowly, it returns a zero instead of attempting to go through all the recursions?
The function being integrated is essentially a two-dimensional Gaussian, which is modulated by complex exponentials. The oscillating frequency of the exponentials depends upon multiple function inputs. The Gaussian envelope has a maximum of ~10^-101. The FWHM of the Gaussian is ~10^14. Overall the range of NIntegate output can be crudely approximated to be from 0 to 1.
I'm not really concerned with the quality of the result. Three significant digits is good enough for me. I need to significantly speed up the computation. For well behaving inputs, the NIntegrate call is done in 0.04s, however under certain conditions the call executes in ~2s and gives a slightly incorrect result.
My NIntegrate call is already using Method -> "LevinRule" , MaxRecursion -> 10, PrecisionGoal -> 3, AccuracyGoal -> 3.
Catch[Internal`HandlerBlock[{"Message", If[Last[#], Throw[Indeterminate, "x"]] &}, NIntegrate[Log[x], {x, 0, 1}, Method -> {"Trapezoidal", "SymbolicProcessing" -> 0}]], "x"]– J. M.'s missing motivation Mar 18 '16 at 23:43Internal\HandlerBlock[{"Message", If[Last[#], Throw[Indeterminate, "x"]] &}...what is the significance ofLast[#]and theIfstatement? I have not encountered functions of the formInternal`HandlerBlock,Internal`AddHandlerandInternal`RemoveHandler` before. What do these mean (I could not find any documentation concerning this)? – Gleb Egorov Mar 21 '16 at 18:31Hold[message, printed]is passed to all"Message"handler functions wheremessageis the message text andprintedisTrueis the message would be printed,Falseotherwise."Last[]just extracts the Boolean value ofprintedin this case. – J. M.'s missing motivation Mar 21 '16 at 19:20