Navigation

Operators and Keywords

Function List:

C++ API

: q = quadv (f, a, b)
: q = quadv (f, a, b, tol)
: q = quadv (f, a, b, tol, trace)
: q = quadv (f, a, b, tol, trace, p1, p2, …)
: [q, nfun] = quadv (…)

Numerically evaluate the integral of f from a to b using an adaptive Simpson’s rule.

f is a function handle, inline function, or string containing the name of the function to evaluate. quadv is a vectorized version of quad and the function defined by f must accept a scalar or vector as input and return a scalar, vector, or array as output.

a and b are the lower and upper limits of integration. Both limits must be finite.

The optional argument tol defines the absolute tolerance used to stop the adaptation procedure. The default value is 1e-6.

The algorithm used by quadv involves recursively subdividing the integration interval and applying Simpson’s rule on each subinterval. If trace is true then after computing each of these partial integrals display: (1) the total number of function evaluations, (2) the left end of the subinterval, (3) the length of the subinterval, (4) the approximation of the integral over the subinterval.

Additional arguments p1, etc., are passed directly to the function f. To use default values for tol and trace, one may pass empty matrices ([]).

The result of the integration is returned in q.

The optional output nfun indicates the total number of function evaluations performed.

Note: quadv is written in Octave’s scripting language and can be used recursively in dblquad and triplequad, unlike the quad function.

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

Package: octave