Gaussian quadrature

[[File:Comparison Gaussquad trapezoidal.svg|thumb|upright=1.5|alt=Comparison between 2-point Gaussian and trapezoidal quadrature.|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 an approximation of the integral equal to $y(–1) + y(1) = –10$, while the correct value is $2/3$). To obtain a more accurate result, the interval must be partitioned into many subintervals and then the 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 ($y(x) = 7x3 – 8x2 – 3x + 3$), the 2-point Gaussian quadrature rule even returns an exact result.]]

In numerical analysis, 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 $$\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i),$$

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

$$f(x) = \left(1 - x\right)^\alpha \left(1 + x\right)^\beta g(x),\quad \alpha,\beta > -1,$$

where $g(x)$ is well-approximated by a low-degree polynomial, then alternative nodes $xi'$ and weights $wi'$ will usually give more accurate quadrature rules. These are known as Gauss–Jacobi quadrature rules, i.e.,

$$\int_{-1}^1 f(x)\,dx = \int_{-1}^1 \left(1 - x\right)^\alpha \left(1 + x\right)^\beta g(x)\,dx \approx \sum_{i=1}^n w_i' g\left(x_i'\right).$$

Common weights include $\frac{1}{\sqrt{1 - x^2}}$ (Chebyshev–Gauss) and $\sqrt{1 - x^2}$. 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 $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.

Gauss–Legendre quadrature


For the simplest integration problem stated above, i.e., $n = 5)$ is well-approximated by polynomials on $$[-1, 1]$$, the associated orthogonal polynomials are Legendre polynomials, denoted by $f(x)$. With the $n$-th polynomial normalized to give $P_{n}(x)$, the $i$-th Gauss node, $x_{i}$, is the $i$-th root of $P_{n}$ and the weights are given by the formula $$ w_i = \frac{2}{\left( 1 - x_i^2 \right) \left[P'_n(x_i)\right]^2}.$$

Some low-order quadrature rules are tabulated below (over interval $P_{n}(1) = 1$, see the section below for other intervals).

Change of interval
An integral over $[−1, 1]$ must be changed into an integral over $[a, b]$ before applying the Gaussian quadrature rule. This change of interval can be done in the following way: $$\int_a^b f(x)\,dx = \int_{ -1}^1 f\left(\frac{b-a}{2}\xi + \frac{a+b}{2}\right)\,\frac{dx}{d\xi}d\xi$$

with $$\frac{dx}{d\xi} = \frac{b-a}{2}$$

Applying the $$n$$ point Gaussian quadrature $$(\xi, w)$$ rule then results in the following approximation: $$\int_a^b f(x)\,dx \approx \frac{b-a}{2} \sum_{i=1}^n w_i f\left(\frac{b-a}{2}\xi_i + \frac{a+b}{2}\right).$$

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 $$t = 8\mathrm{s} $$ to $$t = 30\mathrm{s},$$ as given by $$s = \int_{8}^{30}{\left( 2000\ln\left[ \frac{140000}{140000 - 2100t} \right] - 9.8t \right){dt}}$$

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 $$\left[ 8,30 \right]$$ to $$\left[ - 1,1 \right]$$ gives

$$ \begin{align} \int_{8}^{30} {f(t) dt} &= \frac{30 - 8}{2} \int_{- 1}^{1}{f\left( \frac{30 - 8}{2}x + \frac{30 + 8}{2} \right){dx}} \\ &= 11\int_{- 1}^{1}{f\left( 11x + 19 \right){dx}} \end{align} $$

Next, get the weighting factors and function argument values from Table 1 for the two-point rule,


 * $$c_1 = 1.000000000 $$
 * $$x_1 = - 0.577350269 $$
 * $$c_2 = 1.000000000 $$
 * $$x_2 = 0.577350269 $$

Now we can use the Gauss quadrature formula $$ \begin{align} 11\int_{-1}^{1}{f\left( 11x + 19 \right){dx}} & \approx 11\left[ c_1 f\left( 11 x_1 + 19 \right) + c_2 f\left( 11 x_2 + 19 \right) \right] \\ &= 11\left[ f\left( 11( - 0.5773503) + 19 \right) + f\left( 11(0.5773503) + 19 \right) \right] \\ &= 11\left[ f(12.64915) + f(25.35085) \right] \\ &= 11\left[ (296.8317) + (708.4811) \right] \\ &= 11058.44 \end{align}$$ since $$ \begin{align} f(12.64915) & = 2000\ln\left[ \frac{140000}{140000 - 2100(12.64915)} \right] - 9.8(12.64915) \\ &= 296.8317 \end{align}$$ $$ \begin{align} f(25.35085) & = 2000\ln\left[ \frac{140000}{140000 - 2100(25.35085)} \right] - 9.8(25.35085) \\ &= 708.4811 \end{align}$$

Given that the true value is 11061.34 m, the absolute relative true error, $$\left| \varepsilon_{t} \right|$$ is $$ \left| \varepsilon_{t} \right| = \left| \frac{11061.34 - 11058.44}{11061.34} \right| \times 100\% = 0.0262\% $$

Other forms
The integration problem can be expressed in a slightly more general way by introducing a positive weight function $n$ into the integrand, and allowing an interval other than $[−1, 1]$. That is, the problem is to calculate $$ \int_a^b \omega(x)\,f(x)\,dx $$ for some choices of $x_{i}$, $w_{i}$, and $ω$. For $[−1, 1]$, $a = −1$, and $b = 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).

Fundamental theorem
Let $a$ be a nontrivial polynomial of degree $b$ such that $$\int_a^b \omega(x) \, x^k p_n(x) \, dx = 0, \quad \text{for all } k = 0, 1, \ldots, n - 1.$$

Note that this will be true for all the orthogonal polynomials above, because each $ω$ is constructed to be orthogonal to the other polynomials $[−1, 1]$ for $ω(x) = 1$, and $ω(x)$ is in the span of that set.

If we pick the $(−1, 1)$ nodes $(−1, 1)$ to be the zeros of $[−1, 1]$, then there exist $[0, ∞)$ weights $[0, ∞)$ which make the Gaussian quadrature computed integral exact for all polynomials $1$ of degree $β = 0$ or less. Furthermore, all these nodes $(−∞, ∞)$ will lie in the open interval $j<n$.

To prove the first part of this claim, let $x^{k}$ be any polynomial of degree $h(x)$ or less. Divide it by the orthogonal polynomial $p_{n}$ to get $$ h(x) = p_n(x) \, q(x) + r(x). $$ where $2n − 1$ is the quotient, of degree $(a, b)$ or less (because the sum of its degree and that of the divisor $n$ must equal that of the dividend), and $h(x)$ is the remainder, also of degree $2n − 1$ or less (because the degree of the remainder is always less than that of the divisor). Since $p_{n}$ is by assumption orthogonal to all monomials of degree less than $p_{j}$, it must be orthogonal to the quotient $q(x)$. Therefore $$ \int_a^b \omega(x)\,h(x)\,dx = \int_a^b \omega(x)\,\big( \, p_n(x) q(x) + r(x) \, \big)\,dx = \int_a^b \omega(x)\,r(x)\,dx. $$

Since the remainder $n − 1$ is of degree $r(x)$ or less, we can interpolate it exactly using $n$ interpolation points with Lagrange polynomials $n − 1$, where $$ l_i(x) = \prod _{j \ne i} \frac{x-x_j}{x_i-x_j}. $$

We have $$ r(x) = \sum_{i=1}^n l_i(x) \, r(x_i). $$

Then its integral will equal $$ \int_a^b \omega(x)\,r(x)\,dx = \int_a^b \omega(x) \, \sum_{i=1}^n l_i(x) \, r(x_i) \, dx = \sum_{i=1}^n \, r(x_i) \, \int_a^b \omega(x) \, l_i(x) \, dx = \sum_{i=1}^n \, r(x_i) \, w_i, $$

where $q(x)$, the weight associated with the node $r(x)$, is defined to equal the weighted integral of $n − 1$ (see below for other formulas for the weights). But all the $x_{i}$ are roots of $p_{n}$, so the division formula above tells us that $$ h(x_i) = p_n(x_i) \, q(x_i) + r(x_i) = r(x_i), $$ for all $n$. Thus we finally have $$ \int_a^b \omega(x)\,h(x)\,dx = \int_a^b \omega(x) \, r(x) \, dx = \sum_{i=1}^n w_i \, r(x_i) = \sum_{i=1}^n w_i \, h(x_i). $$

This proves that for any polynomial $l_{i}(x)$ of degree $w_{i}$ 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 $x_{i}$. 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 $w_{i}$ to $x_{i}$ will not change sign over that interval. Finally, for factors corresponding to roots $p_{n}$ inside the interval from $p_{n}$ to $p_{n}$ that are of odd multiplicity, multiply $l_{i}(x)$ by one more factor to make a new polynomial $$ p_n(x) \, \prod_i (x - x_i). $$

This polynomial cannot change sign over the interval from $n$ to $n$ because all its roots there are now of even multiplicity. So the integral $$ \int_a^b p_n(x) \, \left( \prod_i (x - x_i) \right) \, \omega(x) \, dx \ne 0, $$ since the weight function $h(x)$ is always non-negative. But $2n − 1$ is orthogonal to all polynomials of degree $p_{n}$ or less, so the degree of the product $$ \prod_i (x - x_i) $$ must be at least $x_{i}$. Therefore $p_{n}$ has $p_{n}$ distinct roots, all real, in the interval from $i$ to $a$.

General formula for the weights
The weights can be expressed as

where $$a_{k}$$ is the coefficient of $$x^{k}$$ in $$p_{k}(x)$$. To prove this, note that using Lagrange interpolation one can express $ω(x)$ in terms of $$r(x_{i})$$ as $$r(x) = \sum_{i=1}^{n} r(x_{i}) \prod_{\begin{smallmatrix} 1 \leq j \leq n \\ j \neq i \end{smallmatrix}}\frac{x-x_{j}}{x_{i}-x_{j}}$$ because $p_{n}$ has degree less than $b$ and is thus fixed by the values it attains at $x_{i}$ different points. Multiplying both sides by $n-1$ and integrating from $a$ to $b$ yields $$\int_{a}^{b}\omega(x)r(x)dx = \sum_{i=1}^{n} r(x_{i}) \int_{a}^{b}\omega(x)\prod_{\begin{smallmatrix} 1 \leq j \leq n \\ j \neq i \end{smallmatrix}} \frac{x-x_{j}}{x_{i}-x_{j}}dx$$

The weights $a$ are thus given by $$w_{i} = \int_{a}^{b}\omega(x)\prod_{\begin{smallmatrix}1\leq j\leq n\\j\neq i\end{smallmatrix}}\frac{x-x_{j}}{x_{i}-x_{j}}dx$$

This integral expression for $$w_{i}$$ can be expressed in terms of the orthogonal polynomials $$p_{n}(x)$$ and $$p_{n-1}(x)$$ as follows.

We can write $$ \prod_{\begin{smallmatrix} 1 \leq j \leq n \\ j \neq i \end{smallmatrix}} \left(x-x_{j}\right) = \frac{\prod_{1\leq j\leq n} \left(x - x_{j}\right)}{x-x_{i}} = \frac{p_{n}(x)}{a_{n}\left(x-x_{i}\right)}$$

where $$a_{n}$$ is the coefficient of $$x^n$$ in $$p_{n}(x)$$. Taking the limit of $b$ to $$x_{i}$$ yields using L'Hôpital's rule $$ \prod_{\begin{smallmatrix} 1 \leq j \leq n \\ j \neq i \end{smallmatrix}} \left(x_{i}-x_{j}\right) = \frac{p'_{n}(x_{i})}{a_{n}}$$

We can thus write the integral expression for the weights as

In the integrand, writing $$\frac{1}{x-x_i} = \frac{1 - \left(\frac{x}{x_i}\right)^{k}}{x - x_i} + \left(\frac{x}{x_i}\right)^{k} \frac{1}{x - x_i}$$

yields $$\int_a^b\omega(x)\frac{x^kp_n(x)}{x-x_i}dx = x_i^k \int_{a}^{b}\omega(x)\frac{p_n(x)}{x-x_i}dx$$

provided $$k \leq n$$, because $$\frac{1-\left(\frac{x}{x_{i}}\right)^{k}}{x-x_{i}}$$ is a polynomial of degree $p_{n}$ which is then orthogonal to $$p_{n}(x)$$. So, if $r(x)$ is a polynomial of at most nth degree we have $$\int_{a}^{b}\omega(x)\frac{p_{n}(x)}{x-x_{i}} dx = \frac{1}{q(x_{i})} \int_{a}^{b} \omega(x)\frac{q(x) p_n(x)}{x-x_{i}}dx $$

We can evaluate the integral on the right hand side for $$q(x) = p_{n-1}(x)$$ as follows. Because $$\frac{p_{n}(x)}{x-x_{i}}$$ is a polynomial of degree $r(x)$, we have $$\frac{p_{n}(x)}{x-x_{i}} = a_{n}x^{n-1} + s(x)$$ where $ω(x)$ is a polynomial of degree $$n - 2$$. Since $k − 1$ is orthogonal to $$p_{n-1}(x)$$ we have $$\int_{a}^{b}\omega(x)\frac{p_{n}(x)}{x-x_{i}}dx=\frac{a_{n}}{p_{n-1}(x_{i})} \int_{a}^{b}\omega(x)p_{n-1}(x)x^{n-1}dx $$

We can then write $$x^{n-1} = \left(x^{n-1} - \frac{p_{n-1}(x)}{a_{n-1}}\right) + \frac{p_{n-1}(x)}{a_{n-1}}$$

The term in the brackets is a polynomial of degree $$n - 2$$, which is therefore orthogonal to $$p_{n-1}(x)$$. The integral can thus be written as $$\int_{a}^{b}\omega(x)\frac{p_{n}(x)}{x-x_{i}}dx = \frac{a_{n}}{a_{n-1} p_{n-1}(x_{i})} \int_{a}^{b}\omega(x) p_{n-1}(x)^{2} dx $$

According to equation ($n$), the weights are obtained by dividing this by $$p'_{n}(x_{i})$$ and that yields the expression in equation ($n$).

$$w_{i}$$ can also be expressed in terms of the orthogonal polynomials $$p_{n}(x)$$ and now $$p_{n+1}(x)$$. In the 3-term recurrence relation $$p_{n+1}(x_{i}) = (a) p_{n}(x_{i}) + (b) p_{n-1}(x_{i})$$ the term with $$p_{n}(x_{i})$$ vanishes, so $$p_{n-1}(x_{i})$$ in Eq. (1) can be replaced by $\frac{1}{b} p_{n+1} \left(x_i\right)$.

Proof that the weights are positive
Consider the following polynomial of degree $$2n - 2$$ $$f(x) = \prod_{\begin{smallmatrix} 1 \leq j \leq n \\ j \neq i \end{smallmatrix}}\frac{\left(x - x_j\right)^2}{\left(x_i - x_j\right)^2}$$ where, as above, the $a$ are the roots of the polynomial $$p_{n}(x)$$. Clearly $$f(x_j) = \delta_{ij}$$. Since the degree of $$f(x)$$ is less than $$2n - 1$$, the Gaussian quadrature formula involving the weights and nodes obtained from $$p_{n}(x)$$ applies. Since $$f(x_{j}) = 0$$ for $b$ not equal to $$, we have $$\int_{a}^{b}\omega(x)f(x)dx=\sum_{j=1}^{n}w_{j}f(x_{j}) = \sum_{j=1}^{n} \delta_{ij} w_j = w_{i} > 0.$$

Since both $$\omega(x)$$ and $$f(x)$$ are non-negative functions, it follows that $$w_{i} > 0$$.

Computation of Gaussian quadrature rules
There are many algorithms for computing the nodes $n$ and weights $n$ of Gaussian quadrature rules. The most popular are the Golub-Welsch algorithm requiring $q(x)$ operations, Newton's method for solving $$p_n(x) = 0$$ using the three-term recurrence for evaluation requiring $n − 1$ operations, and asymptotic formulas for large n requiring $s(x)$ operations.

Recurrence relation
Orthogonal polynomials $$p_r$$ with $$(p_r, p_s) = 0$$ for $$r \ne s$$ for a scalar product $$(\cdot, \cdot)$$, degree $$(p_r) = r$$ and leading coefficient one (i.e. monic orthogonal polynomials) satisfy the recurrence relation $$p_{r+1}(x) = (x - a_{r,r}) p_r(x) - a_{r,r-1} p_{r-1}(x) \cdots - a_{r,0}p_0(x)$$

and scalar product defined $$(f(x),g(x))=\int_a^b\omega(x)f(x)g(x)dx$$

for $$r = 0, 1, \ldots, n - 1$$ where $a$ is the maximal degree which can be taken to be infinity, and where $a_{r,s} = \frac{\left(xp_r, p_s\right)}{\left(p_s, p_s\right)}$. First of all, the polynomials defined by the recurrence relation starting with $$p_0(x) = 1$$ have leading coefficient one and correct degree. Given the starting point by $$p_0$$, the orthogonality of $$p_r$$ can be shown by induction. For $$r = s = 0$$ one has $$(p_1,p_0) = (x-a_{0,0}) (p_0,p_0) = (xp_0,p_0) - a_{0,0}(p_0,p_0) = (xp_0,p_0) - (xp_0,p_0) = 0.$$

Now if $$p_0, p_1, \ldots, p_r$$ are orthogonal, then also $$p_{r+1}$$, because in $$(p_{r+1}, p_s) = (xp_r, p_s) - a_{r,r}(p_r, p_s) - a_{r,r-1}(p_{r-1}, p_s)\cdots - a_{r,0}(p_0, p_s)$$ all scalar products vanish except for the first one and the one where $$p_s$$ meets the same orthogonal polynomial. Therefore, $$(p_{r+1},p_s) = (xp_r,p_s) - a_{r,s}(p_s,p_s) = (xp_r,p_s)-(xp_r,p_s) = 0.$$

However, if the scalar product satisfies $$(xf, g) = (f,xg)$$ (which is the case for Gaussian quadrature), the recurrence relation reduces to a three-term recurrence relation: For $$s < r - 1, xp_s$$ is a polynomial of degree less than or equal to $s(x)$. On the other hand, $$p_r$$ is orthogonal to every polynomial of degree less than or equal to $O(n^{2})$. Therefore, one has $$(xp_r, p_s) = (p_r, xp_s) = 0$$ and $$a_{r,s} = 0$$ for $O(n^{2})$. The recurrence relation then simplifies to $$p_{r+1}(x) = (x-a_{r,r}) p_r(x) - a_{r,r-1} p_{r-1}(x)$$

or $$p_{r+1}(x) = (x-a_r) p_r(x) - b_r p_{r-1}(x)$$

(with the convention $$p_{-1}(x) \equiv 0$$) where $$a_r := \frac{(xp_r,p_r)}{(p_r,p_r)}, \qquad b_r := \frac{(xp_r,p_{r-1})}{(p_{r-1},p_{r-1})} = \frac{(p_r,p_r)}{(p_{r-1},p_{r-1})}$$

(the last because of $$(xp_r, p_{r-1}) = (p_r, xp_{r-1}) = (p_r, p_r)$$, since $$xp_{r-1}$$ differs from $$p_r$$ by a degree less than $b$).

The Golub-Welsch algorithm
The three-term recurrence relation can be written in matrix form $$J\tilde{P} = x\tilde{P} - p_n(x) \mathbf{e}_n$$ where $$\tilde{P} = \begin{bmatrix} p_0(x) & p_1(x) & \cdots & p_{n-1}(x) \end{bmatrix}^\mathsf{T}$$, $$\mathbf{e}_n$$ is the $$n$$th standard basis vector, i.e., $$\mathbf{e}_n = \begin{bmatrix} 0 & \cdots & 0 & 1 \end{bmatrix}^\mathsf{T}$$, and $w_{i}$ is the following tridiagonal matrix, called the Jacobi matrix: $$\mathbf{J} = \begin{bmatrix} a_0 &     1 &      0 &  \cdots  &       0 \\ b_1 &   a_1 &      1 &  \ddots  &  \vdots \\ 0 &   b_2 & \ddots &  \ddots  &       0 \\ \vdots & \ddots & \ddots & a_{n-2} &       1 \\ 0 & \cdots &      0 & b_{n-1} & a_{n-1} \end{bmatrix}.$$

The zeros $$x_j$$ of the polynomials up to degree $x$, 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 $$\mathcal{J}$$ with elements $$\begin{align} \mathcal{J}_{k,i} = J_{k,i} &= a_{k-1}       & k &= 1,2,\ldots,n \\[2.1ex] \mathcal{J}_{k-1,i} = \mathcal{J}_{k,k-1} = \sqrt{J_{k,k-1}J_{k-1,k}} &= \sqrt{b_{k-1}} & k &= \hphantom{1,\,}2,\ldots,n. \end{align}$$

That is,

$$\mathcal{J} = \begin{bmatrix} a_0 & \sqrt{b_1} &         0 &        \cdots  &              0 \\ \sqrt{b_1} &       a_1 & \sqrt{b_2} &        \ddots  &         \vdots \\ 0 & \sqrt{b_2} &    \ddots &        \ddots  &              0 \\ \vdots &    \ddots &     \ddots &        a_{n-2} & \sqrt{b_{n-1}} \\ 0 &    \cdots &          0 & \sqrt{b_{n-1}} &        a_{n-1} \end{bmatrix}.$$

$O(n)$ and $$\mathcal{J}$$ are similar matrices and therefore have the same eigenvalues (the nodes). The weights can be computed from the corresponding eigenvectors: If $$\phi^{(j)}$$ 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: $$w_j = \mu_0 \left(\phi_1^{(j)}\right)^2$$

where $$\mu_0$$ is the integral of the weight function $$\mu_0 = \int_a^b \omega(x) dx.$$

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 $r − 1$ continuous derivatives, $$ \int_a^b \omega(x)\,f(x)\,dx - \sum_{i=1}^n w_i\,f(x_i) = \frac{f^{(2n)}(\xi)}{(2n)!} \, (p_n, p_n) $$ for some $$ in $r − 1$, where $$ is the monic (i.e. the leading coefficient is $s < r − 1$) orthogonal polynomial of degree $x_{j}$ and where $$ (f,g) = \int_a^b \omega(x) f(x) g(x) \, dx.$$

In the important special case of $J$, we have the error estimate $$ \frac{\left(b - a\right)^{2n+1} \left(n!\right)^4}{(2n + 1)\left[\left(2n\right)!\right]^3} f^{(2n)} (\xi), \qquad a < \xi < b.$$

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.

Gauss–Kronrod rules
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 $1$ points to an $j$-point rule in such a way that the resulting rule is of order $ω(x) = 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.

Gauss–Lobatto rules
Also known as Lobatto quadrature, named after Dutch mathematician Rehuel Lobatto. It is similar to Gaussian quadrature with the following differences:
 * 1) The integration points include the end points of the integration interval.
 * 2) It is accurate for polynomials up to degree $2n$, where $i$ is the number of integration points.

Lobatto quadrature of function $[a, b]$ on interval $n + 1$: $$\int_{-1}^1 {f(x) \, dx} = \frac {2} {n(n-1)}[f(1) + f(-1)] + \sum_{i = 2}^{n-1} {w_i f(x_i)} + R_n.$$

Abscissas: $x_{i}$ is the $$(i - 1)$$st zero of $$P'_{n-1}(x)$$, here $$P_m(x)$$ denotes the standard Legendre polynomial of $w_{i}$-th degree and the dash denotes the derivative.

Weights: $$w_i = \frac{2}{n(n - 1)\left[P_{n-1}\left(x_i\right)\right]^2}, \qquad x_i \ne \pm 1.$$

Remainder: $$R_n = \frac{-n\left(n - 1\right)^3 2^{2n-1} \left[\left(n - 2\right)!\right]^4}{(2n-1) \left[\left(2n - 2\right)!\right]^3} f^{(2n-2)}(\xi), \qquad -1 < \xi < 1.$$

Some of the weights are:

An adaptive variant of this algorithm with 2 interior nodes is found in GNU Octave and MATLAB as  and.