Notes GaussQuadrature
Notes GaussQuadrature
1 Introduction
In the earlier lectures we discussed quadrature rules based on polynomial interpolation (Trapezoidal and
Simpson’s Rules). Due to the restrictions that the discrete points xi ’s chosen in [a, b] must be equally
spaced, they are also known as Newton–Cotes quadrature rule. Thus, in general, we expect the degree
of exactness (if f (x) = p(x), a polynomial) of the rule to be n − 1 (But we have seen that some rule gave
a higher than the expected degree of exactness. Which one?).
Is it possible to construct a quadrature rule which is exact for polynomials of degree ≤ 2n − 1? Gaussian
quadrature rules have the surprising property that they can be used to integrate polynomials of degree
2n − 1 exactly using only n nodes. In Gaussian quadrature we select the nodes and weights of an n−point
quadrature rule so that the rule has degree of exactness is ≤ 2n − 1.
In the closed Newton-Cotes (end points a and b are considered) formulas earlier, the positions of the
nodes xi are all fixed, so it remains to find the n weights ci in the quadrature formula
Z b n
X
f (x) dx = ci f (xi ) (1)
a i=1
(Note that in interpolation and corresponding quadrature rule, we use i = 0, 1, . . . , n. If starting from
i = 1, then it must be i = 1, · · · , n + 1 in those formulae. OR consider n − 1 intervals and n points).
These weights are calculated using the formula
Z b n
Y x − xj
ci = Li (x) dx, where Li (x) =
a x i − xj
j=1(j6=i)
(For Simpson’s rules we have considered forward difference interpolation formula. Does it make any
difference?)
What if we do not put any restrictions on the positions of the nodes, other than that they must lie in
the interval [a, b]? Then (??) would contain 2n free parameters: c1 , · · · , cn and x1 , · · · , xn . In general, to
construct a polynomial of degree 2n − 1, we require 2n conditions (why?). This possibility allows that the
highest degree of exactness we can expect to achieve with any quadrature rule is 2n − 1. For example, let
us consider the case when number of nodes are 2 and the interval is [−1, 1]. i.e., We want to determine
the points/nodes x1 , x2 and the weights c1 , c2 so that the formula
Z 1
f (x) dx ≈ c1 f (x1 ) + c2 f (x2 )
−1
is exact for polynomials of degree upto 2 × 2 − 1 = 3. i.e. we can say we obtain the points/nodes x1 , x2
and the weights c1 , c2 such that (note the change from ≈ to =)
Z 1
a0 + a1 x + a2 x2 + a3 x3 dx = c1 (a0 + a1 x1 + a2 x21 + a3 x31 ) + c2 (a0 + a1 x2 + a2 x22 + a3 x32 )
−1
Since 1, x, x2 , x3 represent a basis for the space of all polynomials of degree ≤ 3, above exactness can also
be written individually for each member of the basis.
Z 1 R1
1 dx = 2 = c1 × 1 + c2 × 1; −1
x dx = 0 = c1 × x1 + c2 × x2
−1
Z 1
2 R1
x2 dx = = c1 × x21 + c2 × x22 ; −1
x3 dx = 0 = c1 × x31 + c2 × x32
−1 3
√ √
Solving above equations (they are nonlinear too!), we get c1 = c2 = 1; x1 = − 33 , x2 = 33
Quadrature formula is √ √
Z 1
3 3
f (x) dx ≈ f (− ) + f( )
−1 3 3
√ R1
Note that ± 33 = √13 are the roots of x2 − 13 . (Excercise: Obtain a formula −1 f (x) dx ≈ c1 f (x1 ) which
is exact for polynomials of degree ≤ 2 ∗ 1 − 1 = 1).
2 Legendre Polynomials
Doing above calculations for larger n become tedious by considering the basis {1, x, x2 , · · · , x2n−1 }. But
alternative way of computing these points xj ’s and weights cj ’s is through orthogonal polynomials. A
Z b
sequence of polynomials {p0 (x), p1 (x), · · · , pn (x), · · · } are called orthogonal if, pn (x)pm (x) dx = 0
a
whenever m 6= n. Legendre polynomials are one such class with [a, b] = [−1, 1] and p0 (x) = 1, p1 (x) =
x, p2 (x) = x2 − 31 , p3 (x) = x3 − 35 x, · · · . In general these polynomials can be generated using the recursive
2n − 1 n−1
formula pn (x) = xpn−1 (x) − pn−2 (x). These Legendre polynomials {p0 , p1 , · · · , pn } is also a
n n
basis (rather orthogonal basis) for the set of all polynomials of degree ≤ n.
The roots of these polynomials are distinct, lie in the interval [−1, 1] and have a symmetry with respect to
origin. The points/nodes x1 , x2 , · · · , xn that produces integral approximation formula which is exact for
polynomials of degree ≤ 2n − 1 are the roots of the nth degree Legendre polynomial. Following theorem
establishes this.
Theorem 1. Suppose that x1 , x2 , · · · , xn are the roots of nth degree Legendre polynomial pn (x) and that
Z 1 Y n
x − xj
for each i = 1, 2, · · · , n, the numbers ci are defined by ci = dx. If p(x) is any
−1 j=1(j6=i) xi − xj
Z 1 Xn
polynomial of degree less than 2n (≤ 2n − 1), then p(x) = ci p(xi ).
−1 i=1
Above theorem is helpful in finding the roots of each Legendre polynomial pn and the weights cj ’s.
However, we do not need to do these calculations whenever an integral to be approximated. ci ’s and xi ’s
are computed extensively and following table gives these values for n = 2, 3, 4.
b−a
Then dx = 2 dt. Thus the integral gets transformed to
b 1 1
b−a (b − a)t + a + b b−a
Z Z Z
f (x) dx = f dt = g(t) dt
a 2 −1 2 2 −1
(b−a)t+a+b
where g(t) = f 2 .
4 Exercises
R1
Example 1: Approximate −1 ex cos x dx using Gauss-Legendre quadrature with n = 3 (i.e., 3 points
x1 , x2 , x3 ).
Answer: 1.9333904 R
1.5
Example 2: Evaluate 1 x2 ln x dx using using Gauss-Legendre quadrature with n = 2. Compare the
value with exact and the integral value using Trapezoidal rule with 2 points.
Answer: 0.1922687 R
3
Example 3: Given 1 x6 − x2 sin 2x dx = 31.7.3442466. Evaluate G-L approximation when n = 2 and
n = 3 and compare these values with Trapezoidal and Simpson’s 1/3rd rules, respectively.
Answer: Trapezoidal:- 731.6054420; G-L (n=2):- 306.8199344; Simpson 1/3rd:- 333.2380940; G-L(n=3):-
317.2641516.
5 Remarks
Composite rules: It is simple to devise a method for decomposing the interval of integration into smaller
regions, over which Gauss quadrature rules can be applied. The most straightforward application is to
adjust the Gauss–Legendre quadrature rule, which is the simplest rule based on orthogonal polynomials.