Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Assume I have a complicated integral $I$ which can feature all kinds of difficulties like infinite interval, rapidly oscillatory integrand, integrable singularities and numerically almost singular points in the integrand. Assume further that I need to compute it many times, so I need to optimize speed. I figured that I need to help Mathematica a bit to avoid problems such as NIntegrate::slwcon if I do not want to increase MaxIterations, MinIterations, WorkingPrecision a lot, which would decrease speed. So I decompose the domain of integration into several $I=I_1+I_2+I_3\ldots I_n$ ($n$ finite). NIntegrate behaves better now and I can manually perform integral transformations and choose well suited Methods for the different domains. However: With fixed AccuracyGoal and PressicionGoal for each of $I_i$ NIntegrate will choose sufficiently many sampling points and iterations to achieve these error levels, even if the total contribution of $I_i$ is negligibly small. How would you proceed (how would you choose AccuracyGoal and PressicionGoal for the individual integrands) to reduce the total number of integrand evalutations to the minimum required as to achieve given global values of AccuracyGoal and PressicionGoal? Since the integrand of $I$ is fixed I can reorder $I_i$ such that difficult but possibly small ones appear late and I can use the previous results as estimates for the total value of $I$. However assume that I do not have any analytic estimates for $I_i$.

share|improve this question
It seems that you should set PrecisionGoal to Infinity (i.e. to switch off this option) and set equal AccuracyGoal for all integrals. Note that PrecisionGoal is meant to specify the relative error of the result while AccuracyGoal - absolute error. – Alexey Popkov Feb 3 '14 at 20:55
But this solution would imply that I can't specify a relative error, unless I know an approximate result, for the total Integral. – highsciguy Feb 5 '14 at 15:12
I had not investigated how AccuracyGoal actually affects selection of evaluation points for the integrand on each stage of NIntegrate's recursive algorithm. Assuming that increasing AccuracyGoal just adds new levels of recursion and does not alter previous you could use memoization and compute the complete integral in two stages: at first stage you compute it with little value of AccuracyGoal (which you still should guess), at the second stage you set AccuracyGoal you actually wish based on the estimate from the 1'st stage. – Alexey Popkov Feb 5 '14 at 16:36
Of course it is not a general solution, just a partial workaround for the case when evaluation of the integrand(s) is very time-consuming. – Alexey Popkov Feb 5 '14 at 16:43
How would 'memoization' work? Probably it would depend then on the integration routine too as not all algorithms can make use of previous evaluation points as far as I understand. – highsciguy Feb 5 '14 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.