{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $f \\colon [a, b] \\to \\R$ be integrable and let $\\tau \u003e 0$ be a tolerance.\nFor each closed subinterval $J$ of $[a, b]$, let $A(J)$ be a computable approximation of $I(J) = \\int_J f(x) \\, dx$, and let $E(J) \\ge 0$ be a computable error estimate.\nThe *adaptive quadrature* procedure $\\mathrm{ADAPT}(J, \\tau_J)$ returns $A(J)$ if $E(J) \\le \\tau_J$; otherwise it splits $J$ at its midpoint into $J_1$ and $J_2$ and returns $\\mathrm{ADAPT}(J_1, \\tau_J / 2) + \\mathrm{ADAPT}(J_2, \\tau_J / 2)$.\nSuppose that $\\mathrm{ADAPT}([a, b], \\tau)$ terminates, and let $J_1, \\ldots, J_m$ be the intervals at which it accepted $A(J_i)$ with tolerance $\\tau_i$.\nThen:\n\n1. the intervals $J_1, \\ldots, J_m$ cover $[a, b]$ and overlap only at endpoints, and $\\tau_1 + \\cdots + \\tau_m = \\tau$;\n2. if $\\abs{I(J_i) - A(J_i)} \\le E(J_i)$ for each $i$, then the result $S = \\sum_{i=1}^m A(J_i)$ satisfies $\\abs{\\int_a^b f(x)\\,dx - S} \\le \\tau$.\n\n## Remarks\n\nClause 1 holds by induction on the recursion: a split replaces one interval with tolerance $\\tau_J$ by its two halves with tolerances adding up to $\\tau_J$.\nClause 2 then follows from the triangle inequality, since $\\abs{\\int_a^b f - S} \\le \\sum_i \\abs{I(J_i) - A(J_i)} \\le \\sum_i \\tau_i$.\nThe usual example is adaptive [[Simpson's rule|MNXC26G3BQ]]: with $S(J)$ the Simpson value on $J$, one takes $A(J) = S(J_1) + S(J_2)$ and $E(J) = \\abs{S(J_1) + S(J_2) - S(J)}/15$.\nThis estimate is justified for $f \\in C^4$ and small $J$: the Simpson error on an interval of length $\\ell$ is $-\\frac{\\ell^5}{2880} f^{(4)}(\\xi)$, so halving the interval divides the error by about $16$.\nThe hypothesis of clause 2 is essential, and the estimate $E$ can be fooled.\nFor $f(x) = \\big(x (x - \\tfrac14)(x - \\tfrac12)(x - \\tfrac34)(x - 1)\\big)^2$ on $[0, 1]$, all the Simpson sample points of the first test are zeros of $f$, so $E([0,1]) = 0$ and the procedure returns $0$, while $\\int_0^1 f \u003e 0$.\nReal programs also bound the depth of the recursion, since termination is not guaranteed for every $f$.\n\n## Explanations\n\n### L1 human\n\nAn adaptive integrator spends its effort where the function is hard.\nIt estimates the error on an interval; if the error is too big, it cuts the interval in half and treats each half with half of the allowed error.\nSmooth regions are finished after a few steps, and only the difficult spots get cut many times.\n\n### L2 human\n\nCompared with a fixed composite rule, adaptivity can save many function evaluations when $f$ has a peak, a kink or an endpoint singularity.\nThe error estimate comes from comparing two rules on the same interval, such as Simpson's rule on one and on two panels, or a Gauss rule with its [[Gauss–Kronrod extension|E8QJJVC1KV]].\nThe guarantee is only as good as the estimate: it is a heuristic, not a proof, for a function known only through samples.\nGlobal variants keep a list of all intervals and always split the one with the largest estimated error.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "7HYF6YG0RS"
    ],
    "kind": "statement",
    "msc": [
      "65D30",
      "65D32"
    ],
    "name": "Adaptive quadrature",
    "role": "proposition",
    "same_as": {
      "wikidata": "Q4680758",
      "wikipedia": "Adaptive quadrature"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Adaptive_quadrature"
      }
    ],
    "tag": "948A39DZDE",
    "uses": [
      "7HYF6YG0RS",
      "ADSVMCY77A",
      "MNXC26G3BQ"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/948A39DZDE/",
  "links": [
    {
      "field": "about",
      "target": "7HYF6YG0RS"
    },
    {
      "field": "uses",
      "target": "7HYF6YG0RS"
    },
    {
      "field": "uses",
      "target": "ADSVMCY77A"
    },
    {
      "field": "uses",
      "target": "MNXC26G3BQ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/948A39DZDE.md",
  "msc": [
    "65D30",
    "65D32"
  ],
  "name": "Adaptive quadrature",
  "prov": null,
  "role": "proposition",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/948/948A39DZDE.md",
  "status": null,
  "tag": "948A39DZDE",
  "uri": "m2://948A39DZDE",
  "url": "https://tamnd.github.io/math2/wiki/adaptive-quadrature/",
  "writing": {
    "tag": "948A39DZDE",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
