QUADRULE is a FORTRAN77 library which sets up a variety of quadrature rules, used to approximate the integral of a function over various domains.

QUADRULE returns the abscissas and weights for a variety of one dimensional quadrature rules for approximating the integral of a function. The best rule is generally Gauss-Legendre quadrature, but other rules offer special features, including the ability to handle certain weight functions, to approximate an integral on an infinite integration region, or to estimate the approximation error.

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

QUADRULE is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version and a Python version.

### Related Programs:

CLENSHAW_CURTIS_RULE, a FORTRAN77 program which defines a Clenshaw Curtis quadrature rule.

INT_EXACTNESS, a FORTRAN90 program which checks the polynomial exactness of a 1-dimensional quadrature rule for a finite interval.

INT_EXACTNESS_LAGUERRE, a FORTRAN90 program which checks the polynomial exactness of a 1-dimensional quadrature rule for a semi-infinite interval.

INT_EXACTNESS_LEGENDRE, a FORTRAN90 program which tests the polynomial exactness of Gauss-Legendre quadrature rules.

KRONROD, a FORTRAN77 library which can compute a Gauss and Gauss-Kronrod pair of quadrature rules of arbitrary order, by Robert Piessens, Maria Branders.

LAGUERRE_RULE, a FORTRAN77 program which can compute and print a Gauss-Laguerre quadrature rule for estimating the integral of a function with density exp(-x) over the interval [0,+oo).

LINE_FELIPPA_RULE, a FORTRAN77 library which returns the points and weights of a Felippa quadrature rule over the interior of a line segment in 1D.

LINE_NCO_RULE, a FORTRAN77 library which computes a Newton Cotes Open (NCO) quadrature rule, using equally spaced points, over the interior of a line segment in 1D.

PATTERSON_RULE, a FORTRAN77 program which returns the points and weights of a 1D Gauss-Patterson quadrature rule of order 1, 3, 7, 15, 31, 63, 127, 255 or 511.

QUADMOM, a FORTRAN77 library which computes a Gaussian quadrature rule for a weight function rho(x) based on the Golub-Welsch procedure that only requires knowledge of the moments of rho(x).

QUADPACK, a FORTRAN77 library which contains a variety of routines for numerical estimation of integrals in 1D.

QUADRATURE_RULES, a dataset directory which contains sets of files that define quadrature rules over various 1D intervals or multidimensional hypercubes.

QUADRATURE_TEST, a FORTRAN90 program which reads the definition of a multidimensional quadrature rule from three files, applies the rule to a number of test integrals, and prints the results.

R16_HERMITE_RULE, a FORTRAN90 program which can compute and print a Gauss-Hermite quadrature rule, using "quadruple precision real" arithmetic.

TANH_QUAD, a FORTRAN90 library which sets up the tanh quadrature rule;

TANH_SINH_RULE, a FORTRAN90 program which computes and writes out a tanh-sinh quadrature rule of given order.

TEST_INT, a FORTRAN77 library which contains a number of functions that may be used as test integrands for quadrature rules in 1D.

TEST_INT_HERMITE, a FORTRAN77 library which defines some test integration problems over infinite intervals.

TEST_INT_LAGUERRE, a FORTRAN77 library which defines test integrands for the interval [a,+oo) and weight exp(-x);

TOMS351, a FORTRAN77 library which estimates an integral using Romberg integration.

TOMS379, a FORTRAN77 library which estimates an integral.

TOMS418, a FORTRAN77 library which estimates the integral of a function with a sine or cosine factor.

TOMS424, a FORTRAN77 library which estimates the integral of a function using Clenshaw-Curtis quadrature.

TOMS468, a FORTRAN77 library which carries out the "automatic" integration of a function.

TOMS655, a FORTRAN77 library which computes the weights for interpolatory quadrature rule;
this library is commonly called IQPACK;
this is a FORTRAN90 version of ACM TOMS algorithm 655.

TOMS793, a FORTRAN77 library which carries out Gauss quadrature for rational functions, by Walter Gautschi; this is ACM TOMS algorithm 793.

### Reference:

1. Milton Abramowitz, Irene Stegun,
Handbook of Mathematical Functions,
National Bureau of Standards, 1964,
ISBN: 0-486-61272-4,
LC: QA47.A34.
2. Donald Anderson,
Gaussian Quadrature Formulae for the integral from 0 to 1 of -ln(X) f(X) dx,
Mathematics of Computation,
Volume 19, Number 91, July 1965, pages 477-481.
3. Claudio Canuto, Yousuff Hussaini, Alfio Quarteroni, Thomas Zang,
Spectral Methods in Fluid Dynamics,
Springer, 1993,
ISNB13: 978-3540522058,
LC: QA377.S676.
4. Charles Clenshaw, Alan Curtis,
A Method for Numerical Integration on an Automatic Computer,
Numerische Mathematik,
Volume 2, Number 1, December 1960, pages 197-205.
5. Philip Davis, Philip Rabinowitz,
Methods of Numerical Integration,
Second Edition,
Dover, 2007,
ISBN: 0486453391,
LC: QA299.3.D28.
6. Sylvan Elhay, Jaroslav Kautsky,
Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of Interpolatory Quadrature,
ACM Transactions on Mathematical Software,
Volume 13, Number 4, December 1987, pages 399-415.
7. Hermann Engels,
Numerical Quadrature and Cubature,
ISBN: 012238850X,
LC: QA299.3E5.
8. Gwynne Evans,
Practical Numerical Integration,
Wiley, 1993,
ISBN: 047193898X,
LC: QA299.3E93.
9. Simeon Fatunla,
Numerical Methods for Initial Value Problems in Ordinary Differential Equations,
ISBN: 0122499301,
LC: QA372.F35.
10. Walter Gautschi,
Numerical Quadrature in the Presence of a Singularity,
SIAM Journal on Numerical Analysis,
Volume 4, Number 3, September 1967, pages 357-362.
11. Alan Genz, Bradley Keister,
Fully symmetric interpolatory rules for multiple integrals over infinite regions with Gaussian weight,
Journal of Computational and Applied Mathematics,
Volume 71, 1996, pages 299-309.
12. Florian Heiss, Viktor Winschel,
Likelihood approximation by numerical integration on sparse grids,
Journal of Econometrics,
Volume 144, 2008, pages 62-80.
13. Francis Hildebrand,
Introduction to Numerical Analysis,
Dover, 1987,
ISBN13: 978-0486653631,
LC: QA300.H5.
14. Zdenek Kopal,
Numerical Analysis,
John Wiley, 1955,
LC: QA297.K6.
Approximate Calculation of Integrals,
Dover, 2006,
ISBN: 0486445798,
LC: QA311.K713.
16. Prem Kythe, Michael Schaeferkotter,
Handbook of Computational Methods for Integration,
Chapman and Hall, 2004,
ISBN: 1-58488-428-2,
LC: QA299.3.K98.
17. Leon Lapidus, John Seinfeld,
Numerical Solution of Ordinary Differential Equations,
Mathematics in Science and Engineering, Volume 74,
ISBN: 0124366503,
LC: QA3.M32.v74
18. Federico Paris, Jose Canas,
Boundary Element Method: Fundamentals and Applications,
Oxford, 1997,
ISBN: 0-19-856543-7
LC: TA347.B69.P34.
19. Thomas Patterson,
The Optimal Addition of Points to Quadrature Formulae,
Mathematics of Computation,
Volume 22, Number 104, October 1968, pages 847-856.
20. Robert Piessens, Elise deDoncker-Kapenga, Christian Ueberhuber, David Kahaner,
QUADPACK: A Subroutine Package for Automatic Integration,
Springer, 1983,
ISBN: 3540125531,
LC: QA299.3.Q36.
21. Arthur Stroud, Don Secrest,
Prentice Hall, 1966,
LC: QA299.4G3S7.
22. Lloyd Trefethen,
Is Gauss Quadrature Better Than Clenshaw-Curtis?,
SIAM Review,
Volume 50, Number 1, March 2008, pages 67-87.
23. Joerg Waldvogel,
Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
BIT Numerical Mathematics,
Volume 43, Number 1, 2003, pages 1-18.
24. Stephen Wolfram,
The Mathematica Book,
Fourth Edition,
Cambridge University Press, 1999,
ISBN: 0-521-64314-7,
LC: QA76.95.W65.
25. Daniel Zwillinger, editor,
CRC Standard Mathematical Tables and Formulae,
30th Edition,
CRC Press, 1996,
ISBN: 0-8493-2479-3,
LC: QA47.M315.

### List of Routines:

• BASHFORTH_SET sets abscissas and weights for Adams-Bashforth quadrature.
• BDF_SET sets weights for ODE backward differentiation.
• BDF_SUM: an explicit backward difference quadrature rule for [0,1].
• BDFC_SET sets weights for backward differentiation corrector quadrature.
• BDFP_SET sets weights for backward differentiation predictor quadrature.
• CHEB_SET sets abscissas and weights for Chebyshev quadrature.
• CHEBYSHEV1_COMPUTE computes a Gauss-Chebyshev type 1 quadrature rule.
• CHEBYSHEV1_INTEGRAL evaluates a monomial Chebyshev type 1 integral.
• CHEBYSHEV2_COMPUTE computes a Gauss-Chebyshev type 2 quadrature rule.
• CHEBYSHEV2_INTEGRAL evaluates a monomial Chebyshev type 2 integral.
• CHEBYSHEV3_COMPUTE computs a Gauss-Chebyshev type 3 quadrature rule.
• CLENSHAW_CURTIS_COMPUTE computes a Clenshaw Curtis quadrature rule.
• CLENSHAW_CURTIS_SET sets a Clenshaw-Curtis quadrature rule.
• FEJER1_COMPUTE computes a Fejer type 1 quadrature rule.
• FEJER1_SET sets abscissas and weights for Fejer type 1 quadrature.
• FEJER2_COMPUTE computes a Fejer type 2 quadrature rule.
• FEJER2_SET sets abscissas and weights for Fejer type 2 quadrature.
• GEGENBAUER_COMPUTE computes a Gauss-Gegenbauer quadrature rule.
• GEGENBAUER_INTEGRAL: integral of a monomial with Gegenbauer weight.
• GEGENBAUER_RECUR finds the value and derivative of a Gegenbauer polynomial.
• GEGENBAUER_ROOT improves an approximate root of a Gegenbauer polynomial.
• GEN_HERMITE_DR_COMPUTE computes a generalized Gauss-Hermite rule.
• GEN_HERMITE_EK_COMPUTE computes a generalized Gauss-Hermite quadrature rule.
• GEN_HERMITE_INTEGRAL evaluates a monomial generalized Hermite integral.
• GEN_LAGUERRE_EK_COMPUTE: generalized Gauss-Laguerre quadrature rule.
• GEN_LAGUERRE_INTEGRAL evaluates a monomial genearlized Laguerre integral.
• GEN_LAGUERRE_SS_COMPUTE: generalized Gauss-Laguerre quadrature rule.
• GEN_LAGUERRE_SS_RECUR evaluates a generalized Laguerre polynomial.
• GEN_LAGUERRE_SS_ROOT seeks roots of a generalized Laguerre polynomial.
• HERMITE_EK_COMPUTE computes a Gauss-Hermite quadrature rule.
• HERMITE_GK16_SET sets a Hermite Genz-Keister 16 rule.
• HERMITE_GK18_SET sets a Hermite Genz-Keister 18 rule.
• HERMITE_GK22_SET sets a Hermite Genz-Keister 22 rule.
• HERMITE_GK24_SET sets a Hermite Genz-Keister 24 rule.
• HERMITE_INTEGRAL evaluates a monomial Hermite integral.
• HERMITE_SET sets abscissas and weights for Hermite quadrature.
• HERMITE_SS_COMPUTE computes a Gauss-Hermite quadrature rule.
• HERMITE_SS_RECUR finds the value and derivative of a Hermite polynomial.
• HERMITE_SS_ROOT improves an approximate root of a Hermite polynomial.
• IMTQL2 computes all eigenvalues/vectors of a symmetric tridiagonal matrix.
• IMTQLX diagonalizes a symmetric tridiagonal matrix.
• JACOBI_EK_COMPUTE: Elhay-Kautsky method for Gauss-Jacobi quadrature rule.
• JACOBI_INTEGRAL evaluates the integral of a monomial with Jacobi weight.
• JACOBI_SS_COMPUTE computes a Gauss-Jacobi quadrature rule.
• JACOBI_SS_RECUR finds the value and derivative of a Jacobi polynomial.
• JACOBI_SS_ROOT improves an approximate root of a Jacobi polynomial.
• KRONROD_SET sets abscissas and weights for Gauss-Kronrod quadrature.
• LAGUERRE_EK_COMPUTE: Laguerre quadrature rule by the Elhay-Kautsky method.
• LAGUERRE_INTEGRAL evaluates a monomial Laguerre integral.
• LAGUERRE_SET sets abscissas and weights for Laguerre quadrature.
• LAGUERRE_SS_COMPUTE computes a Gauss-Laguerre quadrature rule.
• LAGUERRE_SS_RECUR finds the value and derivative of a Laguerre polynomial.
• LAGUERRE_SS_ROOT improves an approximate root of a Laguerre polynomial.
• LAGUERRE_SUM carries out Laguerre quadrature over [ A, +oo ).
• LEGENDRE_COS2_SET sets a Gauss-Legendre rule for COS(X) * F(X) on [0,PI/2].
• LEGENDRE_COS_SET: Gauss-Legendre rule for COS(X) * F(X) on [-PI/2,PI/2].
• LEGENDRE_DR_COMPUTE: Gauss-Legendre quadrature by Davis-Rabinowitz method.
• LEGENDRE_EK_COMPUTE: Legendre quadrature rule by the Elhay-Kautsky method.
• LEGENDRE_GW_COMPUTE: Legendre quadrature rule by the Golub-Welsch method.
• LEGENDRE_INTEGRAL evaluates a monomial Legendre integral.
• LEGENDRE_LOG_COMPUTE: Gauss-Legendre rules for - LOG(X) * F(X) on [0,1].
• LEGENDRE_LOG_ROOTS is a root finder for LEGENDRE_LOG_COMPUTE.
• LEGENDRE_LOG_SET sets a Gauss-Legendre rule for - LOG(X) * F(X) on [0,1].
• LEGENDRE_LOG_VALUE evaluates a polynomial for LEGENDRE_LOG_ROOT.
• LEGENDRE_POLYNOMIAL_VALUE evaluates a Legendre polynomial.
• LEGENDRE_RECUR finds the value and derivative of a Legendre polynomial.
• LEGENDRE_ROOT improves an approximate root of a Legendre polynomial.
• LEGENDRE_SET sets abscissas and weights for Gauss-Legendre quadrature.
• LEGENDRE_SQRTX2_01_SET: Gauss-Legendre rule for F(X) / SQRT(X) on [0,1].
• LEGENDRE_SQRTX_01_SET sets a Gauss-Legendre rule for SQRT(X) * F(X) on [0,1].
• LEGENDRE_SS_COMPUTE: Gauss-Legendre quadrature by Stroud-Secrest method.
• LEGENDRE_SS_RECUR: value and derivative of a scaled Legendre polynomial.
• LEGENDRE_SS_ROOT: improve approximate root of scaled Legendre polynomial.
• LEGENDRE_X0_01_SET sets a Gauss-Legendre rule for F(X) on [0,1].
• LEGENDRE_X1_01_SET sets a Gauss-Legendre rule for X * F(X) on [0,1].
• LEGENDRE_X1_SET sets a Gauss-Legendre rule for ( 1 + X ) * F(X) on [-1,1].
• LEGENDRE_X2_01_SET sets a Gauss-Legendre rule for X * X * F(X) on [0,1].
• LEGENDRE_X2_SET sets a Gauss-Legendre rule for ( 1 + X )^2 * F(X) on [-1,1].
• LOBATTO_COMPUTE computes a Lobatto quadrature rule.
• LOBATTO_SET sets abscissas and weights for Lobatto quadrature.
• MOULTON_SET sets weights for Adams-Moulton quadrature.
• NC_COMPUTE computes a Newton-Cotes quadrature rule.
• NCC_COMPUTE: Newton-Cotes Closed quadrature rule.
• NCC_COMPUTE_POINTS: Newton-Cotes Closed points
• NCC_COMPUTE_WEIGHTS: Newton-Cotes Closed weights.
• NCC_SET sets abscissas and weights for Newton-Cotes closed quadrature.
• NCO_COMPUTE computes a Newton-Cotes Open quadrature rule.
• NCO_COMPUTE_POINTS: points for a Newton-Cotes Open quadrature rule.
• NCO_COMPUTE_WEIGHTS: weights for a Newton-Cotes Open quadrature rule.
• NCO_SET sets abscissas and weights for open Newton-Cotes quadrature.
• NCOH_COMPUTE computes a Newton-Cotes Open Half quadrature rule.
• NCOH_COMPUTE_POINTS: points for a Newton-Cotes Open Half quadrature rule.
• NCOH_COMPUTE_WEIGHTS: weights for a Newton-Cotes Open Half quadrature rule.
• NCOH_SET sets abscissas and weights for Newton-Cotes "open half" quadrature.
• PATTERSON_SET sets abscissas and weights for Gauss-Patterson quadrature.
• PYTHAG computes SQRT ( A * A + B * B ) carefully.
• R8_EPSILON returns the R8 roundoff unit.
• R8_FACTORIAL computes the factorial of N.
• R8_FACTORIAL2 computes the double factorial function.
• R8_GAMMA evaluates Gamma(X) for a real argument.
• R8_HUGE returns a "huge" R8.
• R8_HYPER_2F1 evaluates the hypergeometric function F(A,B,C,X).
• R8_PSI evaluates the function Psi(X).
• R8VEC_DOT_PRODUCT finds the dot product of a pair of R8VEC's.
• R8VEC_PRINT prints an R8VEC.
• R8VEC_PRODUCT multiplies the entries of an R8VEC.
• R8VEC_REVERSE reverses the elements of an R8VEC.