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 as:
An anonymous function:
F = @(x) 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);
Class support for inputs A, B, and the output of FUN:
float: double, single
See also quadv, quadl, dblquad, triplequad, @, trapz.
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 as:
An anonymous function:
F = @(x) 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);
Class support for inputs A, B, and the output of FUN:
float: double, single
See also quadv, quadl, dblquad, triplequad, @, trapz.
Reference page in Help browser
doc quad
'Research > Etc_Research' 카테고리의 다른 글
Monte Carlo Method (0) | 2007.01.08 |
---|---|
Gradient (0) | 2007.01.08 |
Partial differential equations (0) | 2007.01.08 |
산화환원 반응 (0) | 2007.01.07 |
Matrix Inverse (6) | 2007.01.07 |