Class SimpsonIntegrator1D

  • All Implemented Interfaces:

    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 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>
        f - The function to integrate, not null
        lower - The lower bound, not null
        upper - The upper bound, not null
        The result of the integration