Lably
Skip to content

Adaptive quadrature

Type of numerical integration

  • 3 min read
  • 4 chapters

Related on Lably

Through Integral and Function (mathematics)

General scheme

Adaptive quadrature follows the general scheme

1. <b id="mwDw">procedure</b> integrate ( f, a, b, τ ) 2. <span class="mwe-math-element mwe-math-element-inline" typeof="mw:Extension/math" about="#mwt5" data-mw='{"name":"math","attrs":{},"body":{"extsrc":"Q \\approx \\int_a^b f(x)\\,\\mathrm{d}x"}}' id="mwEA"><span class="mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" class="mathjax_ignore" alttext="{\displaystyle Q\approx \int _{a}^{b}f(x)\,\mathrm {d} x}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>Q</mi> <mo>≈<!-- ≈ --></mo> <msubsup> <mo>∫<!-- ∫ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mi>a</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>b</mi> </mrow> </msubsup> <mi>f</mi> <mo stretchy="false">(</mo> <mi>x</mi> <mo stretchy="false">)</mo> <mspace width="thinmathspace"></mspace> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="normal">d</mi> </mrow> <mi>x</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle Q\approx \int _{a}^{b}f(x)\,\mathrm {d} x}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/728841852a453036f92683d6bd39b0cc72a04a7e" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.338ex; width:16.153ex; height:6.343ex;" alt="{\displaystyle Q\approx \int _{a}^{b}f(x)\,\mathrm {d} x}"/></span> 3. <span class="mwe-math-element mwe-math-element-inline" typeof="mw:Extension/math" about="#mwt6" data-mw='{"name":"math","attrs":{},"body":{"extsrc":"\\varepsilon \\approx \\left|Q - \\int_a^b f(x)\\,\\mathrm{d}x\\right|"}}' id="mwEQ"><span class="mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" class="mathjax_ignore" alttext="{\displaystyle \varepsilon \approx \left|Q-\int _{a}^{b}f(x)\,\mathrm {d} x\right|}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ε<!-- ε --></mi> <mo>≈<!-- ≈ --></mo> <mrow> <mo>|</mo> <mrow> <mi>Q</mi> <mo>−<!-- − --></mo> <msubsup> <mo>∫<!-- ∫ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mi>a</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>b</mi> </mrow> </msubsup> <mi>f</mi> <mo stretchy="false">(</mo> <mi>x</mi> <mo stretchy="false">)</mo> <mspace width="thinmathspace"></mspace> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="normal">d</mi> </mrow> <mi>x</mi> </mrow> <mo>|</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \varepsilon \approx \left|Q-\int _{a}^{b}f(x)\,\mathrm {d} x\right|}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fa50e2b35b2ce5ea3526d875b90955b6bb1a07a7" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.838ex; width:21.37ex; height:6.843ex;" alt="{\displaystyle \varepsilon \approx \left|Q-\int _{a}^{b}f(x)\,\mathrm {d} x\right|}"/></span> 4. <b id="mwEg">if</b> <i id="mwEw">ε</i> > <i id="mwFA">τ</i> <b id="mwFQ">then</b> 5. m = (a + b) / 2 6. Q = integrate(f, a, m, τ/2) + integrate(f, m, b, τ/2) 7. <b id="mwFg">endif</b> 8. <b id="mwFw">return</b> Q

An approximation Q to the integral of f(x) over the interval [a,b] is computed (line 2), as well as an error estimate ε (line 3). If the estimated error is larger than the required tolerance τ(line 4), the interval is subdivided (line 5) and the quadrature is applied on both halves separately (line 6). Either the initial estimate or the sum of the recursively computed halves is returned (line 7).

The important components are the quadrature rule itself

Q≈∫abf(x)dx,

the error estimator

ε≈|Q−∫abf(x)dx|,

and the logic for deciding which interval to subdivide, and when to terminate.

There are several variants of this scheme. The most common will be discussed later.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication