Navigation

Operators and Keywords

Function List:

C++ API

: q = quadcc (f, a, b)
: q = quadcc (f, a, b, tol)
: q = quadcc (f, a, b, tol, sing)
: [q, err, nr_points] = quadcc (…)

Numerically evaluate the integral of f from a to b using doubly-adaptive Clenshaw-Curtis quadrature.

f is a function handle, inline function, or string containing the name of the function to evaluate. The function f must be vectorized and must return a vector of output values if given a vector of input values. For example,

f = @(x) x .* sin (1./x) .* sqrt (abs (1 - x));

which uses the element-by-element “dot” form for all operators.

a and b are the lower and upper limits of integration. Either or both limits may be infinite. quadcc handles an inifinite limit by substituting the variable of integration with x = tan (pi/2*u).

The optional argument tol defines the relative tolerance used to stop the integration procedure. The default value is 1e^{-6}.

The optional argument sing contains a list of points where the integrand has known singularities, or discontinuities in any of its derivatives, inside the integration interval. For the example above, which has a discontinuity at x=1, the call to quadcc would be as follows

int = quadcc (f, a, b, 1.0e-6, [ 1 ]);

The result of the integration is returned in q.

err is an estimate of the absolute integration error.

nr_points is the number of points at which the integrand was evaluated.

If the adaptive integration did not converge, the value of err will be larger than the requested tolerance. Therefore, it is recommended to verify this value for difficult integrands.

quadcc is capable of dealing with non-numeric values of the integrand such as NaN or Inf. If the integral diverges, and quadcc detects this, then a warning is issued and Inf or -Inf is returned.

Note: quadcc is a general purpose quadrature algorithm and, as such, may be less efficient for a smooth or otherwise well-behaved integrand than other methods such as quadgk.

The algorithm uses Clenshaw-Curtis quadrature rules of increasing degree in each interval and bisects the interval if either the function does not appear to be smooth or a rule of maximum degree has been reached. The error estimate is computed from the L2-norm of the difference between two successive interpolations of the integrand over the nodes of the respective quadrature rules.

Reference: P. Gonnet, Increasing the Reliability of Adaptive Quadrature Using Explicit Interpolants, ACM Transactions on Mathematical Software, Vol. 37, Issue 3, Article No. 3, 2010.

See also: quad, quadv, quadl, quadgk, trapz, dblquad, triplequad.

Package: octave