Class DiscreteTrapezoidIntegrator
The trapezoid rule on a fixed number of evenly spaced evaluations of a function over [a, b], the ends included.
public sealed class DiscreteTrapezoidIntegrator : Integrator
- Inheritance
-
DiscreteTrapezoidIntegrator
- Inherited Members
Remarks
Immutable. Its accuracy is QuantLib's Null<Real>(): the rule runs its evaluations and reports no error.
Fewer than two evaluations are refused, where QuantLib's count of intervals wraps below zero and its loop runs about
2⁶⁴ times (discreteintegrals.cpp:74-79).
Constructors
DiscreteTrapezoidIntegrator(int)
Initializes a new instance of the DiscreteTrapezoidIntegrator class.
public DiscreteTrapezoidIntegrator(int evaluations)
Parameters
evaluationsintThe number of evaluations, at least 2.
Exceptions
- ArgumentOutOfRangeException
evaluationsis below 2.
Methods
IntegrateCore(Func<double, double>, double, double)
The rule's integral over [a, b], a below b, with the number of evaluations it made and its error estimate, if it computes one.
protected override IntegrationResult IntegrateCore(Func<double, double> f, double a, double b)
Parameters
Returns
- IntegrationResult
The integral, the number of evaluations and the error estimate, or null for none.
Exceptions
- NanoQLException
The evaluations were set below 2 (SetMaxEvaluations(int)).