quadrature_2d
quadrature_2d(
f,
min_x,
max_x,
min_y,
max_y,
absolute_tolerance=None,
relative_tolerance=None,
min_depth=None,
max_depth=None,
)Integrate a user-written function of two variables over a rectangle.
Computes 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.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| f | callable | A function taking two numbers (x, y) and returning one number. |
required |
| min_x | float | The bounds of the rectangle. max_x must be above min_x, and max_y above min_y. |
required |
| max_x | float | The bounds of the rectangle. max_x must be above min_x, and max_y above min_y. |
required |
| min_y | float | The bounds of the rectangle. max_x must be above min_x, and max_y above min_y. |
required |
| max_y | float | The bounds of the rectangle. max_x must be above min_x, and max_y above min_y. |
required |
| absolute_tolerance | float | The convergence tolerances on the difference between the whole-domain and quadrant-subdivided estimates. Each must lie between 1e-15 and 1. Left unset, the ported integrator’s own defaults (1e-8) apply. | None |
| relative_tolerance | float | The convergence tolerances on the difference between the whole-domain and quadrant-subdivided estimates. Each must lie between 1e-15 and 1. Left unset, the ported integrator’s own defaults (1e-8) apply. | None |
| min_depth | int | The recursion-depth bounds. Left unset, the ported class’s own defaults (0 and 100) apply. | None |
| max_depth | int | The recursion-depth bounds. Left unset, the ported class’s own defaults (0 and 100) apply. | None |
Returns
| Name | Type | Description |
|---|---|---|
| QuadratureResult | The integral, a float carrying the same three fields :func:quadrature returns: status, function_evaluations, and standard_error. |
Examples
>>> import corehydropy as ch
>>> round(ch.quadrature_2d(lambda x, y: x + y, 0, 1, 0, 1), 3)
1.0