{ } Raw JSON

bundles / scipy 1.17.1 / scipy / integrate / _rules / _genz_malik / GenzMalikCubature

class

scipy.integrate._rules._genz_malik:GenzMalikCubature

source: /scipy/integrate/_rules/_genz_malik.py :11

Signature

class   GenzMalikCubature ( ndim degree = 7 lower_degree = 5 xp = None )

Members

Summary

Genz-Malik cubature.

Extended Summary

Genz-Malik is only defined for integrals of dimension >= 2.

Parameters

ndim : int

The spatial dimension of the integrand.

xp : array_namespace, optional

The namespace for the node and weight arrays. Default is None, where NumPy is used.

Attributes

higher : Cubature

Higher-order rule.

lower : Cubature

Lower-order rule.

Examples

Evaluate a 3D integral:
import numpy as np
from scipy.integrate import cubature
from scipy.integrate._rules import GenzMalikCubature
def f(x):
    # f(x) = cos(x_1) + cos(x_2) + cos(x_3)
    return np.sum(np.cos(x), axis=-1)
rule = GenzMalikCubature(3) # Use 3D Genz-Malik
a, b = np.array([0, 0, 0]), np.array([1, 1, 1])
rule.estimate(f, a, b) # True value 3*sin(1), approximately 2.5244
rule.estimate_error(f, a, b)

Aliases

  • scipy.integrate._cubature.GenzMalikCubature