quadax.GenzMalikRule
- class quadax.GenzMalikRule(ndim: int, degree: int = 9, norm: Callable | float | int = inf, batch_size: int | None = None)Source
Integrate a function over a box using a fixed degree Genz-Malik rule.
Integration is performed using a fully symmetric rule of the given polynomial degree, with error estimated from an embedded rule two degrees lower sharing its nodes [1] and from null rules on those nodes and one extra orbit [2].
- Parameters:
ndim (
int) – Dimension of the box to integrate over. One dimension is allowed, where the rule reduces to adegreepoint rule on the interval, but a 1D rule such asGaussKronrodRulereaches a far higher degree for the same nodes and is the better choice there.degree (
int) – Polynomial degree of the rule, one of 7, 9, 11 or 13. Higher degrees are worth their extra nodes only on integrands smooth enough to be resolved by them.norm (
int,callable) – Norm to use for measuring error for vector valued integrands. No effect if the integrand is scalar valued. If an int, uses p-norm of the given order, otherwise should be callable.batch_size (
int, optional) – Number of points to evaluate the integrand at simultaneously. The default evaluates all the rule’s nodes at once.
Notes
The number of integrand evaluations per application is
2**ndimfrom the corner orbit, plus a polynomial inndimof degree(degree - 3) // 2from the rest, plus2*ndimfor the orbit the error estimate adds:ndim
degree 7
degree 9
degree 11
degree 13
1
9
11
13
15
2
21
33
49
69
3
39
77
143
245
4
65
153
345
705
5
103
273
723
1725
6
161
453
1365
3729
8
417
1105
3921
13345
10
1265
2605
9405
37409
The extra orbit is what lets the error be estimated over a space of null rules rather than from a single one, which is worth its
2*ndimnodes several times over; the same counts appear in [2]. It carries no integration weight, so the value the rule returns is the classical one.Raising the degree therefore costs more the higher the dimension, and no degree escapes the exponential corner term, which overtakes the polynomial part around
ndimof 7 at degree 7 and progressively later at higher degrees. Both growths are in the rule itself, before an adaptive routine multiplies them by a number of regions that grows withndimin its own right.The rule has negative weights, increasingly so as
ndimgrows, so it is not guaranteed to return a positive value for a positive integrand and can lose precision to cancellation in high dimensions. Degrees 9 and 11 carry rather less negative weight than degree 7 does, so their extra nodes buy conditioning as well as degree; degree 13 carries considerably more, and in low precision can give back what its degree gains.References
Methods
integrate(fun, a, b, args)Integrate a function over a box using a nested cubature rule.
norm(x)Norm to use for measuring error for vector valued integrands.
Attributes
Dimension of the domain this rule integrates over.
How many evaluations of the integrand one application of the rule costs.