Class SimpsonIntegrator1D
- java.lang.Object
-
- com.opengamma.strata.math.impl.integration.Integrator1D<Double,Double>
-
- com.opengamma.strata.math.impl.integration.SimpsonIntegrator1D
-
public class SimpsonIntegrator1D extends Integrator1D<Double,Double>
Simpson's integration rule is a Newton-Cotes formula that approximates the function to be integrated with quadratic polynomials before performing the integration. For a function $f(x)$, if three points $x_1$, $x_2$ and $x_3$ are equally spaced on the abscissa with $x_2 - x_1 = h$ then $$ \begin{align*} \int^{x_3} _{x_1} f(x)dx \approx \frac{1}{3}h(f(x_1) + 4f(x_2) + f(x_3)) \end{align*} $$This class is a wrapper for the Commons Math library implementation of Simpson integration.
-
-
Constructor Summary
Constructors Constructor Description SimpsonIntegrator1D()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Double
integrate(Function<Double,Double> f, Double lower, Double upper)
Simpson's integration method.-
Methods inherited from class com.opengamma.strata.math.impl.integration.Integrator1D
integrate
-
-
-
-
Method Detail
-
integrate
public Double integrate(Function<Double,Double> f, Double lower, Double upper)
Simpson's integration method.Note that the Commons implementation fails if the lower bound is larger than the upper - in this case, the bounds are reversed and the result negated.
- Specified by:
integrate
in classIntegrator1D<Double,Double>
- Parameters:
f
- The function to integrate, not nulllower
- The lower bound, not nullupper
- The upper bound, not null- Returns:
- The result of the integration
-
-