Integrate a user-written function of two variables over a rectangle
Source:R/callback.R
quadrature_2d.RdComputes the definite integral of f(x, y) over the rectangle [min_x, max_x] x [min_y, max_y] with the ported Numerics adaptive Simpson's rule in two dimensions
(P2 "math extras"): the tensor-product 3x3-point Simpson estimate over the whole domain is
compared against the sum of the four quadrant sub-estimates, and the domain is subdivided into
quadrants until the two agree to the requested tolerance.
Usage
quadrature_2d(
f,
min_x,
max_x,
min_y,
max_y,
absolute_tolerance = NULL,
relative_tolerance = NULL,
min_depth = NULL,
max_depth = NULL
)Arguments
- f
a function taking two numbers (
x,y) and returning one number.- min_x, max_x, min_y, max_y
the bounds of the rectangle.
max_xmust be abovemin_x, andmax_yabovemin_y.- absolute_tolerance, relative_tolerance
the convergence tolerances on the difference between the whole-domain and quadrant-subdivided estimates, each between 1e-15 and 1.
NULL, the default, leaves the ported integrator's own defaults (1e-8) in force.- min_depth, max_depth
the recursion-depth bounds.
NULL, the default, leaves the ported class's own defaults (0 and 100) in force.
Value
the integral, a single number, carrying the same three attributes quadrature()
returns: status, function_evaluations, and standard_error.