FejerAlgorithm¶
(Source code
, png
)
- class FejerAlgorithm(*args)¶
Fejer Integration algorithm
- Available constructors:
FejerAlgorithm(dimension=1, method=FejerAlgorithm.FEJERTYPE1)
FejerAlgorithm(discretization, method=FejerAlgorithmFEJERTYPE1)
- Parameters:
- dimensionint,
The dimension of the functions to integrate. The default discretization is FejerAlgorithm-DefaultMarginalIntegrationPointsNumber in each dimension, see
ResourceMap
.- discretizationsequence of int
The number of nodes in each dimension. The sequence must be non-empty and must contain only positive values.
- methodint, optional
Integer used to select the method of integration. (Amongst ot.FejerAlgorithm.FEJERTYPE1, ot.FejerAlgorithm.FEJERTYPE2 and ot.FejerAlgorithm.CLENSHAWCURTIS).
Default is ot.FejerAlgorithm.FEJERTYPE1
Methods
Accessor to the object's name.
Accessor to the discretization of the tensorized rule.
getName
()Accessor to the object's name.
getNodes
()Accessor to the integration nodes.
Accessor to the integration weights.
hasName
()Test if the object is named.
integrate
(*args)Evaluation of the integral of on an interval.
setName
(name)Accessor to the object's name.
integrateWithNodes
Notes
The FejerAlgorithm algorithm enables to approximate the definite integral:
with , using a the approximation:
where is the -th node of the points and are the associated weight.
For any , let . The Clenshaw-Curtis nodes are:
for any and its associated weights are:
where:
and:
The type-1 Fejer quadrature rule uses the nodes:
for any and the associated weights are:
Finally, the type-2 Fejer quadrature rule is very close to the Clenshaw-Curtis rule. The two methods share the same nodes (except the endpoints that are set to 0 within the Fejer method). The weights of the type-2 Fejer quadrature rule are:
for any .
Examples
Create a FejerAlgorithm algorithm:
>>> import openturns as ot >>> algo = ot.FejerAlgorithm(2) >>> algo = ot.FejerAlgorithm([2, 4, 5])
- __init__(*args)¶
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getDiscretization()¶
Accessor to the discretization of the tensorized rule.
- Returns:
- discretization
Indices
The number of integration point in each dimension.
- discretization
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- getNodes()¶
Accessor to the integration nodes.
- Returns:
- nodes
Sample
The tensorized FejerAlgorithm integration nodes on where is the dimension of the integration algorithm.
- nodes
- getWeights()¶
Accessor to the integration weights.
- Returns:
- weights
Point
The tensorized FejerAlgorithm integration weights on where is the dimension of the integration algorithm.
- weights
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- integrate(*args)¶
Evaluation of the integral of on an interval.
- Available usages:
integrate(f, interval)
integrate(f, interval, xi)
- Parameters:
- Returns:
- value
Point
Approximation of the integral.
- value
Examples
>>> import openturns as ot >>> f = ot.SymbolicFunction(['x'], ['sin(x)']) >>> a = -2.5 >>> b = 4.5 >>> algoF1 = ot.FejerAlgorithm([10]) >>> value = algoF1.integrate(f, ot.Interval(a, b))[0] >>> print(value) -0.590...
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.