quad2d
Numerically evaluate double integral, tiled method
Syntax
q = quad2d(fun,a,b,c,d)
[q,errbnd] = quad2d(...)
q = quad2d(fun,a,b,c,d,param1,val1,param2,val2,...)
Description
q = quad2d(fun,a,b,c,d)
approximates the integral offun(x,y)
over the planar region
and
.fun
is a function handle,c
andd
may each be a scalar or a function handle.
All input functions must be vectorized. The functionZ=fun(X,Y)
must accept 2-D matricesX
andY
of the same size and return a matrixZ
of corresponding values. The functionsymin=c(X)
andymax=d(X)
must accept matrices and return matrices of the same size with corresponding values.
[q,errbnd] = quad2d(...)
.errbnd
is an approximate upper bound on the absolute error,|Q - I|
, whereI
denotes the exact value of the integral.
q = quad2d(fun,a,b,c,d,param1,val1,param2,val2,...)
performs the integration as above with specified values of optional parameters:
AbsTol |
absolute error tolerance |
RelTol |
relative error tolerance |
quad2d
attempts to satisfyERRBND <= max(AbsTol,RelTol*|Q|)
. This is absolute error control when|Q|
is sufficiently small and relative error control when|Q|
is larger. A default tolerance value is used when a tolerance is not specified. The default value ofAbsTol
is 1e-5. The default value ofRelTol
is100*eps(class(Q))
. This is also the minimum value ofRelTol
. SmallerRelTol
values are automatically increased to the default value.
MaxFunEvals |
Maximum allowed number of evaluations offun reached. |
TheMaxFunEvals
parameter limits the number of vectorized calls tofun
. The default is 2000.
FailurePlot |
Generate a plot ifMaxFunEvals is reached. |
SettingFailurePlot
totrue
generates a graphical representation of the regions needing further refinement whenMaxFunEvals
is reached. No plot is generated if the integration succeeds before reachingMaxFunEvals
. These (generally) 4-sided regions are mapped to rectangles internally. Clusters of small regions indicate the areas of difficulty. The default isfalse
.
Singular |
Problem may have boundary singularities |
WithSingular
set totrue
,quad2d
will employ transformations to weaken boundary singularities for better performance. The default istrue
. SettingSingular
tofalse
will turn these transformations off, which may provide a performance benefit on some smooth problems.
Examples
References
[1] L.F. Shampine, "Matlab Program for Quadrature in 2D."Applied Mathematics and Computation.Vol. 202, Issue 1, 2008, pp. 266–274.