Numerically evaluate integral, adaptive Lobatto quadrature
quadl will be removed in a future release.
q = quadl(fun,a,b)
q = quadl(fun,a,b,tol)
[q,fcnt] = quadl(...)
q = quadl(fun,a,b) approximates
the integral of function
to within an error of 10-6 using recursive
adaptive Lobatto quadrature.
fun is a function
handle. It accepts a vector
x and returns a vector
fun evaluated at each element of
b must be finite.
Parameterizing Functions explains how to provide additional
parameters to the function
fun, if necessary.
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
in fewer function evaluations and faster computation, but less accurate
trace shows the values of
[fcnt a b-a q] during
[q,fcnt] = quadl(...) returns
the number of function evaluations.
Use array operators
the definition of
fun so that it can be evaluated
with a vector argument.
quad might be more efficient
with low accuracies or nonsmooth integrands.
The list below contains information to help you determine which quadrature function in MATLAB® to use:
quad function might be most
efficient for low accuracies with nonsmooth integrands.
quadl function might be more
quad at higher accuracies with
quadgk function 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
quadv function vectorizes
If the interval is infinite, ,
then for the integral of
fun(x) to exist,
x approaches infinity, and
it to decay rapidly. Special methods should be used for oscillatory
functions on infinite intervals, but
be used if
fun(x) decays fast enough.
quadgk function 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
>= -1/2. If the function is singular at points inside
write the integral as a sum of integrals over subintervals with the
singular points as endpoints, compute them with
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
'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 available at