(Not recommended) Numerically evaluate integral, adaptive Lobatto quadrature
quadl is not recommended. Use
q = quadl(fun,a,b)
q = quadl(fun,a,b,tol)
[q,fcnt] = quadl(...)
q = quadl(fun,a,b) approximates the integral
within an error of 10-6 using recursive adaptive Lobatto
fun is a function handle. It accepts a vector
x and returns a vector
y, the function
fun evaluated at each element of
b must be finite.
Parameterizing Functions explains how to
provide additional parameters to the function
q = quadl(fun,a,b,tol) uses an absolute
error tolerance of
tol instead of the default, which is
1.0e-6. Larger values of
tol result in fewer
function evaluations and faster computation, but less accurate results.
quadl(fun,a,b,tol,trace) with non-zero
trace shows the values of
[fcnt a b-a q] during the recursion.
[q,fcnt] = quadl(...) returns the number of
Use array operators
.^ in the definition of
fun so that it can be
evaluated with a vector argument.
quad might be more efficient with low accuracies or
The list below contains information to help you determine which quadrature function in MATLAB® to use:
quadfunction might be most efficient for low accuracies with nonsmooth integrands.
quadlfunction might be more efficient than
quadat higher accuracies with smooth integrands.
quadgkfunction might be most efficient for high accuracies and oscillatory integrands. It supports infinite intervals and can handle moderate singularities at the endpoints. It also supports contour integration along piecewise linear paths.
quadfor an array-valued
If the interval is infinite, , then for the integral of
fun(x)must decay as
xapproaches infinity, and
quadgkrequires it to decay rapidly. Special methods should be used for oscillatory functions on infinite intervals, but
quadgkcan be used if
fun(x)decays fast enough.
quadgkfunction will integrate functions that are singular at finite endpoints if the singularities are not too strong. For example, it will integrate functions that behave at an endpoint
p >= -1/2. If the function is singular at points inside
(a,b), write the integral as a sum of integrals over subintervals with the singular points as endpoints, compute them with
quadgk, and add the results.
Pass the function handle,
Q = quadl(@myfun,0,2);
where the function
function y = myfun(x) y = 1./(x.^3-2*x-5);
Pass anonymous function handle
F = @(x) 1./(x.^3-2*x-5); Q = quadl(F,0,2);
quadl might issue one of the following warnings:
'Minimum step size reached' indicates that the recursive interval
subdivision has produced a subinterval whose length is on the order of roundoff error in
the length of the original interval. A nonintegrable singularity is possible.
'Maximum function count exceeded' indicates that the integrand has
been evaluated more than 10,000 times. A nonintegrable singularity is likely.
'Infinite or Not-a-Number function value encountered' indicates a
floating point overflow or division by zero during the evaluation of the integrand in
the interior of the interval.
quadl implements a high order method using an adaptive
Gauss/Lobatto quadrature rule.
 Gander, W. and W. Gautschi, “Adaptive Quadrature
– Revisited,” BIT, Vol. 40, 2000, pp. 84-101. This document is also