Last updated: 2023-03-16.
tf_quant_finance.math.integration.integrate#
Evaluates definite integral.
tf_quant_finance.math.integration.integrate(
func, lower, upper, method=tf_quant_finance.math.integration.IntegrationMethod.C
OMPOSITE_SIMPSONS_RULE, dtype=None, name=None, **kwargs
)
Example#
f = lambda x: x*x
a = tf.constant(0.0)
b = tf.constant(3.0)
integrate(f, a, b) # 9.0
Args:#
func: Represents a function to be integrated. It must be a callable of a singleTensorparameter and return aTensorof the same shape and dtype as its input. It will be called with aTesnorof shapelower.shape + [n](where n is integer number of points) and of the samedtypeaslower.lower: Represents the lower limits of integration.funcwill be integrated between each pair of points defined bylowerandupper.upper: Same shape and dtype aslowerrepresenting the upper limits of intergation.method: Integration method. Instance of IntegrationMethod enum. Default is IntegrationMethod.COMPOSITE_SIMPSONS_RULE.dtype: Dtype of result. Must be real dtype. Defaults to dtype oflower.name: The name to give to the ops created by this function. Default value: None which maps to ‘integrate’.**kwargs: Additional parameters for specific integration method.
Returns:#
Tensor of the same shape and dtype as lower, containing the value of the
definite integral.
Raises: ValueError if method was not recognized.