IteratedQuadrature

(Source code, png)

../../_images/IteratedQuadrature.png
class IteratedQuadrature(*args)

Multivariate integration algorithm.

Parameters:
univariateQuadratureIntegrationAlgorithm

By default, the integration algorithm is the Gauss-Kronrod algorithm (GaussKronrod) with the parameters IteratedQuadrature-MaximumSubIntervals, IteratedQuadrature-MaximumError, IteratedQuadrature-Rule in ResourceMap.

Methods

getAlgorithm()

Accessor to the underlying 1D integration algorithm.

getClassName()

Accessor to the object's name.

getName()

Accessor to the object's name.

hasName()

Test if the object is named.

integrate(*args)

Evaluation of the integral of f on a domain.

setAlgorithm(algorithm)

Set the underlying 1D integration algorithm.

setName(name)

Accessor to the object's name.

Notes

This class enables to approximate the following integral:

I_f = \int_{a}^{b}\, \int_{l_1(x_0)}^{u_1(x_0)}\, \int_{l_2(x_0, x_1)}^{u_2(x_0,x_1)}\, \int_{l_{n-1}(x_0, \dots, x_{n-2})}^{u_{n-1}(x_0, \dots, x_{n-2})} \, f(x_0, \dots, x_{n-1})\di{x_{n-1}}\dots\di{x_0}

with f: \Rset^n \mapsto \Rset^p, l_k, u_k: \Rset^k \mapsto \Rset and n\geq 1. For n=1, there is no bound functions l_k and u_k.

Note that the default parametrisation of the GaussKronrod class leads to a more precise evaluation of the integral but at a greater cost.

It is recommended to increase the order of the quadrature rule and the number of subintervals if the integrand or one of the bound functions is smooth but with many oscillations.

When the function f: \Rset \mapsto \Rset^p has a scalar input, use the iterated quadrature algorithm of the GaussKronrod class.

Examples

Create an iterated quadrature algorithm:

>>> import openturns as ot
>>> import math as m
>>> a = -m.pi
>>> b = m.pi
>>> f = ot.SymbolicFunction(['x', 'y'], ['1+cos(x)*sin(y)'])
>>> l = [ot.SymbolicFunction(['x'], [' 2+cos(x)'])]
>>> u = [ot.SymbolicFunction(['x'], ['-2-cos(x)'])]

Evaluate the integral with high precision:

>>> Iref = ot.IteratedQuadrature(ot.GaussKronrod(100000, 1e-13, ot.GaussKronrodRule(ot.GaussKronrodRule.G11K23))).integrate(f, a, b, l, u)

Evaluate the integral with the default IteratedQuadrature algorithm:

>>> Idefault = ot.IteratedQuadrature().integrate(f, a, b, l, u)
>>> relative_error = abs(1.0-Idefault[0]/Iref[0])
__init__(*args)
getAlgorithm()

Accessor to the underlying 1D integration algorithm.

Returns:
algoIntegrationAlgorithm

The 1D integration algorithm used recursively over the dimensions of the integration domain.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

integrate(*args)

Evaluation of the integral of f on a domain.

Available usages:

integrate(f, interval)

integrate(f, a, b, lowerBoundFunctions, upperBoundFunctions)

Parameters:
fFunction, f: \Rset^n \mapsto \Rset^p

The integrand function.

intervalInterval, interval \in \Rset^n

The integration domain.

a,bfloat

Bounds of the integration interval of the first scalar input x_0

lowerBoundFunctions, upperBoundFunctionslist of Function

List of n functions (l_0, \dots, l_{n-1}) and (u_0, \dots, u_{n-1}) where l_k, u_k: \Rset^k \mapsto \Rset defining the integration domain as defined above. The bound functions can cross each other.

Returns:
valuePoint

Approximation of the integral.

setAlgorithm(algorithm)

Set the underlying 1D integration algorithm.

Parameters:
algoIntegrationAlgorithm

The 1D integration algorithm used recursively over the dimensions of the integration domain.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Examples using the class

Estimate a multivariate integral with IteratedQuadrature

Estimate a multivariate integral with IteratedQuadrature