NumericalQuadratureΒΆ

numquad.spad line 1

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 containsindent{3} 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 indent{0}indent{0} 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 center{ABS(S(i) - S(i-1)) < eps_r * ABS(S(i-1))} center{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 par 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. par 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. par 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. par 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 parmeters for each subinterval. This is useful where a large number of points are needed only in a small fraction of the entire domain. par 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 par The adaptive routines take as an additional parameter nint the number of independent intervals to apply a closed family integrator of the same name. par Notes: Closed family level i uses 1 + 2^i points. Open family level i uses 1 + 3^i points.

aromberg: (Float -> Float, Float, Float, Float, Float, Integer, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
romberg(fn, a, b, epsrel, epsabs, nmin, nmax) uses the romberg method to numerically integrate function spadvar{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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
trapezoidal(fn, a, b, epsrel, epsabs, nmin, nmax) uses the trapezoidal method to numerically integrate function spadvar{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: (Float -> Float, Float, Float, Float, Float, Integer, Integer) -> Record(value: Float, error: Float, totalpts: Integer, success: Boolean)
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.