Compute Integration Scaling Factor#
import minterpy as mp
import numpy as np
Integrating a polynomial in Minterpy involves two main steps:
Integrating the internal polynomial representation over the internal reference domain (currently \([-1, 1]^m\))
Scaling the result by the integration factor, which accounts for the change of variables from \(\Omega\) to \([-1, 1]^m\)
While Minterpy handles this scaling automatically, this guide demonstrates how the integration scaling factor can be computed directly from a Domain instance.
Example: Four-dimensional rectangular domain#
Create a four-dimensional rectangular domain that corresponds to:
Domain instance#
The rectangular domain is defined four pair of bounds, each of which forms and interval for a dimension. We can specify them in a single two-dimensional array of two rows:
bounds = np.array([
[0.0, 5.0],
[10.0, 15.0],
[5.0, 10.0],
[3.0, 7.0],
])
An instance of Domain given an array of bounds can be constructed using the default constructor:
dom = mp.Domain(bounds)
We can verify that the domain is indeed four dimensional:
print(dom.spatial_dimension)
4
and with the appropriate bounds:
print(dom.bounds)
[[ 0. 5.]
[10. 15.]
[ 5. 10.]
[ 3. 7.]]
Integration factor#
The integration factor can be computed via the int_factor() method. The method does not take any arguments and assumes that the integration is carried out over all dimensions. Due to the affine separable transformation, the Jacobian of the transformation is diagonal and its determinant reduces to a product, giving the integration factor:
print(dom.int_factor())
31.25