numquad.spad line 1 [edit on github]
This suite of routines performs numerical quadrature using algorithms derived from the basic trapezoidal rule. Because the error term of this rule contains only even powers of the step size (for open and closed versions), fast convergence can be obtained if the integrand is sufficiently smooth. Each routine returns a Record of type TrapAns, which contains value (Float): estimate of the integral error (Float): estimate of the error in the computation totalpts (Integer): total number of function evaluations success (Boolean): if the integral was computed within the user specified error criterion To produce this estimate, each routine generates an internal sequence of sub-estimates, denoted by S(i), depending on the routine, to which the various convergence criteria are applied. The user must supply a relative accuracy, eps_r
, and an absolute accuracy, eps_a
. Convergence is obtained when either ABS(S(i) - S(i-1)) < eps_r * ABS(S(i-1))
or ABS(S(i) - S(i-1)) < eps_a
are true
statements. The routines come in three families and three flavors: closed: romberg, simpson, trapezoidal open: rombergo, simpsono, trapezoidalo adaptive closed: aromberg, asimpson, atrapezoidal The S(i) for the trapezoidal family is the value of the integral using an equally spaced absicca trapezoidal rule for that level of refinement. The S(i) for the simpson family is the value of the integral using an equally spaced absicca simpson rule for that level of refinement. The S(i) for the romberg family is the estimate of the integral using an equally spaced absicca romberg method. For the i
-
th level, this is an appropriate combination of all the previous trapezodial estimates so that the error term starts with the 2*(i+1)
power only. The three families come in a closed version, where the formulas include the endpoints, an open version where the formulas do not include the endpoints and an adaptive version, where the user is required to input the number of subintervals over which the appropriate closed family integrator will apply with the usual convergence parameters for each subinterval. This is useful where a large number of points are needed only in a small fraction of the entire domain. Each routine takes as arguments: f
integrand a starting point b
ending point eps_r
relative error eps_a
absolute error nmin
refinement level when to start checking for convergence (> 1) nmax
maximum level of refinement The adaptive routines take as an additional parameter nint
the number of independent intervals to apply a closed family integrator of the same name. Notes: Closed family level i
uses 1 + 2^i
points. Open family level i
uses 1 + 3^i
points.
aromberg(fn, a, b, epsrel, epsabs, nmin, nmax, nint)
uses the adaptive romberg method to numerically integrate function fn
over the closed interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
, and where nint
is the number of independent intervals to apply the integrator. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
asimpson(fn, a, b, epsrel, epsabs, nmin, nmax, nint)
uses the adaptive simpson method to numerically integrate function fn
over the closed interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
, and where nint
is the number of independent intervals to apply the integrator. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
atrapezoidal(fn, a, b, epsrel, epsabs, nmin, nmax, nint)
uses the adaptive trapezoidal method to numerically integrate function fn
over the closed interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
, and where nint
is the number of independent intervals to apply the integrator. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
romberg(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the romberg method to numerically integrate function fn
over the closed interval a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
rombergo(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the romberg method to numerically integrate function fn
over the open interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
simpson(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the simpson method to numerically integrate function fn
over the closed interval a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
simpsono(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the simpson method to numerically integrate function fn
over the open interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
trapezoidal(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the trapezoidal method to numerically integrate function fn
over the closed interval a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.
trapezoidalo(fn, a, b, epsrel, epsabs, nmin, nmax)
uses the trapezoidal method to numerically integrate function fn
over the open interval from a
to b
, with relative accuracy epsrel
and absolute accuracy epsabs
, with the refinement levels for convergence checking vary from nmin
to nmax
. The value returned is a record containing the value of the integral, the estimate of the error in the computation, the total number of function evaluations, and either a boolean value which is true
if the integral was computed within the user specified error criterion. See NumericalQuadrature for details.