Module Integration1D

module Integration1D: sig .. end
Routines for numerical integration.

type integrator =
| GAUSS15 (*7 - 15 points*)
| GAUSS21 (*10 - 21 points*)
| GAUSS31 (*15 - 31 points*)
| GAUSS41 (*20 - 41 points*)
| GAUSS51 (*25 - 51 points*)
| GAUSS61 (*30 - 61 points*)
Choice of local integration rule: which Gauss-Kronrod pair is used.

type reliability =
| OK (*normal and reliable termination of the routine. it is assumed that the requested accuracy has been achieved.*)
| Limit (*maximum number of subdivisions allowed has been achieved. one can allow more subdivisions by increasing the value of limit.

However, if this yields no improvement it is rather advised to analyze the integrand in order to determine the integration difficulties. If the position of a local difficulty can be determined (e.g. singularity, discontinuity within the interval) one will probably gain from splitting up the interval at this point and calling the integrator on the subranges. If possible, an appropriate special-purpose integrator should be used which is designed for handling the type of difficulty involved.

| Roundoff (*The occurrence of roundoff error is detected, which prevents the requested tolerance from being achieved.*)
| Bad_integrand (*Extremely bad integrand behaviour occurs at some points of the integration interval.*)

type result = {
   res : float; (*Approximation to the integral.*)
   err : float; (*Estimate of the modulus of the absolute error, which should equal or exceed abs(res - result).*)
   neval : int; (*Number of integrand evaluations.*)
   nsub : int; (*Number of sub-intervals used <= limit.*)
   msg : reliability;
exception Function_returns_NaN of float * string
Function_returns_NaN(x, x_str) is raised when the function one seeks to integrate returns NaN at x. x_str is simply the string representation of value of x to ease debugging.
type workspace 
Temporary memory used by the integration routines.
val workspace : integrator -> int -> workspace
workspace i limit creates a workspace for the integrator i that can handle up to limit sub-intervals.
val qag : ?limit:int ->
?workspace:workspace ->
integrator ->
?epsabs:float ->
?epsrel:float -> (float -> float) -> float -> float -> result
qag integrator f a b return an approximation i to the integral f over the interval (a,b) hopefully satisfying following claim for accuracy abs(i - true_result) <= max epsabs (epsrel*abs(i)).
limit : gives an upper-bound on the number of sub-intervals in the partition of (a,b); must satisfy limit >= 1. Default: 50.
workspace : Temporary memory used by the integration routines. It is recommended to allocate this memory outside loops. Default: new temporary memory is allocated as needed. A nice way of allocating temprary ressources once only is to use partial evaluation: let integ = qag integrator and then use it repeatedly as integ f a b.
epsabs : absolute accuracy requested (default 1.49E-8).
epsrel : relative accuracy requested (default 1.49E-8).