Fundamentals / Numerical mathematics / Approximation and quadrature

Quadrature near singularities and oscillations

Transform integrable endpoint singularities and use phase information to diagnose a misleading quadrature result.

From first principles

Remove an integrable endpoint singularity by substitution

An integrand can be unbounded and still have finite area. Consider \(f(x)=x^{-\alpha}g(x)\) on \([0,1]\), where \(g\) is continuous and bounded and \(0<\alpha<1\). The power law has a finite integral near zero since

\[\int_0^\varepsilon x^{-\alpha}\,dx=\frac{\varepsilon^{1-\alpha}}{1-\alpha}.\]

Ordinary endpoint rules may still try to sample \(f(0)\), which is undefined. Substitute \(x=t^q\) and include the Jacobian \(dx=q t^{q-1}dt\). The transformed integral becomes

\[\int_0^1 x^{-\alpha}g(x)\,dx=\int_0^1 q\, t^{q(1-\alpha)-1}g(t^q)\,dt .\]

Taking \(q=1/(1-\alpha)\) removes the explicit power. For a square-root singularity the familiar substitution \(x=t^2\) gives a regular factor \(2g(t^2)\). Continuity of the transformed integrand makes endpoint evaluation meaningful, while the convergence order of a high-order rule still depends on how many transformed derivatives are bounded.

Derivation and applications

Subtract a known endpoint contribution before integrating the remainder

A substitution is one way to handle an integrable endpoint singularity. If an expansion of its smooth coefficient is known, a second route is to integrate a few singular terms analytically. Consider \(I=\int_0^1g(x)/\sqrt{x}\,dx\) with \(g\) twice continuously differentiable and \(|g''|\le M\). Taylor’s theorem about \(x=0\) separates the constant and slope from a remainder bounded by \(Mx^2/2\),

\[g(x)=g(0)+xg'(0)+R(x),\qquad |R(x)|\le Mx^2/2 .\]

The first two contributions have finite known moments. The residual now vanishes at the problematic endpoint and can be sampled continuously there,

\[I=2g(0)+\frac23g'(0)+\int_0^1\frac{R(x)}{\sqrt{x}}dx,\qquad \left|\frac{R(x)}{\sqrt{x}}\right|\le\tfrac M2 x^{3/2} .\]

If only the short initial interval \([0,h]\) is targeted, the two analytic terms scale as \(\sqrt h\) and \(h^{3/2}\). Bounding the remaining contribution yields a direct local error certificate,

\[\left|\int_0^h\frac{g(x)}{\sqrt x}\,dx-2g(0)\sqrt h-\frac23g'(0)h^{3/2}\right|\le\frac{M}{5}h^{5/2}.\]

The two known coefficients have to use the same units and coordinate origin as \(h\). Numerically it can be advantageous to evaluate the residual through a stable expression or a local series, because subtracting its first two terms from a nearly equal value of \(g(x)\) can lose relative precision.

Worked example

Integrate a polynomial endpoint layer

For \(g(x)=1+3x+2x^2\) and \(h=0.04\), the two retained terms give

\[0.4+2(0.008)=0.416.\]

The remaining integral is \(2(2/5)h^{5/2}=0.000256\), giving total \(0.416256\). The error bound with \(M=4\) also equals \(0.000256\), attained because the curvature has constant sign and magnitude.

Second application

Choose an endpoint panel from a tolerance

A different coefficient has verified \(|g''|\le10\). To limit the omitted endpoint area to \(10^{-5}\), require \(2h^{5/2}\le10^{-5}\), or \(h\le(5\times10^{-6})^{2/5}=0.00758\). Choosing \(h=0.005\) gives a bound \(3.54\times10^{-6}\). The remaining regular part of the integral still needs its own quadrature budget.

When derivative bounds fail

The usual trapezoid error bound needs a bounded second derivative. The integral of \(x^{-1/2}\) from zero to one is finite, yet the integrand itself is undefined at the first endpoint. Calling a closed quadrature formula on its original samples is already impossible. Simply omitting that endpoint also omits part of a finite area, and its size scales as the square root of the omitted interval. A substitution can encode the known local behaviour exactly.

Set \(x=t^q\). A factor \(x^\alpha dx\) becomes \(qt^{q(\alpha+1)-1}\,dt\). For \(\alpha>-1\), choosing \(q=1/(\alpha+1)\) removes the leading power. Any additional factor \(g(t^q)\) still determines the transformed smoothness. For \(\alpha=-1/2\), \(q=2\) and \(g(x)=1+x\), the integral becomes

\[\int_0^1 2(1+t^2)\,dt=8/3.\]

Composite Simpson quadrature on just two equal panels is exact on this quadratic. Assign the endpoint of the transformed expression by its limit to avoid evaluating zero times infinity.

A deceptively constant sample

Now consider \(\int_0^1\cos(16\pi x)\,dx\). The exact value is zero, because eight periods fit the interval. At the nine nodes of an eight-panel uniform trapezoid rule each value is one. The computed area is one, a full unit of error for an analytic function. A finer grid of sixteen panels samples alternating signs and returns zero. Repeating the first calculation on four panels also returns one. Agreement between the four- and eight-panel estimates therefore gives a false impression of convergence.

The aliasing follows from summing a geometric progression of sampled complex exponentials. When the phase step is an integer multiple of \(2\pi\), neighbouring samples coincide. Changing the offset slightly can expose the problem even before changing the number of nodes. A bound involving derivatives recognises the difficulty because the second derivative grows quadratically with the phase frequency.

Use cancellation as part of the method

When the oscillatory factor is known analytically, integrate it rather than forcing the grid to resolve every period. For a differentiable amplitude \(g\), integration by parts gives

\[\int_a^b g(x)\cos(\omega x)\,dx=\left[\frac{g(x)\sin(\omega x)}{\omega}\right]_a^b-\frac{1}{\omega}\int_a^b g'(x)\sin(\omega x)\,dx.\]

This identity shows how smooth amplitudes can produce small integrals even when pointwise values are large. For \(g=x\) and \(\omega=\pi\) on \([0,1]\), the boundary term vanishes. The remaining sine integrates to \(2/\pi\), giving \(-2/\pi^2\). A quadrature scheme that approximates the slowly varying amplitude by lines and integrates each line against the phase reproduces this result exactly for this example. If the phase itself is uncertain, that modelling error must be assessed separately from quadrature error.

Test integrability before applying the change

For \(f(x)=1/x\) on \((0,1]\) the substitution \(x=t^q\) leaves \(q/t\), still nonintegrable for every positive exponent. A numerical rule excluding zero may nevertheless return an ordinary finite number. The integral from a cutoff \(\delta\) to one is \(-\log\delta\), so reducing the cutoff by a factor of ten adds \(\log10\approx2.3026\) every time. That persistent change signals a divergent problem definition. It calls for a physically justified finite cutoff or a different mathematical quantity before refining a quadrature rule.

Integrate the singular weight exactly on each panel

Sometimes a substitution changes an integrable singularity into a regular function but also complicates the geometry or an expensive supplied amplitude. An alternative is product integration. Suppose \(I=\int_0^1 x^{-1/2}g(x)\,dx\) where only the smooth amplitude \(g\) is sampled. Replace \(g\) by its piecewise linear interpolant while keeping the weight exactly inside each local integral. The contribution of an endpoint sample equals the integral of the corresponding linear basis function against the singular weight. None of these weights requires evaluating \(x^{-1/2}\) at zero.

On a single panel covering the unit interval the basis functions are \(1-x\) and \(x\). Their weights are \(2-2/3=4/3\) and \(2/3\), respectively. They are positive and sum to two, the exact integral of the singular factor. The rule reproduces constant and linear amplitudes exactly. If \(|g''|\le M\), the pointwise error satisfies

\[|g-I_1g|\le Mx(1-x)/2.\]

Multiplying by the positive weight and integrating gives absolute error at most \((M/2)(2/3-2/5)=2M/15\). This derivation tracks smoothness of the amplitude that is actually interpolated.

Compare a weighted panel with an ordinary endpoint sample

Let \(g(x)=1+x^2\). The analytically integrated value is \(2+2/5=2.4\). The weighted panel predicts

\[(4/3)1+(2/3)2=8/3.\]

The excess is \(4/15\), exactly the bound for \(M=2\), because the interpolating line lies above this convex amplitude throughout the open interval. A direct unweighted trapezoid evaluation would have tried to sample an infinite value at the left endpoint. The finite weights here contain all information about the integrable divergence.

For a more refined calculation divide at \(x=1/4\). On the first panel, rescaling \(x=t/4\) multiplies the singular measure by \(1/2\), so the local weights become \(2/3\) and \(1/3\). On the second panel use the basis \((1-x)/(3/4)\), \((x-1/4)/(3/4)\). The weight of its left endpoint is

\[(4/3)[2\sqrt x-(2/3)x^{3/2}]_{1/4}^1=5/9.\]

The remaining weight is \(4/9\), since that panel's total singular measure is one. Combining adjacent contributions gives global weights \(2/3,8/9,4/9\) at the three sampled amplitudes.

The estimate is now \(2/3+(8/9)(17/16)+(4/9)2=2.5\). Its positive error has fallen from \(4/15\) to 0.1. Subdivision concentrated near the singular endpoint is one design choice, while error here also depends on where the smooth amplitude bends. If the amplitude itself has a discontinuity, splitting at that physical interface is necessary before invoking the second-derivative bound on either side.

The positive weights also control bounded amplitude uncertainty. If each of the three amplitude evaluations is uncertain by at most 0.01, the worst possible additional integral error is

\[0.01(2/3+8/9+4/9)=0.02.\]

The bound is achieved by a shared positive offset of 0.01. Unlike the deterministic interpolation discrepancy, this worst-case observation error will remain 0.02 under any further positive-weight refinement that still integrates constant amplitudes exactly. A complaint about slow convergence near the endpoint could therefore reflect either amplitude resolution or the data error floor.

Repeated amplitude measurements can reduce independent sampling variance but cannot remove the effect of a shared calibration offset.

Change parameters · Explore the worked calculation

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.