Comparison between 2-point Gaussian and trapezoidal quadrature. The blue curve shows the function whose definite integral on the interval [−1, 1] is to be calculated (the integrand). The trapezoidal rule approximates the function with a linear function that coincides with the integrand at the endpoints of the interval and is represented by an orange dashed line. The approximation is apparently not good, so the error is large (the trapezoidal rule gives approximation of the integral equal to , while the correct value is 2⁄3). To obtain more exact result, the interval must be partitioned to many subintervals and then composite trapezoidal rule must be used, which requires much more calculations. The Gaussian quadrature chooses more suitable points instead, so even a linear function approximates the function better (the black dashed line). As the integrand is the polynomial of degree 3 (), the 2-point Gaussian quadrature rule even returns an exact result.
In numerical analysis, a quadrature rule is an approximation of the definite integral of a function, usually stated as a weighted sum of function values at specified points within the domain of integration. (See numerical integration for more on quadrature rules.) An n-point Gaussian quadrature rule, named after Carl Friedrich Gauss, is a quadrature rule constructed to yield an exact result for polynomials of degree 2n − 1 or less by a suitable choice of the nodes xi and weights wi for i = 1, ..., n. 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 [−1, 1], so the rule is stated as
which is exact for polynomials of degree 2n − 1 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 f(x) is well-approximated by a polynomial of degree 2n − 1 or less on [−1, 1].
The Gauss-Legendre quadrature rule is not typically used for integrable functions with endpoint singularities. Instead, if the integrand can be written as
where g(x) 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.,
It can be shown (see Press, et al., or Stoer and Bulirsch) that the quadrature nodes xi 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.
For the simplest integration problem stated above, i.e., f(x) is well-approximated by polynomials on , the associated orthogonal polynomials are Legendre polynomials, denoted by Pn(x). With the n-th polynomial normalized to give Pn(1) = 1, the i-th Gauss node, xi, is the i-th root of Pn and the weights are given by the formula (Abramowitz & Stegun 1972, p. 887) harv error: no target: CITEREFAbramowitzStegun1972 (help)
Some low-order quadrature rules are tabulated below (over interval [−1, 1], see the section below for other intervals).
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 [−1, 1]. That is, the problem is to calculate
for some choices of a, b, and ω. For a = −1, b = 1, and ω(x) = 1, 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).
Let pn be a nontrivial polynomial of degree n such that
Note that this will be true for all the orthogonal polynomials above, because each pn is constructed to be orthogonal to the other polynomials pj for j≠n, and xk is in the span of that set.
If we pick the n nodes xi to be the zeros of pn, then there exist n weights wi which make the Gauss-quadrature computed integral exact for all polynomials h(x) of degree 2n − 1 or less. Furthermore, all these nodes xi will lie in the open interval (a, b) (Stoer & Bulirsch 2002, pp. 172–175).
To prove the first part of this claim, let h(x) be any polynomial of degree 2n − 1 or less. Divide it by the orthogonal polynomial pn to get
where q(x) is the quotient, of degree n − 1 or less (because the sum of its degree and that of the divisor pn must equal that of the dividend), and r(x) is the remainder, also of degree n − 1 or less (because the degree of the remainder is always less than that of the divisor). Since pn is by assumption orthogonal to all monomials of degree less than n, it must be orthogonal to the quotient q(x). Therefore
Since the remainder r(x) is of degree n − 1 or less, we can interpolate it exactly using n interpolation points with Lagrange polynomialsli(x), where
Then its integral will equal
where wi, the weight associated with the node xi, is defined to equal the weighted integral of li(x) (see below for other formulas for the weights). But all the xi are roots of pn, so the division formula above tells us that
for all i. Thus we finally have
This proves that for any polynomial h(x) of degree 2n − 1 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 pn. 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 a to b will not change sign over that interval. Finally, for factors corresponding to roots xi inside the interval from a to b that are of odd multiplicity, multiply pn by one more factor to make a new polynomial
This polynomial cannot change sign over the interval from a to b because all its roots there are now of even multiplicity. So the integral
since the weight function ω(x) is always non-negative. But pn is orthogonal to all polynomials of degree n-1 or less, so the degree of the product
must be at least n. Therefore pn has n distinct roots, all real, in the interval from a to b.
where, as above, the xj 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 j not equal to i, we have
Since both and are non-negative functions, it follows that .
There are many algorithms for computing the nodes xi and weights wi of Gaussian quadrature rules. The most popular are the Golub-Welsch algorithm requiring O(n2) operations, Newton's method for solving using the three-term recurrence for evaluation requiring O(n2) operations, and asymptotic formulas for large n requiring O(n) operations.
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 n 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 r − 1. On the other hand, is orthogonal to every polynomial of degree less than or equal to r − 1. Therefore, one has and for s < r − 1. The recurrence relation then simplifies to
(with the convention ) where
(the last because of , since differs from by a degree less than r).
The three-term recurrence relation can be written in matrix form where , is the th standard basis vector, i.e., , and J is the so-called Jacobi matrix:
The zeros of the polynomials up to degree n, which are used as nodes for the Gaussian quadrature can be found by computing the eigenvalues of this tridiagonal 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
J 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 to the eigenvalue xj, the corresponding weight can be computed from the first component of this eigenvector, namely:
Stoer and Bulirsch remark that this error estimate is inconvenient in practice, since it may be difficult to estimate the order 2n 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.
If the interval [a, b] 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 n + 1 points to an n-point rule in such a way that the resulting rule is of order 2n + 1. 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.
Also known as Lobatto quadrature (Abramowitz & Stegun 1972, p. 888) harv error: no target: CITEREFAbramowitzStegun1972 (help), 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.
Piessens, R. (1971). "Gaussian quadrature formulas for the numerical integration of Bromwich's integral and the inversion of the laplace transform". J. Eng. Math. Vol. 5, no. 1. pp. 1–9. Bibcode:1971JEnMa...5....1P. doi:10.1007/BF01535429.
Riener, Cordian; Schweighofer, Markus (2018). "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". Journal of Complexity. 45: 22–54. arXiv:1607.08404. doi:10.1016/j.jco.2017.10.002.