Orthogonal polynomials and Gauss quadrature

Maria Cameron
1. Gaussian quadrature
The key idea behind the Gaussian quadrature is a clever choice of interpolation nodes in
[a, b] that maximizes the degree of exactness of the quadrature rule. Gaussian quadrature
is designed for computing integrals of the form
Z b
(1)
I(f ) =
f (x)w(x)dx.
a
Here w(x) is a weight function on [a, b] which means that it is nonnegative in any open
interval in [a, b] (a = −∞ and b = ∞ are accepted) and
Z b
w(x)|x|n dx < ∞, , n = 0, 1, 2, . . . .
a
1.1. Maximizing the degree of exactness. As soon as the interpolation nodes x1 <
x2 < . . . xn , xj ∈ [a, b], j = 1, 2, . . . , n are picked one can approximate the integral using
the standard recipe for interpolating quadrature rules:
Z b
Z b
n
n
X
X
(2)
I(f ) =
f (x)w(x)dx ≈ Q(f ) =
w(x)
f (xj )Lj (x) =
wj f (xj )
a
a
j=1
j=1
where
Z
(3)
wj =
b
Lj (x)w(x)dx,
Lj (x) =
a
n
Y
k=1, k6=j
(x − xk )
.
(xj − xk )
Independent of the choice of nodes such a rule is exact for polynomials f (x) of degree
≤ n − 1.
Definition 1. We say a quadrature rule of the form of Eq. (2) has degree of exactness m
if it is exact for all polynomials f (x) of degree ≤ m but not exact for all polynomials of
degree m + 1.
The quadrature rule of the form (2) has 2n parameters: n nodes and n weights. Hence
we can hope to make it exact for all polynomials of degree 2n − 1 that have 2n coefficients.
The nodes and weights for such a rule will be the solution of the system of 2n − 1 equations
Z b
n
X
wj xkj =
xk w(x)dx, k = 0, 1, . . . 2n − 1.
j=1
a
However, this system is hard to solve. It is nonlinear and badly conditioned. Therefore,
this approach is not practical. A much better idea is to generate a set of orthogonal
polynomials {pk (x)}nk=0 on [a, b] with respect to the weight function w(x) using the threeterm recurrence relations (TTRR). Then nodes coinciding with the zeros of the polynomial
pn (x) for an interpolatory quadrature rule will render it exact for all polynomials of degree
up to 2n − 1.
1
2
Theorem 1. Let {pk (x)}nk=0 be a set of orthogonal polynomials on [a, b] with respect to the
inner product
Z b
f (x)g(x)w(x)dx.
(f, g) =
a
Let xj , j = 1, 2, . . . , n be zeros of the polynomial pn (x). Then the quadrature rule given by
Eqs. (2) and (3) has degree of exactness 2n − 1.
Proof. The key idea in the proof of this fact is division of the polynomial f (x) by the
polynomial pn (x). Let f (x) be a polynomial of degree ≤ 2n − 1. Then
f (x) = pn (x)q(x) + r(x),
q(x), r(x) ∈ Pn−1 ,
where
i.e, q(x) and r(x) are polynomials of degree ≤ n−1. Since the rule (2), (3) is interpolatory,
it is exact for r(x). Then we have
Z b
Z b
Z b
q(x)pn (x)w(x)dx +
r(x)w(x)dx =
r(x)w(x)dx = Q(r).
I(f ) = I(qpn + r) =
a
a
a
Here we have used the fact that the polynomial pn (x) is orthogonal to all polynomials of
degree ≤ n − 1. We continue:
I(f ) = Q(r) =
n
X
j=1
wj r(xj ) =
n
X
wj (pn (xj )q(xj ) + r(xj )) = Q(f ).
j=1
Here we have used the fact that xj ’s are the zeros of pn (x).
It remains to prove that the rule (2), (3) is not exact for all polynomials of degree 2n.
Let us make the polynomial pn (x) of norm 1. Let f (x) be a polynomial of degree 2n. Then
q(x) is of degree n and r(x) is of degree ≤ n − 1. On one hand,
Z b
Z b
I(f ) = I(qpn + r) =
q(x)pn (x)w(x)dx +
r(x)w(x)dx = Q(r) + (q, pn ).
a
a
Note that (q, pn ) 6= 0. On the other hand,
Q(f ) = Q(pn q + r) = Q(r),
as xj ’s are the zeros of pn (x). Hence I(f ) 6= Q(f ) for all polynomials f of degree 2n.
1.2. Error estimate. Next we will obtain an error estimate for the Gaussian quadrature.
Theorem 2. Let w(x) be a weight function and pn (x) be the monic polynomial of degree n
orthogonal to all polynomials of smaller degrees. Let xj , j = 1, 2, . . . , n be zeros of pn (x).
Let Q(f ) be the quadrature rule defined in Eqs. (2) and (3). Suppose f ∈ C 2n [a, b]. Then
one can find λ ∈ (a, b) such that
Z b
Z b
f (2n) (λ)
, where γn =
p2n (x)w(x)dx.
(4)
f (x)w(x)dx = Q(f ) + γn
(2n)!
a
a
3
Proof. We use the Hermite interpolation to prove the error estimate. There exists a unique
polynomial h2n−1 (x) of degree 2n − 1 such that
and h02n−1 (xj ) = f 0 (xj ).
h2n−1 (xj ) = f (xj )
In addition, there exists ζ ∈ (a, b) depending of x such that
f (x) = h2n−1 (x) +
f (2n) (ζ)
(x − x1 )2 . . . (x − xn )2 .
(2n)!
Note that (x − x1 ) . . . (x − xn ) = pn (x) as pn is monic and xj , j = 1, . . . , n are its roots.
Therefore
Z b (2n)
Z b
Z b
f
(ζ) 2
h2n−1 (x)w(x)dx +
f (x)w(x)dx =
p (x)w(x)dx.
(2n)! n
a
a
a
Since the quadrature is exact for polynomials of degree 2n − 1, it is exact for h2n−1 (x).
Hence
Z b
n
n
X
X
h2n−1 (x)w(x)dx = Q(h2n−1 ) =
h2n−1 (xj )wj =
f (xj )wj = Q(f ).
a
j=1
j=1
On the other hand, because p2n (x)w(x) ≥ 0 on [a, b] we can apply the mean value theorem
and get
Z
Z b (2n)
f (2n) (λ) b 2
f
(ζ) 2
p (x)dx =
p (x)w(x)dx
(2n)! n
(2n)! a n
a
for some λ ∈ (a, b). This completes the proof.
1.3. TTRR. As we know from the beginning of the course, given a weight function w(x)
and an interval [a, b], the set of monic orthogonal polynomials {pk } associated with the
inner product
Z b
(f, g) =
f (x)g(x)w(x)dx
a
satisfies the TTRR
p0 (x) = 1,
p1 (x) = (x − B0 )p0 (x),
(5)
pk+1 (x) = (x − Bk )pk (x) − Ak pk−1 (x),
Ak =
k2
kpk
, k ≥ 1,
kpk−1 k2
Bk =
k = 1, 2, . . . ,
(xpk , pk )
, k ≥ 0.
kpk k2
where
4
For the orthonormal polynomials {Pn } the TTRR (5) can be rewritten as
α1 P1 (x) + β0 P0 (x) = xP0 (x)
(6)
(7)
αk+1 Pk+1 (x) + βk Pk (x) + αk Pk−1 (x) = xPk (x), k = 1, 2, . . . , with
p
ak−1
kpk k
=
, k ≥ 1,
α k = Ak =
kpk−1 k
ak
βk = Bk = (xPk , Pk ), k ≥ 0,
where ak ’s are the leading coefficients of Pk ’s, since
Fk =
1
.
kpk k
Exercise Prove TTRR (6).
Unfortunately, the integrals in TTRR (5) are the very kind of integrals we would like to
compute using the Gaussian quadrature. However, there are three classic cases where the
coefficients are analytic. These cases are listed below.
(α,β)
1.3.1. Jacobi Polynomials. Notation: Pn
(x).
Interval: [−1, 1].
Weight function: w(x) = (1 − x)α (1 + x)β , α, β > −1.
TTRR:
a0 P1 (x) + b0 P0 (x) = xP0 (x),
an Pn+1 (x) + bn Pn (x) + cn Pn−1 (x) = xPn (x),
where
β−α
2
, b0 =
,
α+β+2
α+β+2
2(n + 1)(n + α + β + 1)
,
=
(Ln + 1)(Ln + 2)
β 2 − α2
=
,
Ln (Ln + 2)
2(n + α)(n + β)
=
, n ≥ 1,
Ln (Ln + 1)
= 2n + α + β.
a0 =
an
bn
cn
Ln
(α)
1.3.2. Generalized Laguerre polynomials. Notation: Ln (x).
Interval: [0, ∞).
Weight function: w(x) = xα e−x , α > −1.
5
TTRR:
(α)
(α)
(α)
−L1 (x) + (α + 1)L0 (x) = xL0 (x),
(α)
(α)
(α)
−(n + 1)Ln+1 (x) + (2n + α + 1)L(α)
n (x) − (n + α)Ln−1 (x) = xLn (x).
1.3.3. Hermite polynomials. Notation: Hn (x).
Interval: (−∞, ∞).
2
Weight function: w(x) = e−x .
TTRR:
1
2 H1 (x)
1
2 Hn+1 (x)
= xH0 (x),
+ nHn−1 (x) = xHn (x).
1.4. Golub-Welsch algorithm for finding nodes and weights. The starting point for
computing nodes and weights of a Gaussian n-point rule is TTRR (6). Let xj be the one
of the nodes of the rule. Then
(8)
α1 P1 (xj ) + β0 P0 (xj )
= xj P0 (xj )
α2 P2 (xj ) + β1 P1 (xj ) + α1 P0
..
.
= xj P1 (xj )
βn−1 Pn−1 (xj ) + αn−1 Pn−2 (xj )
In the matrix form Eq.

β0 α1
 α1 β1

 0 α2
(9)

 ..
 .
0 ...
or
= xj Pn−1 (xj ).
(8) is
0
α2
β2
0
...
0







αn−1 βn−1
(10)
P0 (xj )
P1 (xj )
P2 (xj )
..
.
Pn−1 (xj )








 = xj 




P0 (xj )
P1 (xj )
P2 (xj )
..
.




,


Pn−1 (xj )
JP (xj ) = xj P (xj ),
where P (xj ) = [P0 (xj ), . . . , Pn−1 (xj )]. Therefore,the nodes that we need for the npoint Gaussian quadrature are the eigenvalues of J!
Now we need to find a way to obtain the weights. We will use the facts that (i) the
Gaussian quadrature is exact for P0 , P1 ,... ,Pn−1 , (ii) P (xj ) is the eigenvector for xj , and
(iii) P0 is constant and we can easily find it and set the proper scaling for the rest of the
entries of P .
Since
Z
b
(Pi , Pk ) =
Pi (x)Pk (x)w(x)dx = δik ,
a
0 ≤ i, k ≤ n − 1,
6
and the Gaussian quadrature is exact on these polynomials, we have
n
X
δik = (Pi , Pk ) =
Pi (xj )Pk (xj )wj .
j=1
In the matrix form this expression is
P W P T = I,
(11)
where W = diag(w1 , w2 , . . . , wn ) and P = [P (x1 ), P (x2 ), . . . , P (xn )], i.e., P is the matrix
whose columns are the properly scaled eigenvectors of J.
It follows from Eq. (11) that P is invertible, hence
W = P −1 P −T = (P T P )−1 .
Thus,
W −1 = P T P,
which means that
n−1
(12)
X
1
=
(Pk (xj ))2 = kP (xj )k2 ,
wj
k=0
where k · k is the Euclidean norm.
(j)
(j)
On the other hand, given an eigenvector v (j) = [v1 , . . . , vn ] of the matrix J there exists
a constant C such that
vj = CP (xj ) = C[P0 (xj ), P1 (xj ), . . . , Pn−1 (xj )].
The value of C can be obtained by considering
Z b
1 = (P0 , P0 ) = P02
w(x)dx = P02 µ0 .
a
It follows that
Hence
1
P0 = √ .
µ0
C
(j)
v1 = CP0 = √ .
µ0
Then
(j) √
C = v1
µ0 .
Therefore,
1 (j)
1
v = (j) √ v (j) .
C
v 1 µ0
Finally, we obtain the weight wj associated with the node xj :
P (xj ) =
(j)
(13)
wj =
1
(v1 )2
=
µ
.
0
kP (xj )k2
kv (j) k2
7
1.4.1. Nonorthonormal polynomials. The TTRR’s for classic orthogonal polynomials are
traditionally given in the form
(14)
xpk (x) = ak pk+1 + bk pk (x) + ck pk−1 (x),
c0 p−1 (x) = 0
that leads to nonorthonormal families. We need to convert TTRR (16) to the TTRR
for the orthonormal family. Since the orthonormal polynomials Pk (x) and the orthogonal
polynomials pk (x) relate via
pj (x) = λj Pj (x),
we have
(15)
xλk Pk (x) = ak λk+1 λPk+1 + bk λk Pk (x) + ck λk−1 Pk−1 (x).
Hence
αk+1 = ak
λk+1
,
λk
βk = bk ,
αk = ck
λk−1
.
λk
Therefore,
αk = ak−1
λk−1 √
λk
= ck
= ak−1 ck ,
λk−1
λk
To summarize,
(16)
αk =
√
ak−1 ck ,
βk = bk .
Rb
1.4.2. The Golub-Welsch algorithm. Input: µ0 = a w(x)dx
Output: x1 ,,. . ., xn ; w1 , . . ., wn .
• Build J from α1 , ..., αn−1 , β0 ,, ..., βn−1 .
• Compute eigenvalues ρ1 , ..., ρn and eigenvectors v1 , ..., vn of J.
• for i = 1 : n
xi = ρi ,
2
wi = µ0 vkvi (1)
2 .
ik
end
The following subroutine implements the Golub-Welsch
algorithm in matlab for comR∞
puting the Gamma function. It tests that Γ(5) = 0 x5−1 e−x dx = 4!.
function golubwelsch()
n=20;
b=zeros(n,1);
a=zeros(n,1);
b(1)=1;
for j=2:n
k=j-1;
b(j)=b(k)+2;
a(j)=k;
end
mu0=1;
%% form J
8
J=zeros(n);
J(1,1)=b(1);
J(1,2)=a(2);
for j=2:n-1
J(j,j)=b(j);
J(j,j-1)=a(j);
J(j,j+1)=a(j+1);
end
J(n,n)=b(n);
J(n,n-1)=a(n);
%% find eigenvalues and eigenvectors
[V E]=eig(J);
%% find weigths
x=zeros(n,1);
w=zeros(n,1);
for j=1:n
x(j)=E(j,j);
w(j)=mu0*V(1,j)^2/norm(V(:,j))^2;
end
%% compute integral
I=sum(myf(x).*w);
fprintf(’I = %.14e\n’,I);
%%
function y=myf(x)
p=zeros(5,1); % polynomial of 4-th degree
p(1)=1; % p(x)= x^4
y=polyval(p,x);
1.5. Example: Gauss-Chebyshev quadrature. For the Gauss-Chebyshev quadrature
nodes, i.e. zeros of Tn (x), are given by
!
π(j − 21 )
, j = 1, . . . , n,
xj = cos
n
and weights can be found easily.
As we know, the n − 1-st degree Chebyshev interpolant of f (x) is
fn−1 =
n−1
X
j=0
0ci Ti (x),
9
P
( 0 means that the first term is divided by 2), where
n
2X
ci =
f (xk )Ti (xk ),
n
xk = cos
k=1
π(k − 21 )
n
!
,
k = 1, . . . , n.
The Gauss-Chebyshev rule consists in the approximation
Z 1
Z 1
f
(x)
f (x)
√
√n−1
dx ≈ Q(f ) =
dx.
I(f ) =
2
1−x
1 − x2
−1
−1
Plugging in the expression for fn−1 (x) and using the facts that (Ti , Tk ) = 0 for i 6= k,
T0 = 1 and (T0 , T0 ) = π we get
Z 1
n−1
X
1
c0
πc0
√
Q(f ) =
0ci Ti (x)dx = (T0 , T0 ) =
.
2
2
2
1−x
−1
j=0
Now, using the expression for c0 we obtain
n
n
πX
π2X
πc0
f (xk ) =
f (xk ).
=
Q(f ) =
2
2n
n
k=1
k=1
Therefore, the weights for the Gauss-Chebyshev quadrature are all equal to π/n:
π
wi = , i = 1, . . . , n.
n
References
[1] A. Gil, J. Segura, N. Temme, Numerical Methods for Special Functions, SIAM, 2007