Class MidPointQuadrature
java.lang.Object
com.irurueta.numerical.integration.Quadrature
com.irurueta.numerical.integration.MidPointQuadrature
- Direct Known Subclasses:
ExponentialMidPointQuadrature
,InfinityMidPointQuadrature
,LowerSquareRootMidPointQuadrature
,UpperSquareRootMidPointQuadrature
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final double
Lower limit of integration.private final double
Upper limit of integration.protected final SingleDimensionFunctionEvaluatorListener
Listener to evaluate single dimension functions at required points.private double
Current value of integral.Fields inherited from class com.irurueta.numerical.integration.Quadrature
n
-
Constructor Summary
ConstructorsConstructorDescriptionMidPointQuadrature
(double a, double b, SingleDimensionFunctionEvaluatorListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected double
func
(double x) Evaluates function at x.double
getA()
Gets lower limit of integration.double
getB()
Gets upper limit of integration.double
getS()
Gets current value of integral.getType()
Gets type of quadrature.double
next()
Returns the value of the integral at the nth stage of refinement.Methods inherited from class com.irurueta.numerical.integration.Quadrature
getN
-
Field Details
-
a
private final double aLower limit of integration. -
b
private final double bUpper limit of integration. -
s
private double sCurrent value of integral. -
listener
Listener to evaluate single dimension functions at required points.
-
-
Constructor Details
-
MidPointQuadrature
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
Returns the value of the integral at the nth stage of refinement.- Specified by:
next
in classQuadrature
- Returns:
- the value of the integral at the nth stage of refinement.
- Throws:
EvaluationException
- Raised if something failed during the evaluation.
-
getType
Gets type of quadrature.- Specified by:
getType
in classQuadrature
- Returns:
- type of quadrature.
-
func
Evaluates function at x.- Parameters:
x
- point where function is evaluated.- Returns:
- result of evaluation.
- Throws:
EvaluationException
- if evaluation fails.
-