Library
Module
Module type
Parameter
Class
Class type
Routines for one dimensional numerical integration.
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;
}
Function_not_finite(x)
is raised when the function one seeks to integrate returns NaN, infinity
or neg_infinity
at x
.
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
returns a function integ
so that integ f a b
is 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))
. ⚠ BEWARE that qag integrator
creates a workspace that will be used for all calls of integ
, so you should not call integ
inside f
or call the same integ
in parallel.
Keywords: automatic integrator, general-purpose, integrand examinator, globally adaptive, Gauss-Kronrod.