quad_rule, a C++ code which sets up a variety of quadrature rules, used to approximate the integral of a function over various domains.

The code 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.


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


quad_rule is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Programs:

ALPERT_RULE, a C++ code which can set up an Alpert quadrature rule for functions which are regular, log(x) singular, or 1/sqrt(x) singular.

CLENSHAW_CURTIS_RULE, a C++ code which defines a Clenshaw Curtis quadrature rule.

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

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

LINE_NCC_RULE, a C++ code which computes a Newton Cotes Closed (NCC) quadrature rule for the line, that is, for an interval of the form [A,B], using equally spaced points which include the endpoints.

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

QUADMOM, a C++ code 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).

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


TEST_INT, a C++ code which defines test integrands for 1D quadrature rules.

Source Code:

Last revised on 05 April 2020.