Matlab 6 Numerical Integration Methods
quad
QUAD Numerically evaluate integral, adaptive Simpson quadrature.
Q = QUAD(FUN,A,B) tries to approximate the integral of function
FUN from A to B to within an error of 1.e-6 using recursive
adaptive Simpson quadrature. The function Y = FUN(X) should
accept a vector argument X and return a vector result Y, the
integrand evaluated at each element of X.
Q = QUAD(FUN,A,B,TOL) uses an absolute error tolerance of TOL
instead of the default, which is 1.e-6. Larger values of TOL
result in fewer function evaluations and faster computation,
but less accurate results. The QUAD function in MATLAB 5.3 used
a less reliable algorithm and a default tolerance of 1.e-3.
[Q,FCNT] = QUAD(...) returns the number of function evaluations.
QUAD(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values
of [fcnt a b-a Q] during the recursion.
QUAD(FUN,A,B,TOL,TRACE,P1,P2,...) provides for additional
arguments P1, P2, ... to be passed directly to function FUN,
FUN(X,P1,P2,...). Pass empty matrices for TOL or TRACE to
use the default values.
Use array operators .*, ./ and .^ in the definition of FUN
so that it can be evaluated with a vector argument.
Function QUADL may be more efficient with high accuracies
and smooth integrands.
Example:
FUN can be specified three different ways.
A string expression involving a single variable:
Q = quad('1./(x.^3-2*x-5)',0,2);
An inline object:
F = inline('1./(x.^3-2*x-5)');
Q = quad(F,0,2);
A function handle:
Q = quad(@myfun,0,2);
where myfun.m is an M-file:
function y = myfun(x)
y = 1./(x.^3-2*x-5);
quadl
QUADL Numerically evaluate integral, adaptive Lobatto quadrature.
Q = QUADL(FUN,A,B) tries to approximate the integral of function
FUN from A to B to within an error of 1.e-6 using high order
recursive adaptive quadrature. The function Y = FUN(X) should
accept a vector argument X and return a vector result Y, the
integrand evaluated at each element of X.
Q = QUADL(FUN,A,B,TOL) uses an absolute error tolerance of TOL
instead of the default, which is 1.e-6. Larger values of TOL
result in fewer function evaluations and faster computation,
but less accurate results.
[Q,FCNT] = QUADL(...) returns the number of function evaluations.
QUADL(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values
of [fcnt a b-a Q] during the recursion.
QUADL(FUN,A,B,TOL,TRACE,P1,P2,...) provides for additional
arguments P1, P2, ... to be passed directly to function FUN,
FUN(X,P1,P2,...). Pass empty matrices for TOL or TRACE to
use the default values.
Use array operators .*, ./ and .^ in the definition of FUN
so that it can be evaluated with a vector argument.
Function QUAD may be more efficient with low accuracies or
nonsmooth integrands.
Example:
FUN can be specified three different ways.
A string expression involving a single variable:
Q = quadl('1./(x.^3-2*x-5)',0,2);
An inline object:
F = inline('1./(x.^3-2*x-5)');
Q = quadl(F,0,2);
A function handle:
Q = quadl(@myfun,0,2);
where myfun.m is an M-file:
function y = myfun(x)
y = 1./(x.^3-2*x-5);
Return to course home page