Gaussian quadrature explained
In numerical analysis, an -point Gaussian quadrature rule, named after Carl Friedrich Gauss, is a quadrature rule constructed to yield an exact result for polynomials of degree or less by a suitable choice of the nodes and weights for .
The modern formulation using orthogonal polynomials was developed by Carl Gustav Jacobi in 1826. The most common domain of integration for such a rule is taken as, so the rule is stated as
which is exact for polynomials of degree or less. This exact rule is known as the Gauss–Legendre quadrature rule. The quadrature rule will only be an accurate approximation to the integral above if is well-approximated by a polynomial of degree or less on .
The Gauss–Legendre quadrature rule is not typically used for integrable functions with endpoint singularities. Instead, if the integrand can be written as
where is well-approximated by a low-degree polynomial, then alternative nodes and weights will usually give more accurate quadrature rules. These are known as Gauss–Jacobi quadrature rules, i.e.,
Common weights include (Chebyshev–Gauss) and . One may also want to integrate over semi-infinite (Gauss–Laguerre quadrature) and infinite intervals (Gauss–Hermite quadrature).
It can be shown (see Press et al., or Stoer and Bulirsch) that the quadrature nodes are the roots of a polynomial belonging to a class of orthogonal polynomials (the class orthogonal with respect to a weighted inner-product). This is a key observation for computing Gauss quadrature nodes and weights.
Gauss–Legendre quadrature
For the simplest integration problem stated above, i.e., is well-approximated by polynomials on
, the associated orthogonal polynomials are
Legendre polynomials, denoted by . With the -th polynomial normalized to give, the -th Gauss node,, is the -th root of and the weights are given by the formula
Some low-order quadrature rules are tabulated below (over interval, see the section below for other intervals).
Number of points, | Points, | Weights, |
---|
1 | 0 | 2 |
2 |
} | ±0.57735... | 1 |
3 | 0 |
| 0.888889... |
} | ±0.774597... |
| 0.555556... |
4 |
}} | ±0.339981... |
} | 0.652145... |
}} | ±0.861136... |
} | 0.347855... |
5 | 0 |
| 0.568889... |
}} | ±0.538469... |
} | 0.478629... |
}} | ±0.90618... |
} | 0.236927... | |
Change of interval
An integral over must be changed into an integral over before applying the Gaussian quadrature rule. This change of interval can be done in the following way:
with
Applying the
point Gaussian quadrature
rule then results in the following approximation:
Example of two-point Gauss quadrature rule
Use the two-point Gauss quadrature rule to approximate the distance in meters covered by a rocket from
to
as given by
Change the limits so that one can use the weights and abscissae given in Table 1. Also, find the absolute relative true error. The true value is given as 11061.34 m.
Solution
First, changing the limits of integration from
to
gives
Next, get the weighting factors and function argument values from Table 1 for the two-point rule,
Now we can use the Gauss quadrature formulasince
Given that the true value is 11061.34 m, the absolute relative true error,
\left|\varepsilont\right|
is
Other forms
The integration problem can be expressed in a slightly more general way by introducing a positive weight function into the integrand, and allowing an interval other than . That is, the problem is to calculatefor some choices of,, and . For,, and, the problem is the same as that considered above. Other choices lead to other integration rules. Some of these are tabulated below. Equation numbers are given for Abramowitz and Stegun (A & S).
Fundamental theorem
Let be a nontrivial polynomial of degree such that
Note that this will be true for all the orthogonal polynomials above, because each is constructed to be orthogonal to the other polynomials for, and is in the span of that set.
If we pick the nodes to be the zeros of, then there exist weights which make the Gaussian quadrature computed integral exact for all polynomials of degree or less. Furthermore, all these nodes will lie in the open interval .
To prove the first part of this claim, let be any polynomial of degree or less. Divide it by the orthogonal polynomial to getwhere is the quotient, of degree or less (because the sum of its degree and that of the divisor must equal that of the dividend), and is the remainder, also of degree or less (because the degree of the remainder is always less than that of the divisor). Since is by assumption orthogonal to all monomials of degree less than, it must be orthogonal to the quotient . Therefore
Since the remainder is of degree or less, we can interpolate it exactly using interpolation points with Lagrange polynomials, where
We have
Then its integral will equal
where, the weight associated with the node, is defined to equal the weighted integral of (see below for other formulas for the weights). But all the are roots of, so the division formula above tells us thatfor all . Thus we finally have
This proves that for any polynomial of degree or less, its integral is given exactly by the Gaussian quadrature sum.
To prove the second part of the claim, consider the factored form of the polynomial . Any complex conjugate roots will yield a quadratic factor that is either strictly positive or strictly negative over the entire real line. Any factors for roots outside the interval from to will not change sign over that interval. Finally, for factors corresponding to roots inside the interval from to that are of odd multiplicity, multiply by one more factor to make a new polynomial
This polynomial cannot change sign over the interval from to because all its roots there are now of even multiplicity. So the integralsince the weight function is always non-negative. But is orthogonal to all polynomials of degree or less, so the degree of the productmust be at least . Therefore has distinct roots, all real, in the interval from to .
General formula for the weights
The weights can be expressed as
where
is the coefficient of
in
. To prove this, note that using
Lagrange interpolation one can express in terms of
as
because has degree less than and is thus fixed by the values it attains at different points. Multiplying both sides by and integrating from to yields
The weights are thus given by
This integral expression for
can be expressed in terms of the orthogonal polynomials
and
as follows.
We can write
where
is the coefficient of
in
. Taking the limit of to
yields using L'Hôpital's rule
We can thus write the integral expression for the weights as
In the integrand, writing
yields
provided
, because
is a polynomial of degree which is then orthogonal to
. So, if is a polynomial of at most nth degree we have
We can evaluate the integral on the right hand side for
as follows. Because
is a polynomial of degree, we have
where is a polynomial of degree
. Since is orthogonal to
we have
We can then write
The term in the brackets is a polynomial of degree
, which is therefore orthogonal to
. The integral can thus be written as
According to equation, the weights are obtained by dividing this by
and that yields the expression in equation .
can also be expressed in terms of the orthogonal polynomials
and now
. In the 3-term recurrence relation
pn+1(xi)=(a)pn(xi)+(b)pn-1(xi)
the term with
vanishes, so
in Eq. (1) can be replaced by
.
Proof that the weights are positive
Consider the following polynomial of degree
where, as above, the are the roots of the polynomial
. Clearly
. Since the degree of
is less than
, the Gaussian quadrature formula involving the weights and nodes obtained from
applies. Since
for not equal to, we have
Since both
and
are non-negative functions, it follows that
.
Computation of Gaussian quadrature rules
There are many algorithms for computing the nodes and weights of Gaussian quadrature rules. The most popular are the Golub-Welsch algorithm requiring operations, Newton's method for solving
using the three-term recurrence for evaluation requiring operations, and asymptotic formulas for large
n requiring operations.
Recurrence relation
Orthogonal polynomials
with
for
for a scalar product
, degree
and leading coefficient one (i.e.
monic orthogonal polynomials) satisfy the recurrence relation
and scalar product defined
for
where is the maximal degree which can be taken to be infinity, and where
. First of all, the polynomials defined by the recurrence relation starting with
have leading coefficient one and correct degree. Given the starting point by
, the orthogonality of
can be shown by induction. For
one has
Now if
are orthogonal, then also
, because in
all scalar products vanish except for the first one and the one where
meets the same orthogonal polynomial. Therefore,
However, if the scalar product satisfies
(which is the case for Gaussian quadrature), the recurrence relation reduces to a three-term recurrence relation: For
is a polynomial of degree less than or equal to . On the other hand,
is orthogonal to every polynomial of degree less than or equal to . Therefore, one has
and
for . The recurrence relation then simplifies to
or
(with the convention
) where
(the last because of
(xpr,pr-1)=(pr,xpr-1)=(pr,pr)
, since
differs from
by a degree less than).
The Golub-Welsch algorithm
The three-term recurrence relation can be written in matrix form
J\tilde{P}=x\tilde{P}-pn(x)en
where
\tilde{P}=\begin{bmatrix}p0(x)&p1(x)& … &pn-1(x)\end{bmatrix}T
,
is the
th standard basis vector, i.e.,
en=\begin{bmatrix}0& … &0&1\end{bmatrix}T
, and is the following
tridiagonal matrix, called the Jacobi matrix:
The zeros
of the polynomials up to degree, which are used as nodes for the Gaussian quadrature can be found by computing the eigenvalues of this matrix. This procedure is known as
Golub–Welsch algorithm.
For computing the weights and nodes, it is preferable to consider the symmetric tridiagonal matrix
with elements
That is,
and
are
similar matrices and therefore have the same eigenvalues (the nodes). The weights can be computed from the corresponding eigenvectors: If
is a normalized eigenvector (i.e., an eigenvector with euclidean norm equal to one) associated with the eigenvalue, the corresponding weight can be computed from the first component of this eigenvector, namely:
where
is the integral of the weight function
See, for instance, for further details.
Error estimates
The error of a Gaussian quadrature rule can be stated as follows. For an integrand which has continuous derivatives,for some in, where is the monic (i.e. the leading coefficient is) orthogonal polynomial of degree and where
In the important special case of, we have the error estimate
Stoer and Bulirsch remark that this error estimate is inconvenient in practice, since it may be difficult to estimate the order derivative, and furthermore the actual error may be much less than a bound established by the derivative. Another approach is to use two Gaussian quadrature rules of different orders, and to estimate the error as the difference between the two results. For this purpose, Gauss–Kronrod quadrature rules can be useful.
Gauss–Kronrod rules
See main article: Gauss–Kronrod quadrature formula.
If the interval is subdivided, the Gauss evaluation points of the new subintervals never coincide with the previous evaluation points (except at zero for odd numbers), and thus the integrand must be evaluated at every point. Gauss–Kronrod rules are extensions of Gauss quadrature rules generated by adding points to an -point rule in such a way that the resulting rule is of order . This allows for computing higher-order estimates while re-using the function values of a lower-order estimate. The difference between a Gauss quadrature rule and its Kronrod extension is often used as an estimate of the approximation error.
Gauss–Lobatto rules
Also known as Lobatto quadrature, named after Dutch mathematician Rehuel Lobatto. It is similar to Gaussian quadrature with the following differences:
- The integration points include the end points of the integration interval.
- It is accurate for polynomials up to degree, where is the number of integration points.
Lobatto quadrature of function on interval :
Abscissas: is the
st zero of
, here
denotes the standard Legendre polynomial of -th degree and the dash denotes the derivative.
Weights:
Remainder:
Some of the weights are:
Number of points, n | Points, | Weights, |
---|
|
|
|
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
}} |
} |
}} |
} |
|
|
|
|
|
}} |
} |
}} |
} |
|
| |
An adaptive variant of this algorithm with 2 interior nodes is found in GNU Octave and MATLAB as quadl
and integrate
.
References
Bibliography
- Donald G. . Anderson . Gaussian quadrature formulae for
. 1965 . 19 . 91 . 477–481 . Math. Comp. . 10.1090/s0025-5718-1965-0178569-1 . free .
- News: Bernard . Danloy . Numerical construction of Gaussian quadrature formulas for
and
. Math. Comp. . 1973 . 27 . 124 . 861–869 . 10.1090/S0025-5718-1973-0331730-X . 0331730.
- Web site: Eaton . John W. . Bateman . David . Hauberg . Søren . Wehbring . Rik . Functions of One Variable (GNU Octave) . 28 September 2018 . 2018.
- Adaptive Quadrature - Revisited . Gander . Walter . Gautschi . Walter . BIT Numerical Mathematics . 2000 . 40 . 1 . 84–101 . 10.1023/A:1022318402393 .
- Book: Gauss, Carl Friedrich . Carl Friedrich Gauss . Methodus nova integralium valores per approximationem inveniendi . Comm. Soc. Sci. Göttingen Math . 3 . 1815 . S. 29–76 . datiert 1814, auch in Werke, Band 3, 1876, S. 163–196. English Translation by Wikisource.
- News: Walter . Gautschi . Construction of Gauss–Christoffel Quadrature Formulas . Math. Comp. . 1968 . 22 . 102 . 251–270 . 10.1090/S0025-5718-1968-0228171-0 . 0228171.
- News: Walter . Gautschi . On the construction of Gaussian quadrature rules from modified moments . Math. Comp. . 1970 . 24 . 245–260 . 10.1090/S0025-5718-1970-0285117-6 . 0285177.
- Book: Gautschi, Walter . A Software Repository for Gaussian Quadratures and Christoffel Functions . SIAM . 978-1-611976-34-2 . 2020.
- Gene H. . Golub . Calculation of Gauss Quadrature Rules . Mathematics of Computation . Gene Golub . John H. . Welsch . 23 . 106 . 1969 . 221–230 . 2004418 . 10.1090/S0025-5718-69-99647-1 . free.
- C. G. J. . Jacobi . Carl Gustav Jacob Jacobi . Ueber Gauß' neue Methode, die Werthe der Integrale näherungsweise zu finden . Journal für die Reine und Angewandte Mathematik . 1 . 1826 . S. 301–308 . und Werke, Band 6..
- Kabir . Hossein . Matikolaei . Sayed Amir Hossein Hassanpour . 2017 . Implementing an Accurate Generalized Gaussian Quadrature Solution to Find the Elastic Field in a Homogeneous Anisotropic Media . Journal of the Serbian Society for Computational Mechanics . 11 . 1 . 11–19 . 10.24874/jsscm.2017.11.01.02.
- Book: Kahaner . David . Moler . Cleve . Cleve Moler . Nash . Stephen . Numerical Methods and Software . 1989 . . 978-0-13-627258-8 . registration .
- Teresa . Laudadio . Nicola . Mastronardi . Paul . Van Dooren . Computing Gaussian quadrature rules with high relative accuracy . Numerical Algorithms . 92 . 2023 . 767–793. 10.1007/s11075-022-01297-9. free .
- Dirk P. . Laurie . Computation of Gauss-type quadrature formulas . 2001 . 201–217 . 127 . 1–2 . J. Comput. Appl. Math. . 10.1016/S0377-0427(00)00506-9 . 2001JCoAM.127..201L .
- Web site: Numerical integration - MATLAB integral . MathWorks . 2012.
- News: R. . Piessens . Gaussian quadrature formulas for the numerical integration of Bromwich's integral and the inversion of the laplace transform . 1971 . 5 . 1 . J. Eng. Math. . 1–9 . 10.1007/BF01535429 . 1971JEnMa...5....1P .
- Book: Alfio Quarteroni . Quarteroni . Alfio . Riccardo . Sacco . Fausto . Saleri . Numerical Mathematics . New York . . 425-478 . 2000 . 0-387-98959-5 . Numerical Mathematics . 10.1007/978-3-540-49809-4_10.
- Cordian . Riener . Schweighofer . Markus . Optimization approaches to quadrature: New characterizations of Gaussian quadrature on the line and quadrature with few nodes on plane algebraic curves, on the plane and in higher dimensions . 2018 . Journal of Complexity . 45 . 22–54 . 10.1016/j.jco.2017.10.002 . 1607.08404 .
- Robin P. . Sagar . A Gaussian quadrature for the calculation of generalized Fermi-Dirac integrals . 1991 . Comput. Phys. Commun. . 66 . 271–275 . 2–3 . 10.1016/0010-4655(91)90076-W . 1991CoPhC..66..271S .
- E. . Yakimiw . Accurate computation of weights in classical Gauss–Christoffel quadrature rules . 1996 . J. Comput. Phys. . 129 . 2 . 406–430 . 1996JCoPh.129..406Y . 10.1006/jcph.1996.0258.
External links
- ALGLIB contains a collection of algorithms for numerical integration (in C# / C++ / Delphi / Visual Basic / etc.)
- GNU Scientific Library — includes C version of QUADPACK algorithms (see also GNU Scientific Library)
- From Lobatto Quadrature to the Euler constant e
- Gaussian Quadrature Rule of Integration – Notes, PPT, Matlab, Mathematica, Maple, Mathcad at Holistic Numerical Methods Institute
- Tabulated weights and abscissae with Mathematica source code, high precision (16 and 256 decimal places) Legendre-Gaussian quadrature weights and abscissas, for n=2 through n=64, with Mathematica source code.
- Mathematica source code distributed under the GNU LGPL for abscissas and weights generation for arbitrary weighting functions W(x), integration domains and precisions.
- Gaussian Quadrature in Boost.Math, for arbitrary precision and approximation order
- Gauss–Kronrod Quadrature in Boost.Math
- Nodes and Weights of Gaussian quadrature