0% found this document useful (0 votes)
24 views24 pages

Very Important Q3

This document discusses numerical integration techniques for approximating integrals. It begins by introducing the concepts of Riemann integration and upper and lower Darboux sums. It then describes two basic numerical integration methods: the rectangular rule, which approximates the integral using function values at the interval endpoints, and the midpoint rule, which uses the midpoint. The document analyzes the error terms for these methods. It further discusses approximating integrals by interpolating function values and integrating the interpolating function. In particular, it presents the trapezoidal rule as an example of this approach.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views24 pages

Very Important Q3

This document discusses numerical integration techniques for approximating integrals. It begins by introducing the concepts of Riemann integration and upper and lower Darboux sums. It then describes two basic numerical integration methods: the rectangular rule, which approximates the integral using function values at the interval endpoints, and the midpoint rule, which uses the midpoint. The document analyzes the error terms for these methods. It further discusses approximating integrals by interpolating function values and integrating the interpolating function. In particular, it presents the trapezoidal rule as an example of this approach.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

D.

Levy
6 Numerical Integration
6.1 Basic Concepts
In this chapter we are going to explore various ways for approximating the integral of a
function over a given domain. There are various reasons as of why such approximations
can be useful. First, not every function can be analytically integrated. Second, even if a
closed integration formula exists, it might still not be the most ecient way of calculating
the integral. In addition, it can happen that we need to integrate an unknown function,
in which only some samples of the function are known.
In order to gain some insight on numerical integration, it is natural to review Rie-
mann integration, a framework that can be viewed as an approach for approximat-
ing integrals. We assume that f(x) is a bounded function dened on [a, b] and that
{x
0
, . . . , x
n
} is a partition (P) of [a, b]. For each i we let
M
i
(f) = sup
x[x
i1
,x
i
]
f(x),
and
m
i
(f) = inf
x[x
i1
,x
i
]
f(x),
Letting x
i
= x
i
x
i1
, the upper (Darboux) sum of f(x) with respect to the
partition P is dened as
U(f, P) =
n

i=1
M
i
x
i
, (6.1)
while the lower (Darboux) sum of f(x) with respect to the partition P is dened as
L(f, P) =
n

i=1
m
i
x
i
. (6.2)
The upper integral of f(x) on [a, b] is dened as
U(f) = inf(U(f, P)),
and the lower integral of f(x) is dened as
L(f) = sup(L(f, P)),
where both the inmum and the supremum are taken over all possible partitions, P, of
the interval [a, b]. If the upper and lower integral of f(x) are equal to each other, their
common value is denoted by
_
b
a
f(x)dx and is referred to as the Riemann integral of
f(x).
1
6.1 Basic Concepts D. Levy
For the purpose of the present discussion we can think of the upper and lower Dar-
boux sums (6.1), (6.2), as two approximations of the integral (assuming that the function
is indeed integrable). Of course, these sums are not dened in the most convenient way
for an approximation algorithm. This is because we need to nd the extrema of the func-
tion in every subinterval. Finding the extrema of the function, may be a complicated
task on its own, which we would like to avoid.
A simpler approach for approximating the value of
_
b
a
f(x)dx would be to compute
the product of the value of the function at one of the end-points of the interval by the
length of the interval. In case we choose the end-point where the function is evaluated
to be x = a, we obtain
_
b
a
f(x)dx f(a)(b a). (6.3)
This approximation (6.3) is called the rectangular method (see Figure 6.1). Numeri-
cal integration formulas are also referred to as integration rules or quadratures, and
hence we can refer to (6.3) as the rectangular rule or the rectangular quadrature. The
points x
0
, . . . x
n
that are used in the quadrature formula are called quadrature points.
a b
f(a)
f(b)
x
f
(
x
)
Figure 6.1: A rectangular quadrature
A variation on the rectangular rule is the midpoint rule. Similarly to the rectan-
gular rule, we approximate the value of the integral
_
b
a
f(x)dx by multiplying the length
of the interval by the value of the function at one point. Only this time, we replace the
value of the function at an endpoint, by the value of the function at the center point
2
D. Levy 6.1 Basic Concepts
1
2
(a + b), i.e.,
_
b
a
f(x)dx (b a)f
_
a + b
2
_
. (6.4)
(see also Fig 6.2). As we shall see below, the midpoint quadrature (6.4) is a more
accurate quadrature than the rectangular rule (6.3).
a (a+b)/2 b
f(a)
f((a+b)/2)
f(b)
x
f
(
x
)
Figure 6.2: A midpoint quadrature
In order to compute the quadrature error for the midpoint rule (6.4), we consider
the primitive function F(x),
F(x) =
_
x
a
f(s)ds,
and expand
_
a+h
a
f(s)ds = F(a + h) = F(a) + hF

(a) +
h
2
2
F

(a) +
h
3
6
F

(a) + O(h
4
) (6.5)
= hf(a) +
h
2
2
f

(a) +
h
3
6
f

(a) + O(h
4
)
If we let b = a + h, we have (expanding f(a + h/2)) for the quadrature error, E,
E =
_
a+h
a
f(s)ds hf
_
a +
h
2
_
= hf(a) +
h
2
2
f

(a) +
h
3
6
f

(a) + O(h
4
)
h
_
f(a) +
h
2
f

(a) +
h
2
8
f

(a) + O(h
3
)
_
,
3
6.1 Basic Concepts D. Levy
which means that the error term is of order O(h
3
). Having an error of order h
3
does
not mean that this is a third-order method. In our case, the parameter h equals to
b a. It is not a parameter that should be vied as a small value that goes to zero. It is
xed. The error of the midpoint method is of the order of O((b a)
3
). Unfortunately,
these calculations cannot directly provide us with an accurate estimate of the error.
This is the case since when truncating two Taylor approximations, we are left with an
error terms that are evaluated at two (generally dierent) intermediate points. Hence
we cannot directly combine the error term
1
6
h
3
f

(
1
) with
1
8
h
3
f

(
2
). This can still be
done, but we have to use a better approach.
The main diculty in evaluating the dierence between the exact value,
_
b
a
f(x)dx,
and its midpoint rule approximation, (b a)f
_
a+b
2
_
, is due to having an integral in one
term and no integral in the second term. The approach will be to replace the midpoint
approximation with an integral expression. Indeed, if we denote the midpoint by c, i.e.,
c =
a + b
2
,
then the tangent line to f(x) at x = c is given by
P
1
(x) = f(c) + f

(c)(x c).
Clearly,
_
b
a
P
1
(x)dx = (b a)f(c),
and hence
_
b
a
f(x)dx (b a)f
_
a + b
2
_
=
_
b
a
(f(x) P
1
(x))dx.
To estimate the dierence between f(x) and P
1
(x) we can expand f(x) around x = c.
Assuming that x [a, b], we have
f(x) = f(c + (x c)) = f(c) + f

(c)(x c) +
1
2
f

()(x c)
2
, (a, b).
Hence
_
b
a
(f(x) P
1
(x))dx =
_
b
a
1
2
f

(
x
)(x c)
2
dx.
In view of the midvalue theorem for integrals, the last integral can be replaces by
1
2
f

()
_
b
a
(x c)
2
dx =
1
24
(b a)
3
f

(), a < < b. (6.6)


Remark. Throughout this section we assumed that all functions we are interested in
integrating are actually integrable in the domain of interest. We also assumed that they
are bounded and that they are dened at every point, so that whenever we need to
evaluate a function at a point, we can do it. We will go on and use these assumptions
throughout the chapter.
4
D. Levy 6.2 Integration via Interpolation
6.2 Integration via Interpolation
One direct way of obtaining quadratures from given samples of a function is by integrat-
ing an interpolant. As always, our goal is to evaluate I =
_
b
a
f(x)dx. We assume that
the values of the function f(x) are given at n + 1 points: x
0
, . . . , x
n
[a, b]. Note that
we do not require the rst point x
0
to be equal to a, and the same holds for the right
side of the interval. Given the values f(x
0
), . . . f(x
n
), we can write the interpolating
polynomial of degree n, which in the Largenge form is
P
n
(x) =
n

i=0
f(x
i
)l
i
(x),
with
l
i
(x) =
n

j=0
j=i
x x
j
x
i
x
j
, 0 i n.
The integral of f(x) can then be approximated by the integral of P
n
(x), i.e.,
_
b
a
f(x)dx
_
b
a
P
n
(x)dx =
n

i=0
f(x
i
)
_
b
a
l
i
(x)dx =
n

i=0
A
i
f(x
i
). (6.7)
The quadrature coecients A
i
in (6.7) are given by
A
i
=
_
b
a
l
i
(x)dx. (6.8)
Note that if we want to integrate several dierent functions, and use their values at
the same points (x
0
, . . . , x
n
), the quadrature coecients (6.8) should be computed only
once, since they do not depend on the function that is being integrated. If we change the
interpolation/integration points, then we must recompute the quadrature coecients.
For equally spaced points, x
0
, . . . , x
n
, a numerical integration formula of the form
_
b
a
f(x)dx
n

i=0
A
i
f(x
i
), (6.9)
is called a Newton-Cotes formula.
Example 6.1
We let n = 1 and consider two interpolation points which we set as
x
0
= a, x
1
= b.
In this case
l
0
(x) =
b x
b a
, l
1
(x) =
x a
b a
.
5
6.2 Integration via Interpolation D. Levy
Hence
A
0
=
_
b
a
l
0
(x) =
_
b
a
b x
b a
dx =
b a
2
.
Similarly,
A
1
=
_
b
a
l
1
(x) =
_
b
a
x a
b a
dx =
b a
2
= A
0
.
The resulting quadrature is the so-called trapezoidal rule,
_
b
a
dx
b a
2
[f(a) + f(b)], (6.10)
(see Figure 6.3).
a b
f(a)
f(b)
x
f
(
x
)
Figure 6.3: A trapezoidal quadrature
We can now use the interpolation error to compute the error in the quadrature (6.10).
The interpolation error is
f(x) P
1
(x) =
1
2
f

(
x
)(x a)(x b),
x
(a, b).
We recall that according to the midvalue theorem for integrals, if u(x) and v(x) are
continuous on [a, b] and if v 0, then there exists (a, b) such that
_
b
a
u(x)v(x)dx = u()
_
b
a
v(x)dx.
6
D. Levy 6.2 Integration via Interpolation
Hence, the interpolation error is given by
E =
_
b
a
1
2
f

(
x
)(xa)(xb) =
f

()
2
_
b
a
(xa)(xb)dx =
f

()
12
(b a)
3
, (6.11)
with (a, b).
Remarks.
1. We note that the quadratures (6.7),(6.8), are exact for polynomials of degree
n. For if p(x) is a polynomial of degree n, it can be written as
p(x) =
n

i=0
p(x
i
)l
i
(x).
(Two polynomials of degree n that agree with each other at n + 1 points must
be identical). Hence
_
b
a
p(x)dx =
n

i=0
p(x
i
)
_
b
a
l
i
(x)dx =
n

i=0
A
i
p(x
i
).
2. As of the opposite direction. Assume that the quadrature
_
b
a
f(x)dx
n

i=0
A
i
f(x
i
),
is exact for all polynomials of degree n. We know that
deg(l
j
(x)) = n,
and hence
_
b
a
l
j
(x)dx =
n

i=0
A
i
l
j
(x
i
) =
n

i=0
A
i

ij
= A
j
.
This menas that the quadrature coecients must be given by
A
j
=
_
b
a
l
j
(x)dx.
7
6.3 Composite Integration Rules D. Levy
6.3 Composite Integration Rules
In a composite quadrature, we divide the interval into subintervals and apply an inte-
gration rule to each subinterval. We demonstrate this idea with a couple of examples.
Example 6.2
Consider the points
a = x
0
< x
1
< < x
n
= b.
The composite trapezoidal rule is obtained by applying the trapezoidal rule in each
subinterval [x
i1
, x
i
], i = 1, . . . , n, i.e.,
_
b
a
f(x)dx =
n

i=1
_
x
i
x
i1
f(x)dx
1
2
n

i=1
(x
i
x
i1
)[f(x
i1
) + f(x
i
)], (6.12)
(see Figure 6.4).
x
0
x
1
x
2
x
n1
x
n
x
f
(
x
)
Figure 6.4: A composite trapezoidal rule
A particular case is when these points are uniformly spaced, i.e., when all intervals
have an equal length. For example, if
x
i
= a + ih,
where
h =
b a
n
,
8
D. Levy 6.3 Composite Integration Rules
then
_
b
a
f(x)dx
h
2
_
f(a) + 2
n1

i=1
f(a + ih) + f(b)
_
= h
n

i=0

f(a + ih). (6.13)


The notation of a sum with two primes,

, means that we sum over all the terms with


the exception of the rst and last terms that are being divided by 2.
We can also compute the error term as a function of the distance between neighboring
points, h. We know from (6.11) that in every subinterval the quadrature error is

h
3
12
f

(
x
).
Hence, the overall error is obtained by summing over n such terms:
n

i=1

h
3
12
f

(
i
) =
h
3
n
12
_
1
n
n

i=1
f

(
i
)
_
.
Here, we use the notation
i
to denote an intermediate point that belongs to the i
th
interval. Let
M =
1
n
n

i=1
f

(
i
).
Clearly
min
x[a,b]
f

(x) M max
x[a,b]
f

(x)
If we assume that f

(x) is continuous in [a, b] (which we anyhow do in order for the


interpolation error formula to be valid) then there exists a point [a, b] such that
f

() = M.
Hence (recalling that (b a)/n = h, we have
E =
(b a)h
2
12
f

(), [a, b]. (6.14)


This means that the composite trapezoidal rule is second-order accurate.
Example 6.3
In the interval [a, b] we assume n subintervals and let
h =
b a
n
.
9
6.4 Additional Integration Techniques D. Levy
The quadrature points are
x
j
= a +
_
j
1
2
_
h, j = 1, 2, . . . , n.
The composite midpoint rule is given by applying the midpoint rule (6.4) in every
subinterval, i.e.,
_
b
a
f(x)dx h
n

j=1
f(x
j
). (6.15)
Equation (6.15) is known as the composite midpoint rule.
In order to obtain the quadrature error in the approximation (6.15) we recall that
in each subinterval the error is given according to (6.6), i.e.,
E
j
=
h
3
24
f

(
j
),
j

_
x
j

h
2
, x
j
+
h
2
_
.
Hence
E =
n

j=1
E
j
=
h
3
24
n

j=1
f

(
j
) =
h
3
24
n
_
1
n
n

j=1
f

(
j
)
_
=
h
2
(b a)
24
f

(), (6.16)
where (a, b). This means that the composite midpoint rule is also second-order
accurate (just like the composite trapezoidal rule).
6.4 Additional Integration Techniques
6.4.1 The method of undetermined coecients
The methods of undetermined coecients for deriving quadratures is the following:
1. Select the quadrature points.
2. Write a quadrature as a linear combination of the values of the function at the
chosen quadrature points.
3. Determine the coecients of the linear combination by requiring that the quadra-
ture is exact for as many polynomials as possible from the the ordered set {1, x, x
2
, . . .}.
We demonstrate this technique with the following example.
Example 6.4
Problem: Find a quadrature of the form
_
1
0
f(x)dx A
0
f(0) + A
1
f
_
1
2
_
+ A
2
f(1),
that is exact for all polynomials of degree 2.
10
D. Levy 6.4 Additional Integration Techniques
Solution: Since the quadrature has to be exact for all polynomials of degree 2, it has
to be exact for the polynomials 1, x, and x
2
. Hence we obtain the system of linear
equations
1 =
_
1
0
1dx = A
0
+ A
1
+ A
2
,
1
2
=
_
1
0
xdx =
1
2
A
1
+ A
2
,
1
3
=
_
1
0
x
2
dx =
1
4
A
1
+ A
2
.
Therefore, A
0
= A
2
=
1
6
and A
1
=
2
3
, and the desired quadrature is
_
1
0
f(x)dx
f(0) + 4f
_
1
2
_
+ f(1)
6
. (6.17)
Since the resulting formula (6.17) is linear, its being exact for 1, x, and x
2
, implies that
it is exact for any polynomial of degree 2. In fact, we will show in Section 6.5.1 that
this approximation is actually exact for polynomials of degree 3.
6.4.2 Change of an interval
Suppose that we have a quadrature formula on the interval [c, d] of the form
_
d
c
f(t)dt
n

i=0
A
i
f(t
i
). (6.18)
We would like to to use (6.18) to nd a quadrature on the interval [a, b], that approxi-
mates for
_
b
a
f(x)dx.
The mapping between the intervals [c, d] [a, b] can be written as a linear transforma-
tion of the form
(t) =
b a
d c
t +
ad bc
d c
.
Hence
_
b
a
f(x)dx =
b a
d c
_
d
c
f((t))dt
b a
d c
n

i=0
A
i
f((t
i
)).
This means that
_
b
a
f(x)dx
b a
d c
n

i=0
A
i
f
_
b a
d c
t
i
+
ad bc
d c
_
. (6.19)
We note that if the quadrature (6.18) was exact for polynomials of degree m, so is (6.19).
11
6.5 Simpsons Integration D. Levy
Example 6.5
We want to write the result of the previous example
_
1
0
f(x)dx
f(0) + 4f
_
1
2
_
+ f(1)
6
,
as a quadrature on the interval [a, b]. According to (6.19)
_
b
a
f(x)dx
b a
6
_
f(a) + 4f
_
a + b
2
_
+ f(b)
_
. (6.20)
The approximation (6.20) is known as the Simpson quadrature.
6.5 Simpsons Integration
In the last example we obtained Simpsons quadrature (6.20). An alternative derivation
is the following: start with a polynomial Q
2
(x) that interpolates f(x) at the points a,
(a + b)/2, and b. Then approximate
_
b
a
f(x)dx
_
b
a
_
(x c)(x b)
(a c)(a b)
f(a) +
(x a)(x b)
(c a)(c b)
f(c) +
(x a)(x c)
(b a)(b c)
f(b)
_
dx
= . . . =
b a
6
_
f(a) + 4f
_
a + b
2
_
+ f(b)
_
,
which is Simpsons rule (6.20). Figure 6.5 demonstrates this process of deriving Simp-
sons quadrature for the specic choice of approximating
_
3
1
sin xdx.
6.5.1 The quadrature error
It turns out that Simpsons quadrature is exact for polynomials of degree 3 and not
only for polynomials of degree 2, as expected by the way it was constructed. We will
obtain this result by studying the error term.
In order to derive the error term for Simpsons method, we discuss an error analysis
technique that is valid for quadratures that are obtained through integration. In all
such cases, the quadrature error is the dierence between the integral of the function
and the integral of its interpolant, i.e.,
E =
_
b
a
(f(t) p
n
(t))dt =
_
b
a
f
(n+1)
(
x
)
(n + 1)!
(t)dt, (6.21)
where
(t) =
n

i=0
(t t
i
)dt.
12
D. Levy 6.5 Simpsons Integration
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
0
0.2
0.4
0.6
0.8
1
P
2
(x)
sinx
x
Figure 6.5: An example of Simpsons quadrature. The approximation of
_
3
1
sin xdx is
obtained by integrating the quadratic interpolant Q
2
(x) over [1, 3]
It (t) is always non-negative or non-positive between a and b, then according to the
midvalue theorem for integrals, the error in (6.21) becomes
E =
f
(n+1)
()
(n + 1)!
_
b
a
(t)dt, (a, b).
Examples for such cases are the trapezoidal rule for which
E =
f

()
12
(b a)
3
,
and the rectangle rule for which
E =
f

()
1
_
b
a
(t a)dt =
f

()
2
(b a)
2
.
Another case which is rather easy to analyze is the case in which
_
b
a
(t)dt = 0. (6.22)
Examples for the case in (6.22) include the midpoint rule for which
_
b
a
(t)dt =
_
b
a
_
t
a + b
2
_
dt = 0,
13
6.5 Simpsons Integration D. Levy
and Simpsons rule for which
_
b
a
(t)dt =
_
b
a
(t a)
_
t
a + b
2
_
(t b)dt = 0.
In this case, we can add another interpolation point without changing the integral of
the interpolant. This is the case since we replace f(x) by p
n
(x) and integrate
_
b
a
f(t)dt
_
b
a
p
n
(x)dx.
Adding an arbitrary interpolation point, x
n+1
, to p
n
(x) turns it into an interpolating
polynomial of a higher order, p
n+1
(x), that is given by
p
n+1
(x) = p
n
(x) + f[x
0
, . . . , x
n+1
](x). (6.23)
Since
_
b
a
(x)dx = 0, when integrating (6.23) in order to obtain a quadrature, we
observe that
_
b
a
f(t)dt
_
b
a
p
n+1
(x)dx =
_
b
a
p
n
(x)dx,
so the original quadrature does not change by adding an arbitrary interpolation point.
We now have all the required tools in order to derive a quadrature for Simpsons
method. Since in this case
_
b
a
(t)dt = 0, we add to a,
a+b
2
, b an arbitrary interpolation
point which we choose as
a+b
2
again. The function (t) becomes
(t) = (t a)
_
t
a + b
2
_
2
(t b).
Hence, for t [a, b], our new (t) satises (t) 0. By the midvalue theorem for
integrals the error in Simpsons method can be written as
E =
f
(4)
()
24
_
b
a
(t a)
_
t
a + b
2
_
2
(t b)dt =
1
90
_
b a
2
_
5
f
(4)
(), (6.24)
for (a, b). Since the fourth derivative of any polynomial of degree 3 is identically
zero, the quadrature error formula (6.24) implies that Simpsons quadrature is exact for
polynomials of degree 3.
6.5.2 Composite Simpson rule
To derive a composite version of Simpsons quadrature, we divide the interval [a, b] into
an even number of subintervals, n, and let
x
i
= a + ih, 0 i n,
14
D. Levy 6.6 Weighted Quadratures
where
h =
b a
n
.
Hence, if we replace the integral in every subintervals by Simpsons rule (6.20), we obtain
_
b
a
f(x)dx =
_
x
2
x
0
f(x)dx + . . . +
_
xn
x
n2
f(x)dx =
n/2

i=1
_
x
2i
x
2i2
f(x)dx

h
3
n/2

i=1
[f(x
2i2
) + 4f(x
2i1
) + f(x
2i
)] .
The composite Simpson quadrature is thus given by
_
b
a
f(x)dx
h
3
_
_
f(x
0
) + 2
n/2

i=0
f(x
2i2
) + 4
n/2

i=1
f(x
2i1
) + f(x
n
)
_
_
. (6.25)
Summing the error terms (that are given by (6.24)) over all sub-intervals, the quadrature
error takes the form
E =
h
5
90
n/2

i=1
f
(4)
(
i
) =
h
5
90

n
2

2
n
n/2

i=1
f
(4)
(
i
).
Since
min
x[a,b]
f
(4)
(x)
2
n
n/2

i=1
f
(4)
(
i
) max
x[a,b]
f
(4)
(x),
we can conclude that
E =
h
5
90
n
2
f
(4)
() =
h
4
180
f
(4)
(), [a, b], (6.26)
i.e., the composite Simpson quadrature is fourth-order accurate.
6.6 Weighted Quadratures
We recall that a weight function is a continuous, non-negative function with a positive
mass. We assume that such a weight function w(x) is given and would like to write a
quadrature of the form
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
). (6.27)
15
6.7 Gaussian Quadrature D. Levy
Such quadratures are called general (weighted) quadratures.
Previously, for the case w(x) 1, we wrote a quadrature of the form
_
b
a
f(x)dx
n

i=0
A
i
f(x
i
),
where
A
i
=
_
b
a
l
i
(x)dx.
Repeating the derivation we carried out in Section 6.2, we construct an interpolant
Q
n
(x) of degree n that passes through the points x
0
, . . . , x
n
. Its Lagrange form is
Q
n
(x) =
n

i=0
f(x
i
)l
i
(x),
with the usual
l
i
(x) =
n

j=0
j=i
x x
j
x
i
x
j
, 0 i n.
Hence
_
b
a
f(x)w(x)dx
_
b
a
Q
n
(x)w(x)dx =
n

i=0
f(x
i
)
_
b
a
l
i
(x)w(x)dx =
n

i=0
A
i
f(x
i
),
where the coecients A
i
are given by
A
i
=
_
b
a
l
i
(x)w(x)dx. (6.28)
To summarize, the general quadrature is
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
), (6.29)
with quadrature coecients, A
i
, that are given by (6.28).
6.7 Gaussian Quadrature
6.7.1 Maximizing the quadratures accuracy
So far, all the quadratures we encountered were of the form
_
b
a
f(x)dx
n

i=0
A
i
f(x
i
). (6.30)
16
D. Levy 6.7 Gaussian Quadrature
An approximation of the form (6.30) was shown to be exact for polynomials of degree n
for an appropriate choice of the quadrature coecients A
i
. In all cases, the quadrature
points x
0
, . . . , x
n
were given up front. In other words, given a set of nodes x
0
, . . . , x
n
,
the coecients {A
i
}
n
i=0
were determined such that the approximation was exact in
n
.
We are now interested in investigating the possibility of writing more accurate
quadratures without increasing the total number of quadrature points. This will be
possible if we allow for the freedom of choosing the quadrature points. The quadra-
ture problem becomes now a problem of choosing the quadrature points in addition to
determining the corresponding coecients in a way that the quadrature is exact for
polynomials of a maximal degree. Quadratures that are obtained that way are called
Gaussian quadratures.
Example 6.6
The quadrature formula
_
1
1
f(x)dx f
_

3
_
+ f
_
1

3
_
,
is exact for polynomials of degree 3(!) We will revisit this problem and prove this
result in Example 6.9 below.
An equivalent problem can be stated for the more general weighted quadrature case.
Here,
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
), (6.31)
where w(x) 0 is a weight function. Equation (6.31) is exact for f
n
if and only if
A
i
=
_
b
a
w(x)

j=0
j=i
x x
j
x
i
x
j
dx. (6.32)
In both cases (6.30) and (6.31), the number of quadrature nodes, x
0
, . . . , x
n
, is n+1,
and so is the number of quadrature coecients, A
i
. Hence, if we have the exibility
of determining the location of the points in addition to determining the coecients,
we have altogether 2n + 2 degrees of freedom, and hence we can expect to be able to
derive quadratures that are exact for polynomials in
2n+1
. This is indeed the case as
we shall see below. We will show that the general solution of this integration problem
is connected with the roots of orthogonal polynomials. We start with the following
theorem.
Theorem 6.7 Let q(x) be a nonzero polynomial of degree n+1 that is w-orthogonal to

n
, i.e., p(x)
n
,
_
b
a
p(x)q(x)w(x)dx = 0.
17
6.7 Gaussian Quadrature D. Levy
If x
0
, . . . , x
n
are the zeros of q(x) then (6.31), with A
i
given by (6.32), is exact f

2n+1
.
Proof. For f(x)
2n+1
, write f(x) = q(x)p(x) + r(x). We note that p(x), r(x)
n
.
Since x
0
, . . . , x
n
are the zeros of q(x) then
f(x
i
) = r(x
i
).
Hence,
_
b
a
f(x)w(x)dx =
_
b
a
[q(x)p(x) + r(x)]w(x)dx =
_
b
a
r(x)w(x)dx (6.33)
=
n

i=0
A
i
r(x
i
) =
n

i=0
A
i
f(x
i
).
The second equality in (6.33) holds since q(x) is w-orthogonal to
n
. The third equality
(6.33) holds since (6.31), with A
i
given by (6.32), is exact for polynomials in
n
.

According to Theorem 6.7 we already know that the quadrature points that will
provide the most accurate quadrature rule are the n+1 roots of an orthogonal polynomial
of degree n + 1 (where the orthogonality is with respect to the weight function w(x)).
We recall that the roots of q(x) are real, simple and lie in (a, b), something we know
from our previous discussion on orthogonal polynomials (see Theorem ??). In other
words, we need n + 1 quadrature points in the interval, and an orthogonal polynomial
of degree n +1 does have n +1 distinct roots in the interval. We now restate the result
regarding the roots of orthogonal functions with an alternative proof.
Theorem 6.8 Let w(x) be a weight function. Assume that f(x) is continuous in [a, b]
that is not the zero function, and that f(x) is w-orthogonal to
n
. Then f(x) changes
sign at least n + 1 times on (a, b).
Proof. Since 1
n
,
_
b
a
f(x)w(x)dx = 0.
Hence, f(x) changes sign at least once. Now suppose that f(x) changes size only r
times, where r n. Choose {t
i
}
i0
such that
a = t
0
< t
1
< < t
r
= b,
and f(x) is of one sign on (t
0
, t
1
), (t
1
, t
2
), . . . , (t
r1
, t
r
). The polynomial
p(x) =
r1

i=0
(x t
i
),
18
D. Levy 6.7 Gaussian Quadrature
has the same sign property. Hence
_
b
a
f(x)p(x)w(x)dx = 0,
which leads to a contradiction since p(x)
n
.

Example 6.9
We are looking for a quadrature of the form
_
1
1
f(x)dx A
0
f(x
0
) + A
1
f(x
1
).
A straightforward computation will amount to making this quadrature exact for the
polynomials of degree 3. The linearity of the quadrature means that it is sucient to
make the quadrature exact for 1, x, x
2
, and x
3
. Hence we write the system of equations
_
1
1
f(x)dx =
_
1
1
x
i
dx = A
0
x
i
0
+ A
1
x
i
1
, i = 0, 1, 2, 3.
From this we can write
_

_
A
0
+ A
1
= 2,
A
0
x
0
+ A
1
x
1
= 0,
A
0
x
2
0
+ A
1
x
2
1
=
2
3
,
A
0
x
3
0
+ A
1
x
3
1
= 0.
Solving for A
1
, A
2
, x
0
, and x
1
we get
A
1
= A
2
= 1, x
0
= x
1
=
1

3
,
so that the desired quadrature is
_
1
1
f(x)dx f
_

3
_
+ f
_
1

3
_
. (6.34)
Example 6.10
We repeat the previous problem using orthogonal polynomials. Since n = 1, we expect
to nd a quadrature that is exact for polynomials of degree 2n+1 = 3. The polynomial
of degree n+1 = 2 which is orthogonal to
n
=
1
with weight w(x) 1 is the Legendre
polynomial of degree 2, i.e.,
P
2
(x) =
1
2
(3x
2
1).
19
6.7 Gaussian Quadrature D. Levy
The integration points will then be the zeros of P
2
(x), i.e.,
x
0
=
1

3
, x
1
=
1

3
.
All that remains is to determine the coecients A
1
, A
2
. This is done in the usual way,
assuming that the quadrature
_
1
1
f(x)dx A
0
f(x
0
) + A
1
f(x
1
),
is exact for polynomials of degree 1. The simplest will be to use 1 and x, i.e.,
2 =
_
1
1
1dx = A
0
+ A
1
,
and
0 =
_
1
1
xdx = A
0
1

3
+ A
1
1

3
.
Hence A
0
= A
1
= 1, and the quadrature is the same as (6.34) (as should be).
6.7.2 Convergence and error analysis
Lemma 6.11 In a Gaussian quadrature formula, the coecients are positive and their
sum is
_
b
a
w(x)dx.
Proof. Fix n. Let q(x)
n+1
be w-orthogonal to
n
. Also assume that q(x
i
) = 0 for
i = 0, . . . , n, and take {x
i
}
n
i=0
to be the quadrature points, i.e.,
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
). (6.35)
Fix 0 j n. Let p(x)
n
be dened as
p(x) =
q(x)
x x
j
.
Since x
j
is a root of q(x), p(x) is indeed a polynomial of degree n. The degree of
p
2
(x) 2n which means that the Gaussian quadrature (6.35) is exact for it. Hence
0 <
_
b
a
p
2
(x)w(x)dx =
n

i=0
A
i
p
2
(x
i
) =
n

i=0
A
i
q
2
(x
i
)
(x
i
x
j
)
2
= A
j
p
2
(x
j
),
20
D. Levy 6.7 Gaussian Quadrature
which means that j, A
j
> 0. In addition, since the Gaussian quadrature is exact for
f(x) 1, we have
_
b
a
w(x)dx =
n

i=0
A
i
.

In order to estimate the error in the Gaussian quadrature we would rst like to
present an alternative way of deriving the Gaussian quadrature. Our starting point
is the Lagrange form of the Hermite polynomial that interpolates f(x) and f

(x) at
x
0
, . . . , x
n
. It is given by (??), i.e.,
p(x) =
n

i=0
f(x
i
)a
i
(x) +
n

i=0
f

(x
i
)b
i
(x),
with
a
i
(x) = (l
i
(x))
2
[1 + 2l

i
(x
i
)(x
i
x)], b
i
(x) = (x x
i
)l
2
i
(x), 0 i n,
and
l
i
(x) =
n

j=0
j=i
x x
j
x
i
x
j
.
We now assume that w(x) is a weight function in [a, b] and approximate
_
b
a
w(x)f(x)dx
_
b
a
w(x)p
2n+1
(x)dx =
n

i=0
A
i
f(x
i
) +
n

i=0
B
i
f

(x
i
), (6.36)
where
A
i
=
_
b
a
w(x)a
i
(x)dx, (6.37)
and
B
i
=
_
b
a
w(x)b
i
(x)dx. (6.38)
In some sense, it seems to be rather strange to deal with the Hermite interpolant when
we do not explicitly know the values of f

(x) at the interpolation points. However, we


can eliminate the derivatives from the quadrature (6.36) by setting B
i
= 0 in (6.38).
Indeed (assuming n = 0):
B
i
=
_
b
a
w(x)(x x
i
)l
2
i
(x)dx =
n

j=0
j=i
(x
i
x
j
)
_
b
a
w(x)
n

j=0
(x x
j
)l
i
(x)dx.
21
6.7 Gaussian Quadrature D. Levy
Hence, B
i
= 0, if the product

n
j=0
(x x
j
) is orthogonal to l
i
(x). Since l
i
(x) is a
polynomial in
n
, all that we need is to set the points x
0
, . . . , x
n
as the roots of a
polynomial of degree n+1 that is w-orthogonal to
n
. This is precisely what we dened
as a Gaussian quadrature.
We are now ready to formally establish the fact that the Gaussian quadrature is
exact for polynomials of degree 2n + 1.
Theorem 6.12 Let f C
2n+2
[a, b] and let w(x) be a weight function. Consider the
Gaussian quadrature
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
).
Then there exists (a, b) such that
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
) =
f
(2n+2)
()
(2n + 2)!
_
b
a
n

j=0
(x x
j
)
2
w(x)dx.
Proof. We use the characterization of the Gaussian quadrature as the integral of a
Hermite interpolant. We recall that the error formula for the Hermite interpolation is
given by (??),
f(x) p
2n+1
(x) =
f
(2n+2)
()
(2n + 2)!
n

j=0
(x x
j
)
2
, (a, b).
Hence according to (6.36) we have
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
) =
_
b
a
f(x)w(x)dx
_
b
a
p
2n+1
w(x)dx
=
_
b
a
w(x)
f
(2n+2)
()
(2n + 2)!
n

j=0
(x x
j
)
2
dx.
The integral mean value theorem then implies that there exists (a, b) such that
_
b
a
f(x)w(x)dx
n

i=0
A
i
f(x
i
) =
f
(2n+2)
()
(2n + 2)!
_
b
a
n

j=0
(x x
j
)
2
(x)w(x)dx.

We conclude this section with a convergence theorem that states that for continuous
functions, the Gaussian quadrature converges to the exact value of the integral as the
number of quadrature points tends to innity. This theorem is not of a great practical
value because it does not provide an estimate on the rate of convergence. A proof of
the theorem that is based on the Weierstrass approximation theorem can be found in,
e.g., in [?].
22
D. Levy 6.8 Romberg Integration
Theorem 6.13 We let w(x) be a weight function and assuming that f(x) is a con-
tinuous function on [a, b]. For each n N we let {x
n
i
}
n
i=0
be the n + 1 roots of the
polynomial of degree n + 1 that is w-orthogonal to
n
, and consider the corresponding
Gaussian quadrature:
_
b
a
f(x)w(x)dx
n

i=0
A
n
i
f(x
n
i
). (6.39)
Then the right-hand-side of (6.39) converges to the left-hand-side as n .
6.8 Romberg Integration
We have introduced Richardsons extrapolation in Section ?? in the context of numerical
dierentiation. We can use a similar principle with numerical integration.
We will demonstrate this principle with a particular example. Let I denote the exact
integral that we would like to approximate, i.e.,
I =
_
b
a
f(x)dx.
Lets assume that this integral is approximated with a composite trapezoidal rule on a
uniform grid with mesh spacing h (6.13),
T(h) = h
n

i=0

f(a + ih).
We know that the composite trapezoidal rule is second-order accurate (see (6.14)).
A more detailed study of the quadrature error reveals that the dierence between I and
T(h) can be written as
I = T(h) + c
1
h
2
+ c
2
h
4
+ . . . + c
k
h
k
+ O(h
2k+2
).
The exact values of the coecients, c
k
, are of no interest to us as long as they do not
depend on h (which is indeed the case). We can now write a similar quadrature that is
based on half the number of points, i.e., T(2h). Hence
I = T(2h) + c
1
(2h)
2
+ c
2
(2h)
4
+ . . .
This enables us to eliminate the h
2
error term:
I =
4T(h) T(2h)
3
+ c
2
h
4
+ . . .
23
6.8 Romberg Integration D. Levy
Therefore
4T(h) T(2h)
3
=
1
3
_
4h
_
1
2
f
0
+ f
1
+ . . . + f
n1
+
1
2
f
n
_
2h
_
1
2
f
0
+ f
2
+ . . . + f
n2
+
1
2
f
n
__
=
h
3
(f
0
+ 4f
1
+ 2f
2
+ . . . + 2f
n2
+ 4f
n1
+ f
n
) = S(n).
Here, S(n) denotes the composite Simpsons rule with n subintervals. The procedure of
increasing the accuracy of the quadrature by eliminating the leading error term is known
as Romberg integration. In some places, Romberg integration is used to describe the
specic case of turning the composite trapezoidal rule into Simpsons rule (and so on).
The quadrature that is obtained from Simpsons rule by eliminating the leading error
term is known as the super Simpson rule.
24

You might also like