al Integration
Computational Te
hniques II
Contents
1 Introdu tion 1
2 Newton-Cotes quadrature 2
2.1 Trapezium rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Simpson's rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 A simpler way to derive Newton-Cotes formulae . . . . . . . . . . 3
2.4 Error analysis for Newton-Cotes formulae . . . . . . . . . . . . . 3
4 Gaussian quadrature 7
4.1 Orthogonal polynomials . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 More general Gaussian quadrature . . . . . . . . . . . . . . . . . 10
4.3 Standard weights . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1 Introdu tion
Suppose that we are given a fun
tion f (x); and we are to
ompute
Z b
f (x) dx;
a
where a; b are given numbers. One method is to rst nd an indenite integral
of f (x) : Z
F (x) = f (x) dx;
and then to
ompute F (b) F (a): This method is
alled the analyti
al method,
and depends on our ability to
ompute the indenite integral F (x): There are
many situations where
omputing F (x) is di
ult or even impossible. In su
h
ases, we resort to numeri
al integration or quadrature. A numeri
al integration
method has the advantage that we do not need to nd the indenite integral, but
it has the disadvantage that the answer may be approximate. There are many
dierent methods of numeri
al integration. In this
ourse, we shall learn about
two types of quadrature algorithms: Newton-Cotes quadrature and Gaussian
quadrature.
1
2 Newton-Cotes quadrature
Here we shall assume that we are given the value of f (x) at regularly spa
ed
points, a = x0 ; :::; xn = b; where xi = a + ih; for i = 0; :::; n and h = (b a)=n:
Then we
an interpolate the n + 1 points
(x0 ; y0 ); :::; (xn ; yn )
using a (unique) polynomial p(x) of degree n and use
Z b
p(x)dx
a
as an approximation for Z b
f (x)dx:
a
This is
alled Newton-Cotes quadrature. Of spe
ial interest are the simplest two
ases: n = 1 and n = 2: These are
alled, respe
tively, the trapezium rule and
Simpson's rule.
f(b)
f(a)
a=x0 b=x1
h
Trapezium rule
Its area is
h
(f (x0 ) + f (x1 )):
2
Noti
e that this is just a linear
ombination of the f (xi )'s. It turns out that
this is a general behaviour for Newton-Cotes formulae.
2
2.3 A simpler way to derive Newton-Cotes formulae
We have already mentioned that the Newton-Cotes formula for any n is a linear
ombination of f (xi )0 s; i.e., of the form
0 f (x0 ) + + f (x );
n n
Exer ise 1 Show that this is true by observing that f [x0 ; :::; xk 's are linear ombinations of
f (xi )'s.
On
e we know that i 's are free of f; we
an take spe
ial simple
hoi
es of f
to
ompute them. For instan
e, to derive trapezium rule (whi
h uses linear
interpolation) we shall take f (x) = 1 and f (x) = x: The rst
hoi
e will give:
b a = 0 + 1 ;
while the se
ond
hoi
e gives
(b2 a2 )=2 = 0 a + 1 b
Solving these two equations we get
h
0 = 1 = ;
2
whi
h gives the trapezium rule.
Similarly, we
an take f (x) = 1; x and x2 for Simpson's rule to get 3 equations:
0 + 1 + 2 = b a
x0 0 + x1 1 + x2 2 = (b2 a2 )=2
x20 0 + x21 1 + x22 2 = (b3 a3 )=3
Noti
e that this system
an be written as
2 32 3 2 3
1 1 1 0 (b a)
4 x0 x1 x2 5 4 1 5 = 4 (b2 a2 )=2 5 :
x20 x21 x22 2 (b3 a3 )=3
The
oe
ient matrix is a Vandermonde matrix, and hen
e is nonsingular. It
should not be di
ult to
he
k that the unique solution is given by
0 = h=3; 1 = 4h=3; 2 = h=3:
Example Let us apply the trapezium rule to f (x) = x2 for x0 = 0 and x1 = 1: The a
tual
integral is Z1
1
x2 dx = :
0 3
3
Using trapezium rule we get
1 1 1
(0 + 1) = 6= :
2 2 3
However, something dierent happens for Simpson's rule. Sin
e it is the Newton-
Cotes formula for n = 2; it is exa
t for polynomials of degree 2: However, it
turns out that it is also exa
t for polynomials of degree 3.
Example Let us apply Simpson's rule to f (x) = x3 for general a; b: The a
tual answer is
Z b
(b4 a4 )
x3 dx = :
a 4
To apply Simpson's rule we noti
e that x0 = a; x1 = (a + b)=2; x2 = b and
h = (b a)=2: So Simpson's rule gives
h
(x30 + 4x31 + x32 );
3
whi
h is same as the exa
t integral (
he
k!)
quadratic interpolant
+ f(x) is cubic
-
The two areas marked + and are equal, and hen
e
an
el ea
h other out.
This is a
tually a general phenomenon for Newton-Cotes formulae for even n:
They are exa
t if f (x) is a polynomial of degree n + 1: However, if n is odd
then it is guaranteed to be exa
t only if f (x) is a polynomial of degree n: To
prove this let f (x) be a polynomial of degree n + 1: Then it
oin
ides with the
(n+1)-th degree interpolating polynomial, and hen
e
f (x) = f [x0 + (x x0 )f [x0 ; x1 + + f [x0 ; :::x (x x0 ) (x x ):
n n
If we use n-point Newton-Cotes formula, then we integrate only the rst n terms.
So we miss the last term, whose integral is
Z x n
f [x0 ; :::x
n (x x0 ) (x x )dx: n
x0
4
Sin
e the xi 's are regularly spa
ed, the polynomial
(x x0 ) (x x )
n
has a graph like the following. Ea
h shaded \hump" has the same area. For even
n there are exa
tly n=2 humps above and below the x-axis. So the algebrai
sum of the areas is zero.
n=3 n=2
x x x2 x3 x x1 x
0 1 0 2
As one
an see easily, the Newton-Cotes formulae be
ome more and more
om-
pli
ated as n in
reases. To avoid this, we use pie
ewise polynomial interpolation.
Ea
h pie
e is of a low degree, and we apply the low degree Newton-Cotes for-
mula for ea
h pie
e separately, and then add the results. The following diagram
shows how we
an approximate f (x) by pie
ewise linear interpolation.
yi1 y
i
a b a h b
Choose some positive integer n: Split the interval [a; b into n equal parts:
a; a + h; a + 2h; :::; a + nh = b;
where h = (b a)=n: Compute f (x) at ea
h of these points:
y = f (a + ih) for i = 0; 1; :::; n:
i
Now
ompute
Z b
h
f (x) dx [y0 + 2(y1 + + y 1 ) + yn :
a 2 n
5
Example Compute Z
p1 e
2
2
x =2
dx;
2 1
by trapezium rule using n = 5: We split the interval [1; 2 into 4 equal parts and
ompute yi 's.
i yi
0 0.2420
1 0.1826
2 0.1295
3 0.0863
4 0.0540
f (x) dx 0 + y2k )
a
+2(y2 + y4 + + y2(k 1) )
+ 4(y1 + y3 + + y2k 1 ) :
Example Now let us
ompute the integral from the last example using Simpson's rule.
We shall again use n = 4: This time the value is
0:25
3
[ (0:2420 + 0:0540)
+ 2 (0:1295) + 4 (0:1826 + 0:0863) = 0:1359;
whi
h is
orre
t up to 4 de
imal pla
es. Noti
e how Simpson's rule gives here
more a
urate value than the trapezium rule, though we have used the same n
in both methods.
6
4 Gaussian quadrature
So far we have been using f (x) only via its values at some regularly spa
ed
points xi 's. In some
ases, it may be impossible to know f (x) at other points,
e.g., if f (x) is not known analyti
ally but only measured by some experiment.
However, in many other
ases, it may be possible to
ompute f (x) at any value
of x of our
hoi
e. Then one may like to
hoose the values xi 's
arefully to
improve the a
ura
y of the quadrature in stead of using regularly spa
ed xi 's.
This is the main idea behind Gaussian quadrature. Here we try to approximate
the integral as Z b
f (x)dx 0 f (x0 ) + + f (x ); n n
a
where both i 's and xi 's are to be
hosen to in
rease the a
ura
y of the ap-
proximation. Sin
e we are
hoosing 2(n + 1) numbers here, (as
ompared to
only (n + 1) in Newton-Cotes) we would expe
t that Gaussian quadrature is
more a
urate (i.e., exa
t for higher degree polynomials) than Newton-Cotes
quadrature with the same n:
Theorem
Let x0 ; :::; xn be n + 1 distin
t numbers. Let m 1 be any integer. Then the
following two statements are equivalent.
1. There are
oe
ients 0 ; :::; n su
h that for any polynomial f (x) of degree
n + m; Z b X n
f (x)dx = f (x ):
i i (gau)
a
i=0
2. The polynomial
p(x) = (x x0 )(x x1 ) (x x ) n
satises Z b
x p(x)dx = 0
k
8k = 0; 1; :::; m 1: (orth)
a
Proof:
x p(x)dx =
k
x p(x ) = 0;
i
k
i i
a
i=0
7
where Z b
=
k x dx = (b
k k+1
ak+1
)=(k + 1):
a
The xi 's being distin
t, the
oe
ient matrix is nonsingular, and hen
e this
system uniquely xes the i 's. Thus, by
onstru
tion, (gau) holds for degrees
n: We need to show that it also hold for degrees n + 1; :::; n + m: Enough
to show that (gau) holds for f (x) = xk where k = n + 1; :::; n + m: We shall
pro
eed by indu
tion. First
onsider f (x) = xn+1 : For this it is enough to show
that (gau) holds for f (x) = p(x); sin
e p(x) is an (n + 1)-degree polynomial
and the (gau) already holds for 1; x; x2 ; :::; xn : Thus, we are to show that
Z b X n
p(x)dx = p(x );
i i
a
i=0
whi
h is trivial, sin
e the l.h.s. vanishes by (orth) and the r.h.s. vanishes
by denition of p(x): This
ompletes the proof for f (x) = xn+1 : Now assume
that (gau) holds for f (x) = xn+1 ; :::; xn+k : We shall show that (gau) holds for
f (x) = xn+k+1 : But this is the same as showing that (gau) holds for xk p(x);
sin
e it is an n + k + 1-degree polynomial and (gau) already holds for powers
n + k: So we are to show
Z b X n
x p(x)dx =
k
x p(x );
i
k
i
a
i=0
whi
h is again trivial, sin
e the l.h.s. vanishes by (orth) and the r.h.s. vanishes
by denition of p(x):
hf; gi = f (x)g(x)dx:
a
8
Proof:
Let zk;0 ; :::; zk;k 1 be the zeros of pk (x): Then Gaussian quadrature with n + 1
points uses the following approximation:
Z b X
n
where the n+1;i 's are obtained from the Vandermonde system with xi = zn+1;i :
This is exa
t if f (x) is a polynomial of degree 2n:
Example Let us expli
itly
ompute p0 (x); p1 (x) and p2 (x): Noti
e that we
are only about
the roots of the polynomials, so we shall save ourselves the trouble of normalizing
the polynomials. We start with the usual basis
u0 (x) = 1; u1 (x) = x; u2(x) = x2 ; : : : :
We take
p0 (x) = u0 (x) = 1:
Taking out the p0 -
omponent from u1 we are left with
p1 = u1
hu ; p i p
1 0
= u1 = x;
hp ; p i
0 0
0
sin
e Z 1
hu ; p i =
1 0 xdx = 0:
1
p2 = u2
hu ; p i p
2 0 hu ; p i p :
2 1
hp ; p i
0 0
0
hp ; p i
1 1
1
Example People have
omputed the zeros of pk (x)'s and the
orresponding i 's and pub-
lished the values as tables. Here are the values for k = 5:
i z5 ;i 5 ;i
0 0:00000000 0:56888889
1 0:53846931 0:47862867
2 0:53846931 0:47862867
3 0:90617985 0:23692689
4 0:90617985 0:23692689
9
Thus, if we want to integrate f (x) = 1=(x + 3); we shall
ompute as follows.
:=
k w(x)x dxk
10
It is easy to see that ea
h pk (x) has degree k: The following theorem is a gen-
eralization of the last theorem.
Theorem
Ea
h pk (x) has k distin
t, real zeros inside the open interval (a; b):
Proof:
where zn+1;0 ; :::; zn+1;n are the zeros of pn+1 (x) and the n+1;i 's are obtained
from 2 32 3 2 3
1 1 1 n+1;0
0
66 x0 x1 x 77 66
n n+1;1
7
7 6
6
1 7
7
66 x20 x21 x 77 66
2
n+1;2
7
7 6
= 6
2 7
7;
64 .. 7 6 7
n
.. .. ..
. . . 54 . 5 4 5
x0 x1n n
x n
n
n+1;n
n
where Z b
= k x w(x)dx:
k
Certain
hoi
es of weights are more popular than others. Here is an in
omplete
list.
Standard tables are available for zk;i 's and n;i 's for these
ases. Here are some
of these.
Gauss-Laguerre
i z5 ;i 5 ;i
0 0:263560319718 0:521755610583
1 1:413403059107 0:398666811083
2 3:596425771041 0:759424496817e 1
3 7:085810005859 0:361175867992e 2
4 12:640800844276 0:233699723858e 4
For Gauss-Chebyshev there are simple
losed-form formulae for zk;i 's and k;i 's:
(2i + 1)
z =
os ; = :
k;i
2k k;i
k
Here is the table for Gauss-Hermite.
11
Gauss-Hermite
i z5 ;i 5 ;i
0; 1 2:0201828705 0:0199532421
2; 3 0:9585724646 0:3936193232
4 0:0000000000 0:9453087205
12