Package uk.ac.starlink.dpac.math

# Class Integral

java.lang.Object
uk.ac.starlink.dpac.math.Integral

public class Integral extends Object
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

Constructors
Constructor
Description
`Integral(Function f, double lo, double hi)`
Constructs an integral with given bounds.
`Integral(Function f, double lo, double hi, double flo, double fhi)`
Constructs an integral with given bounds and supplied function evaluations.
`Integral(Function f, Integral[] subs)`
Constructs an integral with a number of sub-integrals covering the interval of interest.

## Method Summary

Modifier and Type
Method
Description
`int`
`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`
`integrate(Function f, double[] points, double tol)`
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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Integral

public Integral(Function f, double lo, double hi, double flo, double fhi)
Constructs an integral with given bounds and supplied function evaluations.

Parameters:
  `f` - function to integrate
  `lo` - lower bound of integration interval
  `hi` - upper bound of integration interval
  `flo` - function evaluattion at `lo`
  `fhi` - function evaluattion at `hi`

### Integral

public Integral(Function f, double lo, double hi)
Constructs an integral with given bounds.

Parameters:
  `f` - function to integrate
  `lo` - lower bound of integration interval
  `hi` - upper bound of integration interval

### Integral

public Integral(Function f, Integral[] subs)
Constructs an integral with a number of sub-integrals covering the interval of interest.

Parameters:
  `f` - function to integrate
  `subs` - 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 values
  `y` - array to populate with Y (integrated) values
  `index` - index of the `x` and `y` arrays from which the results should be inserted
Returns:
  number of samples inserted

### integrate

public static NumericFunction integrate(Function f, double[] points, double tol)
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 integrate
  `points` - ordered list of samples on X axis at which evaluations will be forced
  `tol` - tolerance parameter controlling recursion
Returns:
  numeric function giving integral of `f` over the range given by the first and last elements of `points`