Package uk.ac.starlink.dpac.math
Class Integral
java.lang.Object
uk.ac.starlink.dpac.math.Integral
Performs indefinite numerical integration using an adaptive Simpson's rule.
An instance of this class represents the definite integral over a
given interval, but it provides methods that permit adaptive
integration and the extraction of (a numerical form) of the antiderivative
function.
- Since:
- 15 Mar 2018
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an integral with given bounds.Constructs an integral with given bounds and supplied function evaluations.Constructs an integral with a number of sub-integrals covering the interval of interest. -
Method Summary
Modifier and TypeMethodDescriptionint
count()
Returns the number of nodes whose recursive data provides the output of this integral function.void
fill
(double tol) Recursively populates the child nodes of this integral so as to achieve a given tolerance in calculation accuracy.static NumericFunction
Adaptively integrates a given function with the calculation broken up into sub-intervals at supplied points.int
store
(double[] x, double[] y, int index) Flattens the recursive information contained by this integral into a pair of arrays represting (x,y) samples giving the antiderivative function.
-
Constructor Details
-
Integral
Constructs an integral with given bounds and supplied function evaluations.- Parameters:
f
- function to integratelo
- lower bound of integration intervalhi
- upper bound of integration intervalflo
- function evaluattion atlo
fhi
- function evaluattion athi
-
Integral
Constructs an integral with given bounds.- Parameters:
f
- function to integratelo
- lower bound of integration intervalhi
- upper bound of integration interval
-
Integral
Constructs an integral with a number of sub-integrals covering the interval of interest.- Parameters:
f
- function to integratesubs
- contiguous sub-intervals; it is the responsibility of the caller to populate these with their own recursive sub-intervals as required
-
-
Method Details
-
fill
public void fill(double tol) Recursively populates the child nodes of this integral so as to achieve a given tolerance in calculation accuracy.- Parameters:
tol
- tolerance
-
count
public int count()Returns the number of nodes whose recursive data provides the output of this integral function. -
store
public int store(double[] x, double[] y, int index) Flattens the recursive information contained by this integral into a pair of arrays represting (x,y) samples giving the antiderivative function.- Parameters:
x
- array to populate with X valuesy
- array to populate with Y (integrated) valuesindex
- index of thex
andy
arrays from which the results should be inserted- Returns:
- number of samples inserted
-
integrate
Adaptively integrates a given function with the calculation broken up into sub-intervals at supplied points. The result will be aggregated from sub-integrals with boundaries at each of the X points supplied, and further broken up within each such sub-region as the adaptive algorithm requires to reach the supplied tolerance.- Parameters:
f
- function to integratepoints
- ordered list of samples on X axis at which evaluations will be forcedtol
- tolerance parameter controlling recursion- Returns:
- numeric function giving integral of
f
over the range given by the first and last elements ofpoints
-