Class MidPointQuadrature

java.lang.Object
com.irurueta.numerical.integration.Quadrature
com.irurueta.numerical.integration.MidPointQuadrature
Direct Known Subclasses:
ExponentialMidPointQuadrature, InfinityMidPointQuadrature, LowerSquareRootMidPointQuadrature, UpperSquareRootMidPointQuadrature

public class MidPointQuadrature extends Quadrature
Implementation of quadrature using mid-point algorithm. Mid-point algorithm is suitable for improper integrations, which consists of the following situations: - integrand goes to a finite limiting value at finite upper and lower limits, but cannot be evaluated right on one of those limits (e.g. sin(x)/x at x = 0) - the upper limit is positive infinity, or the lower limit is negative infinity. - integrand has an integrable singularity at either limit (e.g. x^-0.5 at x = 0) - integrand has an integrable singularity at a known place between its upper and lower limits. - integrand has an integrable singularity at an unknown place between its upper and lower limits.

Impossible integrals, such as those being infinite (e.g. integral from 1 to infinity of x^-1) or those that have no limiting sense (e.g. integral from -infinity to infinity of cos(x)) cannot be handled by this implementation.

  • Field Details

    • a

      private final double a
      Lower limit of integration.
    • b

      private final double b
      Upper limit of integration.
    • s

      private double s
      Current value of integral.
    • listener

      protected final SingleDimensionFunctionEvaluatorListener listener
      Listener to evaluate single dimension functions at required points.
  • Constructor Details

    • MidPointQuadrature

      public MidPointQuadrature(double a, double b, SingleDimensionFunctionEvaluatorListener listener)
      Constructor.
      Parameters:
      a - Lower limit of integration.
      b - Upper limit of integration.
      listener - listener to evaluate a single dimension function at required points.
  • Method Details

    • getA

      public double getA()
      Gets lower limit of integration.
      Returns:
      lower limit of integration.
    • getB

      public double getB()
      Gets upper limit of integration.
      Returns:
      upper limit of integration.
    • getS

      public double getS()
      Gets current value of integral.
      Returns:
      current value of integral.
    • next

      public double next() throws EvaluationException
      Returns the value of the integral at the nth stage of refinement.
      Specified by:
      next in class Quadrature
      Returns:
      the value of the integral at the nth stage of refinement.
      Throws:
      EvaluationException - Raised if something failed during the evaluation.
    • getType

      public QuadratureType getType()
      Gets type of quadrature.
      Specified by:
      getType in class Quadrature
      Returns:
      type of quadrature.
    • func

      protected double func(double x) throws EvaluationException
      Evaluates function at x.
      Parameters:
      x - point where function is evaluated.
      Returns:
      result of evaluation.
      Throws:
      EvaluationException - if evaluation fails.