## Class SimpsonIntegrator1D

• All Implemented Interfaces:
Integrator<Double,​Double,​Function<Double,​Double>>

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
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
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### SimpsonIntegrator1D

public SimpsonIntegrator1D()
• ### 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 class Integrator1D<Double,​Double>
Parameters:
f - The function to integrate, not null
lower - The lower bound, not null
upper - The upper bound, not null
Returns:
The result of the integration