62
CHAPTER
2.
NUMERICAL
INTEGRATION.
BONDS.
computed
when evaluating
tin,
since f(a2n,2i) = f(an,i), for i = 0 : n.
(Note
that
additional
storage costs are nonetheless incurred.)
Similar savings occur for Simpson's rule. However,
there
are
no
such
savings
to
be
obtained
for
the
Midpoint
rule.
2.5.2
A
concrete
example
We
present
an
example
of
how
to
compute
an
approximate
value
of
a given
integral
to
a prescribed tolerance. We
want
to
find
an
approximate
value for
I =
12
e-
X
'
dx
which is
within
0.5
10-
7
of
I.
Note
that
an
exact
value
of
I
cannot
be
computed,
since J
e-
x2
dx
does
not
have a closed formula.
We implement
the
algorithm
from Table 2.4 for each
of
the
numerical
integration
methods
to
compare
their
convergence properties. We choose
tol = 0.5
10-
7
.
For
an
initial
partition
of
the
interval
[0,
2]
into
n = 4
intervals,
the
following
approximate
values
of
I
are
found using
the
Midpoint,
Trapezoidal,
and
Simpson's rules, respectively:
If1
= 0.88278895;
II
= 0.88061863;
If
= 0.88206551.
Then,
we double
the
number
of
partition
intervals
and
compute
the
nu-
merical approximations corresponding
to
each
method.
We keep
doubling
the
number
of
partition
intervals
until
the
stopping
criterion (2.34) is satisfied.
The
results are recorded below:
No. Intervals Midpoint
Rule
Trapezoidal Rule Simpson's
Rule
4
0.88278895
0.88061863
0.88206551
8
0.88226870
0.88170379
0.88208040
16
0.88212887
0.88198624
0.88208133
32 0.88209330
0.88205756 0.88208139
64
0.88208437
0.88207543
128
0.88208214
0.88207990
256
0.88208158
0.88208102
512
0.88208144
0.88208130
We
note
that
convergence is achieved for 512 intervals for
the
Midpoint
and
Trapezoidal rules,
and
for 32 intervals for Simpson's rule.
To
better
understand
the
convergence
patterns
of
the
quadratically
con-
vergent Midpoint
and
Trapezoidal rules,
and
of
the
fourth
order
convergent
2.5.
CONVERGENCE
OF
NUMERICAL
INTEGRATION
METHODS
63
Simpson's rule, we look
at
the
approximation
errors
of
each algorithm. Since
an
exact
value
of
I
cannot
be
computed,
we
assume
that
the
approximate
value
obtained
using Simpson's rule
with
100,000 intervals
to
be
the
exact
value of
I,
i.e.,
I = 0.88208139076242.
The
approximation
errors
II
-I~I,
II
-I~I,
and
II
-1%1
for
the
Midpoint,
Trapezoidal,
and
Simpson's rules, respectively,
are
presented
below:
No. Intervals
Midpoint
Rule Trapezoidal
Rule
Simpson's Rule
n
II
-
1%11
II
-
I~
I
II
-
1%1
4
0.00070756 0.00146276
0.00001588
8 0.00018731
0.00037760 0.00000099
16
0.00004748
0.00009515 0.00000006
32
0.00001191
0.00002383
3.88/10
v
64 0.00000298
0.00000596
128
0.00000075 0.00000149
256
0.00000019
0.00000037
512
0.00000005
0.00000009
Note
that
the
approximation
errors for
the
Midpoint
rule are
about
half
of
the
approximation
errors
for
the
Trapezoidal rule.
While
this
is
not
always
the
case,
it
is nonetheless consistent
with
the
theoretical
upper
bounds
(2.22)
and
(2.23) from
Theorem
2.2, i.e.,
II
-
I~I
< h
4
2
(b
-
a)
max
1fl/(x)l;
2
a~x~b
II
I~I
<
h12
(b
-
a)
max
Ifl/(x)l.
2
a~x~b
As
the
number
of
intervals doubles,
the
approximation
error decreases
by
a factor
of
4 for
the
Midpoint
and
Trapezoidal rules,
and
by
a factor
of
16 for
Simpson's rule.
This
is consistent
with
the
results (2.24), (2.25)
and
(2.27)
from
Theorem
2.2, i.e.,
As
in
the
example
above,
in
most
cases,
Simpson's
rule converges faster
than
the
Trapezoidal
and
Midpoint
rules. Nonetheless, from a
computational
point
of
view,
it
is
more
expensive
to
compute
the
Simpson's rule approxima-
tion
1%,
which requires
evaluating
the
function f (x)
at
2n + 1 nodes,
that
to
compute
the
Trapezoidal
rule
approximation
I~,
which requires evaluating