You are on page 1of 54

MA 214: Introduction to numerical analysis

Lecture 24

Shripad M. Garge.
IIT Bombay

( shripad@math.iitb.ac.in )

2021-2022

1/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Composite numerical integration

The Newton-Cotes formulae are generally unsuitable for use over


large intervals.

High-degree formulae would be required, and the values of the


coefficients in these formulas are difficult to obtain.

Also, the Newton-Cotes formulae are based on interpolatory


polynomials that use equally-spaced nodes, a procedure that is
inaccurate over large intervals because of the oscillatory nature of
high-degree polynomials.

We now discuss a piecewise approach to numerical integration that


uses the low-order Newton-Cotes formulae.

2/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
An example
ż4
We have e x dx “ e 4 ´ e 0 “ 53.5981500331.
0
1
Using Simpson’s -rule on r0, 4s:
3
ż4
2
e x dx « pe 0 ` 4e 2 ` e 4 q “ 56.7695829526.
0 3
The error is then ´3.17143291943 which is rather unacceptable.
1
Using Simpson’s -rule to r0, 2s and r2, 4s:
3
ż4 ż2 ż4
x x
e dx “ e dx ` e x dx
0 0 2
1 0 1
“ pe ` 4e ` e 2 q ` pe 2 ` 4e 3 ` e 4 q
3 3
“ 53.8638457459
3/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
The example, continued
1
Now, we apply Simpson’s -rule to the subintervals of length 1:
3
ż4 ż1 ż2 ż3 ż4
e x dx “ x
e dx ` x
e dx ` x
e dx ` e x dx
0 0 1 2 3
1 0 1
“ pe ` 4e 1{2 ` eq ` pe ` 4e 3{2 ` e 2 q
6 6
1 2 1
` pe ` 4e 5{2 ` e 3 q ` pe 3 ` 4e 7{2 ` e 4 q
6 6
“ 53.616220796

1
The errors naturally decrease when we apply the Simpson’s -rule
3
to smaller and smaller subintervals.

To generalize this procedure, we choose an even integer n,


subdivide the interval ra, bs into n subintervals, and apply
Simpson’s rule on each consecutive pair of subintervals.
4/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
General case

5/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
General case

In the general case, we have h “ pb ´ aq{n and xj “ a ` jh for


each j “ 0, . . . , n. The formula then reads
żb n{2
ÿ ż x2j
f pxqdx “ f pxqdx
a j“1 x2j´2
n{2
‰ h5 p4q
" *
ÿ h“
“ f px2j´2 q ` 4f px2j´1 q ` f px2j q ´ f pξj q
j“1
3 90

for some ξj between x2j´2 and x2j .

We simplify the above formula by observing the coefficients of


terms which appear in more than one brackets and using some
theorems to get a single µ in the error.

6/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
General case

Let f be 4-times continuously differentiable on ra, bs, let n be an


even integer, h “ pb ´ aq{n and xj “ a ` jh for j “ 0, 1, . . . , n.
There exists a µ P pa, bq for which the Composite Simpson’s rule
for n subintervals can be written with its error term as
» fi
żb n{2´1 n{2
h– ÿ ÿ
f pxqdx “ f paq ` 2 f px2j ` 4 f px2j´1 q ` f pbqfl
a 3 j“1 j“1
b ´ a 4 p4q
´ h f pµq
180
Notice that the above error term is of the order of h4 , whereas it
was of the order of h5 for the standard Simpson’s rule.

However, for standard Simpson’s rule we have h fixed at


h “ pb ´ aq{2 and for the composite rule we have a flexibility using
n which permits us to reduce the value of h considerably.
7/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Composite Trapezoidal rule

Let f be twice differentiable on ra, bs.

Let h “ pb ´ aq{n and xj “ a ` jh, for each j “ 0, 1, . . . , n.

There exists a µ P pa, bq for which the Composite Trapezoidal rule


for n subintervals can be written with its error term as
« ff
żb n´1
h ÿ b´a 2 2
f pxqdx “ f paq ` 2 f pxj q ` f pbq ´ h f pµq.
a 2 j“1
12

8/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Composite Trapezoidal rule

9/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Composite midpoint rule

Let f be twice differentiable on ra, bs.

Let n be even, define h “ pb ´ aq{pn ` 2q and xj “ a ` pj ` 1qh for


each j “ ´1, 0, 1, . . . , n ` 1.

There exists a µ P pa, bq for which the Composite Midpoint rule for
n ` 2 subintervals can be written with its error term as
żb n{2
ÿ b´a 2 2
f pxqdx “ 2h f px2j ` h f pµq.
a j“0
6

10/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Composite midpoint rule

11/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
An example
żπ
Let us compute the integral sin xdx using the above two
0
methods such that the error is less than 0.00002.

The error in the composite trapezoidal rule is given by


ˇ 2
ˇ πh 2 ˇ πh2
ˇ
ˇ 12 f pµqˇ “ 12 | sin µ|.
ˇ ˇ

The condition on the error gives

πh2 πh2
| sin µ| ď ă 0.00002 so h ă 0.00874038744.
12 12
Since h “ π{n, this gives

n ě 360.

12/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
The example, continued

We now apply the composite Simpson’s rule. The error in this rule
is given by ˇ 4
ˇ πh p4q ˇ πh4
ˇ
ˇ 180 f pµqˇ “ 180 | sin µ|
ˇ ˇ

To ensure required accuracy we need

πh4 πh4
| sin µ| ď ă 0.00002 so h ă 0.18398743167.
180 180
Since h “ π{n, this gives
n ě 18.
The composite Simpson’s rule gives the required accuracy for a
smaller number of subintervals.

13/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
Comparison of the composite rules

The composite Simpson’s rule uses the same number of


computations as the composite trapezoidal rule, yet the result is
better.
The composite Simpson’s rule gives the approximation:
« ˙ff
8 ˆ ˙ 9 ˆ
π ÿ jπ ÿ p2j ´ 1qπ
2 sin `4 sin “ 2.0000104.
54 j“1
9 j“1
18

The composite trapezoidal rule with the same number of steps


n “ 18 gives
« ff
17 ˆ ˙
π ÿ jπ
2 sin ` sin 0 ` sin π “ 1.9949205.
36 j“1
18

The accuracy in the latter computation is about 5 ˆ 10´3 .

14/54
shripad@math.iitb.ac.in MA214 (2021-2022) L24
MA 214: Introduction to numerical analysis
Lecture 25

Shripad M. Garge.
IIT Bombay

( shripad@math.iitb.ac.in )

2021-2022

15/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Round-off error

We saw an example in our last lecture where we computed the


interval width, h, based on the required accuracy.

For the required accuracy, the composite Trapezoidal rule needed


360 intervals whereas the composite Simpson’s rule needed only 18
intervals.

In addition to the fact that less computation is needed for the


Simpson’s technique, you might suspect that because of fewer
computations this method would also involve less round-off error.

However, an important property shared by all the composite


integration techniques is the stability with respect to the round-off
error.

That is, the round-off error does not depend on the number of
calculations performed.
16/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Stability of composite integration rules

Let us assume that we apply the Composite Simpson’s rule with n


subintervals to a function f on ra, bs and determine the maximum
bound for the round-off error.

Assume that f pxi q is approximated by f˜pxi q and that

f pxi q “ f˜pxi q ` ei for each i “ 0, 1, . . . , n.

Then the accumulated error, ephq, in the Composite Simpson’s


rule is
ˇ » fiˇ
ˇ pn{2q´1 n{2 ˇ
ˇh ÿ ÿ ˇ
ephq “ ˇ
ˇ –e0 ` 2 e2j ` 4 e2j´1 ` en ˇˇ
fl
ˇ3 j“1 j“1 ˇ
» fi
pn{2q´1 n{2
h– ÿ ÿ
ď |e0 | ` 2 |e2j | ` 4 |e2j´1 | ` |en |fl .
3 j“1 j“1
17/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Stability of composite integration rules

If the round-off errors are uniformly bounded by , then


h” ´n ¯ ´n¯ ı h
ephq ď `2 ´1 `4  `  “ 3n “ hn
3 2 2 3
Hence
ephq ď pb ´ aq
a bound independent of h (and n).

This means that, even though we may need to divide an interval


into more parts to ensure accuracy, the increased computation
does not increase the round-off error.

This result implies that the procedure is stable as h Ñ 0.

Recall that this was not true of the numerical differentiation


procedures.
18/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
A problem with composite methods

The composite formulae are very effective in most situations, but


they suffer occasionally because they require the use of
equally-spaced nodes.

This is inappropriate when integrating a function on an interval


that contains regions with large functional variation and regions
with small functional variation.

Such functions are commonplace, in mechanical engineering some


of them describe certain features of spring and shock absorber
systems, and in electrical engineering they are common solutions to
elementary circuit problems, to mention a few examples.

One such function is y pxq “ e ´3x sin 4x whose graph is shown in


the next slide.

19/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
A problem with composite methods

20/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
A problem with composite methods
ż4
Let us assume that we need to compute y pxqdx.
0

As per the graph, the integral on r3, 4s seems to be very close to 0,


and that on r2, 3s is also not large.

However, on r0, 2s there is significant variation of the function.

Beyond guessing that it would be positive, it is not at all clear


what the integral is on this interval.

This is an example of a situation where composite integration


would be inappropriate.

A very low order method could be used on r2, 4s, but a


higher-order method would be necessary on r0, 2s.

21/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

Question
How can we determine what technique should be applied on
various portions of the interval of integration, and how accurate
can we expect the final approximation to be?

If the approximation error for an integral on a given interval is to


be evenly distributed, a smaller step size is needed for the
large-variation regions than for those with less variation.

An efficient technique for this type of problem should predict the


amount of functional variation and adapt the step size as necessary.

These methods are called adaptive quadrature methods.

22/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

We now study one such method.

The method is based on the Composite Simpson’s rule, but the


technique is easily modified to use other composite procedures.
żb
Suppose that we want to approximate f pxqdx to within a
a
specified tolerance  ą 0.

The first step is to apply Simpson’s rule with step size


h “ pb ´ aq{2. This gives, for some ξ P pa, bq:
żb
h5 p4q
f pxqdx “ Spa, bq ´ f pξq
a 90

where
h
Spa, bq “ rf paq ` 4f pa ` hq ` f pbqs .
3
23/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

Next, we apply the Composite Simpson’s rule with n “ 4 and step


pb ´ aq h
size “ , giving
4 2
żb
1 h5
ˆ ˙ ˆ ˙ ˆ ˙
a`b a`b ˜
f pxqdx “ S a, `S ,b ´ f p4q pξq
a 2 2 16 90

for some ξ˜ P pa, bq.


˜ and the success of the
We now assume that f p4q pξq « f p4q pξq,
technique depends on the accuracy of this assumption.

If it is accurate, then we equate the above two integrals with this


approximation.

24/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

h5 p4q 1 h5
ˆ ˙ ˆ ˙ ˆ ˙
a`b a`b
Spa, bq´ f pξq « S a, `S ,b ´ f p4q pξq
90 2 2 16 90
or
h5 p4q
„ ˆ ˙ ˆ ˙
16 a`b a`b
f pξq « Spa, bq ´ S a, ´S ,b .
90 15 2 2

We now put this estimate in the formula given by Simpson’s rule


for n “ 4
ˇż b ˆ ˙ ˆ ˙ˇ ˆ 5˙
ˇ f pxqdx ´ S a, a ` b ´ S a ` b , b ˇ « 1 h f p4q pξq
ˇ ˇ
ˇ
a 2 2 ˇ 16 90
ˇ ˆ ˙ ˆ ˙ˇ
1 ˇˇ a`b a`b ˇ
« Spa, bq ´ S a, ´S , b ˇˇ .
15 ˇ 2 2
25/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method
żb
` a`b
˘ ` a`b ˘
This implies that S a, 2 `S 2 , b approximates f pxqdx
a
about 15-times better than it agrees with Spa, bq. Thus, if
ˇ ˆ ˙ ˆ ˙ˇ
ˇSpa, bq ´ S a, a ` b ´ S a ` b , b ˇ ă 15
ˇ ˇ
ˇ 2 2 ˇ

we expect
ˇż b ˆ ˙ ˆ ˙ˇ
ˇ f pxqdx ´ S a, a ` b ´ S a ` b , b ˇ ă 
ˇ ˇ
ˇ
a 2 2 ˇ
` ˘ ` ˘
and S a, a`b
2 ` S a`b
2 , b ż is assumed to be a sufficiently
b
accurate approximation to f pxqdx.
a

26/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method
ˇ ` ˘ ` ˘ˇ
When ˇSpa, bq ´ S a, a`b2 ´ S a`b
2 , b ­ă 15, we apply the
ˇ
Simpson’s rule individually to each subinterval, ra, pa ` bq{2s and
rpa ` bq{2, bs.

Then we use the error estimation procedure to determine if the


approximation to the integral on each subinterval is within a
tolerance of {2. If so, we sum the approximations to produce an
żb
approximation to f pxqdx within the tolerance .
a

If the approximation on one of the subintervals fails to be within


the tolerance {2, then that subinterval is subdivided, and the
procedure is applied to the two subintervals to determine if the
approximation on each subinterval is accurate to within {4.

This halving procedure is continued until each portion is within the


required tolerance.
27/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

Problems can be constructed for which this tolerance will never be


met.

But the technique is usually successful because each subdivision


typically increases the accuracy of the approximation by a factor of
16 while requiring an increased accuracy factor of only 2.

Let us consider the function f pxq “ p100{x 2 q sinp10{xq, x P r1, 3s.

Using the Adaptive


ż3 quadrature method with tolerance 10´4 to
approximate f pxqdx produces ´1.426014, a result that is
1
accurate to within 1.1 ˆ 10´5 .

The approximation required that Simpson’s rule with n “ 4 be


performed on the 23 subintervals whose endpoints are shown in the
next slide.
28/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
Adaptive quadrature method

29/54
shripad@math.iitb.ac.in MA214 (2021-2022) L25
MA 214: Introduction to numerical analysis
Lecture 26

Shripad M. Garge.
IIT Bombay

( shripad@math.iitb.ac.in )

2021-2022

30/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

All the Newton-Cotes formulae use values of the function at


equally-spaced points.

This restriction is convenient when the formulae are combined to


form the composite rules, but it can significantly decrease the
accuracy of the approximation.

The Trapezoidal rule approximates the integral of the function by


integrating the linear function that joins the endpoints of the graph
of the function. But this is often not the best approximation.

Consider, for example, the Trapezoidal rule applied to determine


the integrals of the functions whose graphs are shown in the next
slides. We also show some lines in each case which are likely to
give much better approximations.

31/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

32/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

33/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

34/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

Gaußian quadrature chooses the points for evaluation in an


optimal, rather than equally-spaced, way.

The nodes x1 , x2 , . . . , xn in the interval ra, bs and coefficients


c1 , c2 , . . . , cn are chosen to minimize the expected error obtained in
the approximation
żb n
ÿ
f pxqdx « ci f pxi q.
a i“1

To measure this accuracy, we assume that the best choice of these


values produces the exact result for the largest class of polynomials,
that is, the choice that gives the greatest degree of precision.

The coefficients c1 , c2 , . . . , cn in the approximation formula are


arbitrary, and the nodes x1 , x2 , . . . , xn are restricted only by the
fact that they must lie in ra, bs.
35/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature

This gives us 2n parameters to choose.

If the coefficients of a polynomial are considered parameters, the


class of polynomials of degree at most 2n ´ 1 also contains 2n
parameters.

This, then, is the largest class of polynomials for which it is


reasonable to expect a formula to be exact.

With the proper choice of the values and constants, exactness on


this set can be obtained.

We illustrate this method by means of an example where n “ 2


and the interval is r´1, 1s.

We will then discuss the more general situation.

36/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature, n “ 2

We want to determine c1 , c2 , x1 , and x2 so that the integration


formula ż1
f pxqdx “ c1 f px1 q ` c2 f px2 q
´1

gives the exact result whenever f pxq is a polynomial of degree


2p2q ´ 1 “ 3 or less, that is, when

f pxq “ a0 ` a1 x ` a2 x 2 ` a3 x 3

for some a0 , a1 , a2 , a3 .

Clearly, it is enough to work with special cases of polynomials,


namely, f pxq “ 1, x, x 2 or x 3 . The first equation is
ż1
c1 ` c2 “ 1dx “ 2.
´1

37/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Gaußian quadrature, n “ 2

Similarly, we have
ża ż1
2
c1 x1 ` c2 x2 “ xdx “ 0, c1 x12 ` c2 x22 “ x 2 dx “
´1 ´1 3
ż1
and c1 x13 ` c2 x23 “ x 3 dx “ 0. We can solve these equations to
´1 ? ?
´ 3 3
obtain c1 “ 1 “ c2 , x1 “ and x2 “ .
3 3
The approximation formula then reads
ż1 ˆ ? ˙ ˆ? ˙
´ 3 3
f pxqdx « f `f
´1 3 3

which is correct for polynomials of degree ď 3.

38/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Legendre polynomials

There is another method to compute the nodes and coefficients.

There exist polynomials tPn pxqu for n “ 0, 1, . . . satisfying:


(1) Pn pxq is a monic polynomial of degree n,
ż1
(2) PpxqPn pX q “ 0 whenever the degree of Ppxq is less than n.
´1

These are called Legendre polynomials.

The first few Legendre polynomials are


1
P0 pxq “ 1, P1 pxq “ x, P2 pxq “ x 2 ´ ,
3
3 6 3
P3 pxq “ x 3 ´ x, and P4 pxq “ x 4 ´ x 2 ` .
5 7 35

39/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Legendre polynomials

The roots of these polynomials are distinct, lie in the interval


p´1, 1q, have a symmetry with respect to the origin, and, most
importantly, are the correct choice for determining xi and ci .

Theorem
Let x1 , x2 , . . . , xn be the roots of Pn pxq and define for each
i “ 1, 2, . . . , n,
ż1 ź n
x ´ xj
ci “ dx.
´1 xi ´ xj
j “1
j ‰i
If Ppxq is a polynomial of degree ă 2n then
ż1 n
ÿ
Ppxqdx “ ci Ppxi q.
´1 i“1
40/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
Legendre polynomials

The nodes xi and the coefficients ci can be computed from the


definition of Legendre polynomials.

But they have also been tabulated extensively. We can just use
them off the shelf.

For instance, for P3 the nodes and the coefficients are as follows:

xi ci
0.7745966692 0.5555555556
0.0000000000 0.8888888889
-0.7745966692 0.5555555556

ż1
Let us use these values to compute e x cos xdx.
´1

41/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
An example

We have
ż1
e x cos xdx « 0.5555555556 e 0.7745966692 cosp0.7745966692q
´1
` 0.8888888889
` 0.5555555556 e ´0.7745966692 cosp´0.7745966692q
“ 1.9333904.

The actual answer is


ż1
e x cos xdx “ 1.9334214
´1

so the absolute error is less than 3.2 ˆ 10´5 .

42/54
shripad@math.iitb.ac.in MA214 (2021-2022) L26
MA 214: Introduction to numerical analysis
Lecture 27

Shripad M. Garge.
IIT Bombay

( shripad@math.iitb.ac.in )

2021-2022

43/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
What next in numerical integration?

We have learnt some numerical methods to compute definite


integrals.

We then learnt the amazing method of adaptive qudratures.

The icing on the cake was the Gaußian quadrature method.

We now want to venture outside the 1-dimensional realm.

Yup! That’s right. We are going to do multiple integrals using our


numerical techniques.

44/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple integrals

We start with x
f px, y qdA
R

where
R “ tpx, y q : a ď x ď b, c ď y ď du,
is a rectangular region in the plane.

We have
x ż b ˆż d ˙
f px, y qdA “ f px, y qdy dx.
R a c

We start with the composite trapezoidal rule.

45/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple trapezoidal rule

If we let k “ pd ´ cq{2 and h “ pb ´ aq{2 then the composite


trapezoidal rule gives
żd „ ˆ ˙
k c `d
f px, y qdy « f px, cq ` f px, dq ` 2f x, .
c 2 2

We further get
żbżd żbˆ ˙„ ˆ ˙
d ´c c `d
f px, y qdydx « f px, cq ` f px, dq ` 2f x,
a c a 4 2
„ ˆ ˙
pb ´ aqpd ´ cq a`b c `d
“ f pa, cq ` f pa, dq ` f pb, cq ` f pb, dq ` 4f ,
16 2 2
" ˆ ˙ ˆ ˙ ˆ ˙ ˆ ˙*
a`b a`b c `d c `d
`2 f ,c ` f , d ` f a, ` f b, .
2 2 2 2

46/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple trapezoidal rule

The procedure is quite straightforward.

But the number of function evaluations grows with the square of


the number required for a single integral.

In a practical situation, we would not expect to use a method as


elementary as the composite trapezoidal
ˆ ˙rule. Instead, we will
1
employ the composite Simpson’s -rd rule to illustrate the
3
general approximation technique, although any other composite
formula could be used in its place.

To apply the composite Simpson’s rule, we divide the region R by


partitioning both ra, bs and rc, ds into an even number of
subintervals.

47/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple Simpson’s rule

To simplify the notation, we choose even integers n and m, and


partition ra, bs and rc, ds with the evenly spaced mesh points
x0 , x1 , . . . , xn and y0 , y1 , . . . , ym , respectively.

These subdivisions determine step sizes h “ pb ´ aq{n and


k “ pd ´ cq{m.

Writing the double integral as the iterated integral


x ż b ˆż d ˙
f px, y qdA “ f px, y qdy dx
R a c

żd
we first approximate f px, y qdy , treating x as constant, using
c
the composite Simpson’s rule.

48/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple Simpson’s rule
Let yj “ c ` jk, for each j “ 0, 1, . . . , m. Then
»
żd pm{2q´1 m{2
k– ÿ ÿ
f px, y qdy “ f px, y0 q ` 2 f px, y2j q ` 4 f px, y2j´1 q
c 3 j“1 j“1

pd ´ cqk 4 B 4 f

`f px, ym q ´ px, µq
180 By 4

for some µ P pc, dq.


żb
The final double integral is a sum of f px, yj q.
a

With xi “ a ` ih, for each i “ 0, 1, . . . , n we apply the composite


żb
Simpson’s rule to each f px, yj q for j “ 0, 1, . . . , m.
a

49/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Multiple Simpson’s rule
The final answer then is
x
#« pn{2q´1 n{2
ff
hk ÿ ÿ
f px, y qdA « f px0 , y0 q ` 2 f px2i , y0 q ` 4 f px2i´1 , y0 q ` f pxn , y0 q
9 i“1 i“1
R
«pm{2q´1 pm{2q´1 n{2
ÿ ÿ pn{2q´1
ÿ pm{2q´1
ÿ ÿ
`2 f px0 , y2j q ` 2 f px2i , y2j q ` 4 f px2i´1 , y2j q
j“1 j“1 i“1 j“1 i“1

pm{2q´1
ff «m{2 m{2
ÿ ÿ ÿ pn{2q´1
ÿ
` f pxn , y2j q ` 4 f px0 , y2j´1 q ` 2 f px2i , y2j´1 q
j“1 j“1 j“1 i“1

m{2 n{2 m{2


ff
ÿÿ ÿ
`4 f px2i´1 , y2j´1 q ` f pxn , y2j´1 q
j“1 i“1 j“1
« pn{2q´1 n{2
ff+
ÿ ÿ
` f px0 , ym q ` 2 f px2i , ym q ` 4 f px2i´1 , ym q ` f pxn , ym q
i“1 i“1

Let us do an example.
50/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
An example

Use composite Simpson’s rule with n “ 4 and m “ 2 to


approximate ż 2.0 ż 1.5
lnpx ` 2y qdydx
1.4 1.0

The step sizes for this application are h “ p2.0 ´ 1.4q{4 “ 0.15 and
k “ p1.5 ´ 1.0q{2 “ 0.25.

The region of integration R is shown in the next slide, together


with the nodes pxi , yj q, where i “ 0, 1, 2, 3, 4 and j “ 0, 1, 2.

It also shows the coefficients wi,j of f pxi , yj q “ lnpxi ` 2yj q in the


sum that gives the approximation to the integral.

51/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
The example, continued

52/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
The example, continued

The final approximation then is


4 2
p0.15qp0.25q ÿ ÿ
wi,j lnpxi ` 2yj q “ 0.4295524387.
9 i“0 j“0

The actual integral is


ż 2.0 ż 1.5
lnpx ` 2y qdydx “ 0.4295545265
1.4 1.0

so the error is 2.1 ˆ 10´6 .

53/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27
Error formula
x
The error in the formula for f px, y qdA is
R

pd ´ cqpb ´ aq 4 B 4 f 4
„ 
4 B f
E “´ h pη̄, µ̄q ` k pη̂, µ̂q
180 Bx 4 By 4

for some pη̄, µ̄q, pη̂, µ̂q P R.

The error predicted by this formula in the above example is


„ 
p0.5qp0.6q 6 96
|E | ď p0.15q4 max ` p0.25q 4
max
180 R px ` 2y q4 R px ` 2y q4

ď 4.72 ˆ 10´6

54/54
shripad@math.iitb.ac.in MA214 (2021-2022) L27

You might also like