Gauss-Kronrod Quadrature Rules for Python
kronrod is a Python library for computing the abscissas and weights of
Gauss-Kronrod quadrature rules. Given an N-point Gauss quadrature rule,
the library optimally adds N+1 points to produce a 2N+1 point
Gauss-Kronrod rule for numerical integration.
The advantage of using a Gauss and Gauss-Kronrod pair is that the second rule, which uses 2*N+1 points, actually includes the N points in the previous Gauss rule. This means that the function values from that computation can be reused. This efficiency comes at the cost of a mild reduction in the degree of polynomial precision of the Gauss-Kronrod rule.
import kronrod
# Compute a 3-point Gauss / 7-point Gauss-Kronrod rule
x, w1, w2 = kronrod.kronrod(3)
print("Abscissas:", x)
print("Gauss-Kronrod weights:", w1)
print("Gauss weights:", w2)
# Adjust the rule from [-1, +1] to [0, 1]
x_adj, w1_adj, w2_adj = kronrod.kronrod_adjust(0.0, 1.0, 3, x, w1, w2)pip install kronrodRequires Python 3.10+ and NumPy. See the full installation guide for uv, poetry, and source builds.
- Theory — Gauss-Kronrod quadrature, Kronrod extension, error estimation
- Quickstart — runnable examples
- API Reference — function signatures and parameters
- References — literature citations
| Function | Description |
|---|---|
abwe1 |
Calculate a Kronrod abscissa and weight |
abwe2 |
Calculate a Gaussian abscissa and two weights |
kronrod |
Add N+1 points to an N-point Gaussian rule |
r8_abs |
Return the absolute value of a double |
timestamp |
Print the current YMDHMS date as a time stamp |
- Robert Piessens, Maria Branders, "A Note on the Optimal Addition of Abscissas to Quadrature Formulas of Gauss and Lobatto," Mathematics of Computation, Volume 28, Number 125, January 1974, pages 135-139.
The original FORTRAN77 code was written by Robert Piessens and Maria Branders. The C translation was made by John Burkardt and is distributed under the LGPL-2.1 license.
LGPL-2.1 — see LICENSE.