How this calculation works
Integrate a user-supplied two- or three-variable function over an axis-aligned box, with adaptive regional subdivisions. Existing one-variable rules cannot specify a multidimensional domain or mixed-direction refinement.
I=integral_[a1,b1]…[ad,bd] f(x1,…,xd) dx; adaptive estimate I≈Σ_regions Q7, estimated error≈Σ_regions |Q7-Q5|.A worked example
Integrate f(x,y)=x*y over x in [0,1] and y in [0,2]. The product integral is (1/2)*2=1. This verifies both coordinate bounds and the box-volume scaling.
Good to know
Two or three dimensions; finite box with strictly increasing coordinate bounds; supported elementary real expression; absolute/relative requested tolerance >=1e-8; 100,000 evaluations and 2,000 regions maximum; smooth finite integrands only. Uses adaptive tensor Gauss3/5 difference estimates, not a rigorous error enclosure.
Reference: SciPy cubature documentation and Genz–Malik embedded cubature (opens in a new tab) ↗
Specify the dimension and every coordinate interval
A box integral needs one lower and upper bound for each variable. The expression uses x and y in two dimensions, adding z in three. A changed dimension changes both the allowed variable names and the integration region.
Bounds must be finite and strictly increasing in this calculator. Reversed bounds are rejected rather than silently converted into an orientation sign. An axis-aligned box is not a general curved region; encoding an indicator function can introduce discontinuities outside the intended smooth scope.
Compare this with the Trapezoidal and Simpson integration calculator. Integrate a user-supplied two- or three-variable function over an axis-aligned box, with adaptive regional subdivisions. Existing one-variable rules cannot specify a multidimensional domain or mixed-direction refinement.
Understand multidimensional sample rules
A pair of tensor Gauss cubature rules samples the function at selected interior points of a region and combines them with two different weight sets. The higher-degree rule supplies the contribution estimate, while its difference from the lower-degree rule estimates local numerical error.
The rules are multidimensional constructions. They are not a drawing of one-dimensional rectangles or a claim that every variable can be separated. A nonseparable function such as exp(x*y) is an important check because it cannot be reduced to a simple product of independent one-variable integrals.
Refine regions that appear most difficult
Begin with the full box and retain its estimated contribution and error. Select a high-error region, choose a coordinate direction and split it. Reevaluate its children and replace the parent’s contribution in the accumulated total.
This concentrates samples where the rule detects curvature or variation. A priority queue avoids refining every region equally. The resulting partition is a record of numerical work; its density should not be interpreted as a physical probability or an exact error map.
Combine absolute and relative stopping targets
One tolerance controls both scales through estimatedError≤tol×max(1,abs(integral)). For magnitudes below one this is an absolute criterion; above one it behaves as a relative criterion. The interface does not accept separate absolute and relative settings.
A relative-only test is poorly suited to a result near zero. The total estimated error should be compared against the implementation’s explicit combined threshold. Requested tolerance is not the same as achieved accuracy, so return the estimate, stopping status and resource counts together.
Verify bounds with the polynomial example
For x*y on [0,1] by [0,2], the x integral contributes one half and the y integral contributes two. Their product is one. A mistaken unit-square assumption would instead return one quarter, making this a useful bounds-scaling fixture.
Another exact check uses x²+y²+z² on the unit cube, whose three contributions each equal one third. Such monomials exercise the dimension and volume factors independently of adaptive refinement. The nonseparable reference then exercises behavior beyond these exact polynomial cases.
Treat embedded error as evidence rather than proof
Two rules can agree accidentally when both miss a narrow feature. A peak between their sampled locations may produce a deceptively small difference. Smoothness alone does not guarantee that every feature is resolved at a fixed evaluation budget.
The reported error is therefore an algorithmic estimate unless the implementation provides a separate rigorous enclosure. Varying the tolerances or comparing an independent integration route can increase confidence, but repeated agreement is still not a universal mathematical bound. The regional estimate compares tensor-product three-point and five-point Gauss rules, not a rigorous interval enclosure. It repeatedly subdivides the region with largest estimated error along its longest coordinate axis. A polynomial of low degree may be integrated exactly by both rules, while a narrow unsampled feature can be missed by both. Requested tolerance therefore describes the stopping criterion for the error estimate, not a theorem about every elementary input expression. Reaching the evaluation or region cap with an unmet criterion returns unresolved. The expression parser accepts only supported real arithmetic and named variables; it does not execute JavaScript from the input.
Report resource and integrand failures explicitly
The evaluation and region caps prevent a difficult expression from expanding without limit. Reaching a cap should return an unresolved error, not claim the requested tolerance was met. Nonfinite sample values must also stop a smooth finite-integrand calculation.
Singularities, infinite intervals and highly oscillatory domains can need specialized transformations or rules. They are outside this first scope. A failed run identifies a limitation of this bounded calculation and does not prove that the underlying integral fails to exist.
A few questions, answered
Is this repeated Simpson integration?
No. It uses a multidimensional embedded rule and adaptive box subdivision. Repeated one-dimensional integration is a useful independent comparison, but it is a different algorithm.
Does the error estimate prove accuracy?
No. The difference between two sample rules estimates error and can miss unsampled features. A rigorous bound needs additional analysis.
Can I use infinite limits or singularities?
The initial scope requires finite bounds and a finite smooth integrand. Infinite limits and singularities need separate transformations or methods.
What happens when the evaluation cap is reached?
The result must be labeled unfinished or unresolved. Its current estimate and resource counts remain useful, but the requested accuracy has not been established.