3

I am currently trying to compute out an integral with scipy.integrate.quad, and for certain values I get the following error:

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/scipy/integrate/quadrature.py:616: AccuracyWarning: divmax (20) exceeded. Latest difference = 2.005732e-02 AccuracyWarning)

Looking at the documentation, it isn't entirely clear to me why this warning is raised, what it means, and why it only occurs for certain values.

Benjamin Horowitz
  • 604
  • 1
  • 8
  • 10
  • Could you show the simplest version of your code that generates the warning? A quick glance at the latest scipy source code shows that warning can be raised in `scipy.integrate.romberg`, but apparently not in `scipy.integrate.quad`. – Warren Weckesser Jun 06 '14 at 23:02

1 Answers1

1

in scipy.integrate.quad there's a lower-level call to a difference function that is iterated over, and it's iterated over divmax times. In your case, the default for divmax=20. There are some functions that you can override this default -- for example scipy.integrate.quadrature.romberg allows you to set divmax (default here is 10) as a keyword. The warning is thrown when the tolerances aren't met for the difference function. Setting divmax to a higher value will run longer, and hopefully meet the tolerance requirements.

Mike McKerns
  • 33,715
  • 8
  • 119
  • 139