Вы находитесь на странице: 1из 93

Numerical Differentiation & Integration

Composite Numerical Integration I


Numerical Analysis (9th Edition)
R L Burden & J D Faires
Beamer Presentation Slides
prepared by
John Carroll
Dublin City University

c 2011 Brooks/Cole, Cengage Learning


Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

2 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

2 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

2 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

2 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

3 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Application of Simpsons Rule
Use Simpsons rule to approximate
Z

Numerical Analysis (Chapter 4)

ex dx

Composite Numerical Integration I

R L Burden & J D Faires

4 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Application of Simpsons Rule
Use Simpsons rule to approximate
Z

ex dx

and compare this to the results obtained by adding the Simpsons rule
approximations for
Z

Numerical Analysis (Chapter 4)

2
0

ex dx

and

ex dx

Composite Numerical Integration I

R L Burden & J D Faires

4 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Application of Simpsons Rule
Use Simpsons rule to approximate
Z

ex dx

and compare this to the results obtained by adding the Simpsons rule
approximations for
Z

ex dx

and

ex dx

and adding those for


Z

e dx,

Numerical Analysis (Chapter 4)

e dx,
1

e dx

Composite Numerical Integration I

and

ex dx

R L Burden & J D Faires

4 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example

Solution (1/3)
Simpsons rule on [0, 4] uses h = 2

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

5 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example

Solution (1/3)
Simpsons rule on [0, 4] uses h = 2 and gives
Z

ex dx

Numerical Analysis (Chapter 4)

2 0
(e + 4e2 + e4 ) = 56.76958.
3

Composite Numerical Integration I

R L Burden & J D Faires

5 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example

Solution (1/3)
Simpsons rule on [0, 4] uses h = 2 and gives
Z

ex dx

2 0
(e + 4e2 + e4 ) = 56.76958.
3

The exact answer in this case is e4 e0 = 53.59815, and the error


3.17143 is far larger than we would normally accept.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

5 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (2/3)
Applying Simpsons rule on each of the intervals [0, 2] and [2, 4] uses
h=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

6 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (2/3)
Applying Simpsons rule on each of the intervals [0, 2] and [2, 4] uses
h = 1 and gives
Z

e dx

Numerical Analysis (Chapter 4)

e dx +
0

ex dx

Composite Numerical Integration I

R L Burden & J D Faires

6 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (2/3)
Applying Simpsons rule on each of the intervals [0, 2] and [2, 4] uses
h = 1 and gives
Z

e dx

Numerical Analysis (Chapter 4)

e dx +
0

ex dx

 1

1 0
e + 4e + e2 +
e2 + 4e3 + e4
3
3

Composite Numerical Integration I

R L Burden & J D Faires

6 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (2/3)
Applying Simpsons rule on each of the intervals [0, 2] and [2, 4] uses
h = 1 and gives
Z

e dx

Numerical Analysis (Chapter 4)

e dx +
0

ex dx

 1

1 0
e + 4e + e2 +
e2 + 4e3 + e4
3
3

1 0
e + 4e + 2e2 + 4e3 + e4
3

Composite Numerical Integration I

R L Burden & J D Faires

6 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (2/3)
Applying Simpsons rule on each of the intervals [0, 2] and [2, 4] uses
h = 1 and gives
Z

e dx

e dx +
0

ex dx

 1

1 0
e + 4e + e2 +
e2 + 4e3 + e4
3
3

1 0
=
e + 4e + 2e2 + 4e3 + e4
3
= 53.86385

The error has been reduced to 0.26570.


Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

6 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (3/3)
For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpsons rule
four times with h = 12

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

7 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (3/3)
For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpsons rule
four times with h = 12 giving
Z

e dx =
0

Numerical Analysis (Chapter 4)

e dx +

e dx +

e dx +
2

Composite Numerical Integration I

ex dx

R L Burden & J D Faires

7 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (3/3)
For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpsons rule
four times with h = 12 giving
Z

e dx =
0

e dx +

e dx +

e dx +
2

ex dx

 1

1
e0 + 4e1/2 + e +
e + 4e3/2 + e2
6
6
 1

1 2
+
e + 4e5/2 + e3 +
e3 + 4e7/2 + e4
6
6

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

7 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (3/3)
For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpsons rule
four times with h = 12 giving
Z

e dx =
0

e dx +

e dx +

e dx +
2

ex dx

 1

1
e0 + 4e1/2 + e +
e + 4e3/2 + e2
6
6
 1

1 2
+
e + 4e5/2 + e3 +
e3 + 4e7/2 + e4
6
6

1 0
1/2
3/2
e + 4e + 2e + 4e + 2e2 + 4e5/2 + 2e3 + 4e7/2 + e4
6

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

7 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Motivating Example


Solution (3/3)
For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpsons rule
four times with h = 12 giving
Z

e dx =
0

e dx +

e dx +

e dx +
2

ex dx

 1

1
e0 + 4e1/2 + e +
e + 4e3/2 + e2
6
6
 1

1 2
+
e + 4e5/2 + e3 +
e3 + 4e7/2 + e4
6
6

1 0
1/2
3/2
=
e + 4e + 2e + 4e + 2e2 + 4e5/2 + 2e3 + 4e7/2 + e4
6
= 53.61622.

The error for this approximation has been reduced to 0.01807.


Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

7 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

8 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


To generalize this procedure for an arbitrary integral

f (x) dx,

choose an even integer n. Subdivide the interval [a, b] into n


subintervals, and apply Simpsons rule on each consecutive pair of
subintervals.
y
y 5 f (x)

a 5 x0
Numerical Analysis (Chapter 4)

x2

x2j22 x2j21

x2j

Composite Numerical Integration I

b 5 xn

R L Burden & J D Faires

9 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule

Construct the Formula & Error Term


With h = (b a)/n and xj = a + jh, for each j = 0, 1, . . . , n,

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

10 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule

Construct the Formula & Error Term


With h = (b a)/n and xj = a + jh, for each j = 0, 1, . . . , n, we have
Z

f (x) dx =

n/2 Z
X
j=1

x2j

f (x) dx
x2j2

n/2 
X
h
j=1


h5 (4)
[f (x2j2 ) + 4f (x2j1 ) + f (x2j )]
f (j )
3
90

for some j with x2j2 < j < x2j , provided that f C 4 [a, b].

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

10 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Z

f (x) dx =

n/2 
X
h
j=1


h5 (4)
[f (x2j2 ) + 4f (x2j1 ) + f (x2j )]
f (j )
3
90

Construct the Formula & Error Term (Contd)


Using the fact that for each j = 1, 2, . . . , (n/2) 1 we have f (x2j )
appearing in the term corresponding to the interval [x2j2 , x2j ]

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

11 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Z

f (x) dx =

n/2 
X
h
j=1


h5 (4)
[f (x2j2 ) + 4f (x2j1 ) + f (x2j )]
f (j )
3
90

Construct the Formula & Error Term (Contd)


Using the fact that for each j = 1, 2, . . . , (n/2) 1 we have f (x2j )
appearing in the term corresponding to the interval [x2j2 , x2j ] and also
in the term corresponding to the interval [x2j , x2j+2 ],

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

11 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Z

f (x) dx =

n/2 
X
h
j=1


h5 (4)
[f (x2j2 ) + 4f (x2j1 ) + f (x2j )]
f (j )
3
90

Construct the Formula & Error Term (Contd)


Using the fact that for each j = 1, 2, . . . , (n/2) 1 we have f (x2j )
appearing in the term corresponding to the interval [x2j2 , x2j ] and also
in the term corresponding to the interval [x2j , x2j+2 ], we can reduce this
sum to

Z b
(n/2)1
n/2
X
X
h
f (x) dx =
f (x0 ) + 2
f (x2j ) + 4
f (x2j1 ) + f (xn )
3
a
j=1

j=1

n/2

h5 X (4)
f (j )
90
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

11 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule

Construct the Formula & Error Term (Contd)


The error associated with this approximation is
n/2

E (f ) =

h5 X (4)
f (j )
90
j=1

where x2j2 < j < x2j , for each j = 1, 2, . . . , n/2. If f C 4 [a, b], the
Extreme Value Theorem See Theorem implies that f (4) assumes its
maximum and minimum in [a, b].

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

12 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
Since
min f (4) (x) f (4) (j ) max f (4) (x)

x[a,b]

Numerical Analysis (Chapter 4)

x[a,b]

Composite Numerical Integration I

R L Burden & J D Faires

13 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
Since
min f (4) (x) f (4) (j ) max f (4) (x)

x[a,b]

x[a,b]

we have
n/2

X
n
n
min f (4) (x)
f (4) (j )
max f (4) (x)
2 x[a,b]
2 x[a,b]
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

13 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
Since
min f (4) (x) f (4) (j ) max f (4) (x)

x[a,b]

x[a,b]

we have
n/2

X
n
n
min f (4) (x)
f (4) (j )
max f (4) (x)
2 x[a,b]
2 x[a,b]
j=1

and
n/2

min f

x[a,b]

Numerical Analysis (Chapter 4)

(4)

2 X (4)
(x)
f (j ) max f (4) (x)
n
x[a,b]
j=1

Composite Numerical Integration I

R L Burden & J D Faires

13 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
By the Intermediate Value Theorem

Numerical Analysis (Chapter 4)

See Theorem

Composite Numerical Integration I

R L Burden & J D Faires

14 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
By the Intermediate Value Theorem See Theorem there is a (a, b)
such that
n/2
2 X (4)
(4)
f () =
f (j )
n
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

14 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
By the Intermediate Value Theorem See Theorem there is a (a, b)
such that
n/2
2 X (4)
(4)
f () =
f (j )
n
j=1

Thus
n/2

h5 X (4)
h5 (4)
E (f ) =
f (j ) =
nf ()
90
180
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

14 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Construct the Formula & Error Term (Contd)
By the Intermediate Value Theorem See Theorem there is a (a, b)
such that
n/2
2 X (4)
(4)
f () =
f (j )
n
j=1

Thus
n/2

h5 X (4)
h5 (4)
E (f ) =
f (j ) =
nf ()
90
180
j=1

or, since h = (b a)/n,


E (f ) =
Numerical Analysis (Chapter 4)

(b a) 4 (4)
h f ()
180

Composite Numerical Integration I

R L Burden & J D Faires

14 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


These observations produce the following result.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

15 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


These observations produce the following result.

Theorem: Composite Simpsons Rule


Let f C 4 [a, b], n be even, h = (b a)/n, and xj = a + jh, for each
j = 0, 1, . . . , n.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

15 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


These observations produce the following result.

Theorem: Composite Simpsons Rule


Let f C 4 [a, b], n be even, h = (b a)/n, and xj = a + jh, for each
j = 0, 1, . . . , n. There exists a (a, b) for which the Composite
Simpsons rule for n subintervals can be written with its error term as

Z b
(n/2)1
n/2
X
X
h
f (x) dx =
f (a) + 2
f (x2j ) + 4
f (x2j1 ) + f (b)
3
a
j=1

j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

b a 4 (4)
h f ()
180

R L Burden & J D Faires

15 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Comments on the Formula & Error Term

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

16 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Comments on the Formula & Error Term
Notice that the error term for the Composite Simpsons rule is
O(h4 ), whereas it was O(h5 ) for the standard Simpsons rule.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

16 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Comments on the Formula & Error Term
Notice that the error term for the Composite Simpsons rule is
O(h4 ), whereas it was O(h5 ) for the standard Simpsons rule.
However, these rates are not comparable because, for the
standard Simpsons rule, we have h fixed at h = (b a)/2, but for
Composite Simpsons rule we have h = (b a)/n, for n an even
integer.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

16 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Comments on the Formula & Error Term
Notice that the error term for the Composite Simpsons rule is
O(h4 ), whereas it was O(h5 ) for the standard Simpsons rule.
However, these rates are not comparable because, for the
standard Simpsons rule, we have h fixed at h = (b a)/2, but for
Composite Simpsons rule we have h = (b a)/n, for n an even
integer.
This permits us to considerably reduce the value of h.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

16 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Simpsons Rule


Comments on the Formula & Error Term
Notice that the error term for the Composite Simpsons rule is
O(h4 ), whereas it was O(h5 ) for the standard Simpsons rule.
However, these rates are not comparable because, for the
standard Simpsons rule, we have h fixed at h = (b a)/2, but for
Composite Simpsons rule we have h = (b a)/n, for n an even
integer.
This permits us to considerably reduce the value of h.
The following algorithm uses the Composite Simpsons rule on n
subintervals. It is the most frequently-used general-purpose
quadrature algorithm.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

16 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =

Numerical Analysis (Chapter 4)

Rb
a

f (x) dx:

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT

Rb
a

f (x) dx:

endpoints a, b; even positive integer n

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Step 3

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))
For i = 1, . . . , n 1 do Steps 4 and 5:

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Step 3

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))
For i = 1, . . . , n 1 do Steps 4 and 5:
Step 4: Set X = a + ih

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Step 3

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))
For i = 1, . . . , n 1 do Steps 4 and 5:
Step 4: Set X = a + ih
Step 5: If i is even then set XI2 = XI2 + f (X )
else set XI1 = XI1 + f (X )

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Step 3

Step 6

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))
For i = 1, . . . , n 1 do Steps 4 and 5:
Step 4: Set X = a + ih
Step 5: If i is even then set XI2 = XI2 + f (X )
else set XI1 = XI1 + f (X )
Set XI = h(XI0 + 2 XI2 + 4 XI1)/3

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Simpsons Rule Algorithm


To approximate the integral I =
INPUT
OUTPUT

Step 1
Step 2

Step 3

Step 6
Step 7

Rb
a

f (x) dx:

endpoints a, b; even positive integer n


approximation XI to I
Set h = (b a)/n
Set XI0 = f (a) + f (b)
XI1 = 0; (Summation of f (x2i1 )
XI2 = 0. (Summation of f (x2i ))
For i = 1, . . . , n 1 do Steps 4 and 5:
Step 4: Set X = a + ih
Step 5: If i is even then set XI2 = XI2 + f (X )
else set XI1 = XI1 + f (X )
Set XI = h(XI0 + 2 XI2 + 4 XI1)/3
OUTPUT (XI)
STOP

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

17 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

18 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble
The subdivision approach can be applied to any of the
Newton-Cotes formulas.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

19 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble
The subdivision approach can be applied to any of the
Newton-Cotes formulas.
The extensions of the Trapezoidal and Midpoint rules will be
presented without proof.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

19 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble
The subdivision approach can be applied to any of the
Newton-Cotes formulas.
The extensions of the Trapezoidal and Midpoint rules will be
presented without proof.
The Trapezoidal rule requires only one interval for each
application, so the integer n can be either odd or even.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

19 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble
The subdivision approach can be applied to any of the
Newton-Cotes formulas.
The extensions of the Trapezoidal and Midpoint rules will be
presented without proof.
The Trapezoidal rule requires only one interval for each
application, so the integer n can be either odd or even.
For the Midpoint rule, however, the integer n must be even.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

19 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Trapezoidal Rule


y
y 5 f (x)

a 5 x0 x1

x j21

xj

x n21

b 5 xn

Note: The Trapezoidal rule requires only one interval for each
application, so the integer n can be either odd or even.
Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

20 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Trapezoidal Rule

Theorem: Composite Trapezoidal Rule


Let f C 2 [a, b], h = (b a)/n, and xj = a + jh, for each j = 0, 1, . . . , n.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

21 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Trapezoidal Rule

Theorem: Composite Trapezoidal Rule


Let f C 2 [a, b], h = (b a)/n, and xj = a + jh, for each j = 0, 1, . . . , n.
There exists a (a, b) for which the Composite Trapezoidal Rule for
n subintervals can be written with its error term as

Z b
n1
X
h
b a 2
f (x) dx = f (a) + 2
f (xj ) + f (b)
h f ()
2
12
a
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

21 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Midpoint Rule


Midpoint Rule (1-point open Newton-Cotes formula)
Z

x1

f (x) dx = 2hf (x0 ) +

x1

h3
f (),
3

where x1 < < x1

Theorem: Composite Midpoint Rule

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

22 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Midpoint Rule


Midpoint Rule (1-point open Newton-Cotes formula)
Z

x1

f (x) dx = 2hf (x0 ) +

x1

h3
f (),
3

where x1 < < x1

Theorem: Composite Midpoint Rule


Let f C 2 [a, b], n be even, h = (b a)/(n + 2), and xj = a + (j + 1)h
for each j = 1, 0, . . . , n + 1.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

22 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Midpoint Rule


Midpoint Rule (1-point open Newton-Cotes formula)
Z

x1

f (x) dx = 2hf (x0 ) +

x1

h3
f (),
3

where x1 < < x1

Theorem: Composite Midpoint Rule


Let f C 2 [a, b], n be even, h = (b a)/(n + 2), and xj = a + (j + 1)h
for each j = 1, 0, . . . , n + 1. There exists a (a, b) for which the
Composite Midpoint rule for n + 2 subintervals can be written with its
error term as
Z

f (x) dx = 2h
a

Numerical Analysis (Chapter 4)

n/2
X
j=0

f (x2j ) +

b a 2
h f ()
6

Composite Numerical Integration I

R L Burden & J D Faires

22 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Numerical Integration: Composite Midpoint Rule


y
y 5 f (x)

a 5 x21 x 0

x1

x2j21 x2j x2j11

xn21 x n b 5 x n11

Note: The Midpoint Rule requires two intervals for each application, so
the integer n must be even.
Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

23 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Outline

A Motivating Example

The Composite Simpsons Rule

The Composite Trapezoidal & Midpoint Rules

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

24 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpsons Rules


Determine values of h that will ensure
R an approximation error of less
than 0.00002 when approximating 0 sin x dx and employing:

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

25 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpsons Rules


Determine values of h that will ensure
R an approximation error of less
than 0.00002 when approximating 0 sin x dx and employing:
(a) Composite Trapezoidal rule and

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

25 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpsons Rules


Determine values of h that will ensure
R an approximation error of less
than 0.00002 when approximating 0 sin x dx and employing:
(a) Composite Trapezoidal rule and
(b) Composite Simpsons rule.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

25 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (1/5)
The error form for the Composite Trapezoidal rule for f (x) = sin x on
[0, ] is

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

26 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (1/5)
The error form for the Composite Trapezoidal rule for f (x) = sin x on
[0, ] is
2


h h2
h2



=
f
(
sin
)
| sin |.
()
=
12

12
12

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

26 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (1/5)
The error form for the Composite Trapezoidal rule for f (x) = sin x on
[0, ] is
2


h h2
h2



=
f
(
sin
)
| sin |.
()
=
12

12
12

To ensure sufficient accuracy with this technique, we need to have


h2
h2
| sin |
< 0.00002.
12
12

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

26 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example


h2
h2
| sin |
< 0.00002
12
12

Solution (2/5)

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

27 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example


h2
h2
| sin |
< 0.00002
12
12

Solution (2/5)
Since h = /n implies that n = /h, we need
3
12n2

Numerical Analysis (Chapter 4)

< 0.00002

Composite Numerical Integration I

R L Burden & J D Faires

27 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example


h2
h2
| sin |
< 0.00002
12
12

Solution (2/5)
Since h = /n implies that n = /h, we need
3
12n2

< 0.00002

1/2
3
n >
359.44
12(0.00002)
and the Composite Trapezoidal rule requires n 360.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

27 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (3/5)
The error form for the Composite Simpsons rule for f (x) = sin x on
[0, ] is

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

28 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (3/5)
The error form for the Composite Simpsons rule for f (x) = sin x on
[0, ] is
4


h4
h (4) h4



=
f
sin

()
=
180
180
180 | sin |

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

28 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (3/5)
The error form for the Composite Simpsons rule for f (x) = sin x on
[0, ] is
4


h4
h (4) h4



=
f
sin

()
=
180
180
180 | sin |
To ensure sufficient accuracy with this technique we need to have
h4
h4
| sin |
< 0.00002
180
180

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

28 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

h4
h4
| sin |
< 0.00002
180
180

Solution (4/5)

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

29 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

h4
h4
| sin |
< 0.00002
180
180

Solution (4/5)
Using again the fact that n = /h gives
5
< 0.00002
180n4

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

29 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

h4
h4
| sin |
< 0.00002
180
180

Solution (4/5)
Using again the fact that n = /h gives
5
< 0.00002
180n4

n>

5
180(0.00002)

1/4

17.07

So Composite Simpsons rule requires only n 18.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

29 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (5/5)
Composite Simpsons rule with n = 18 gives

 


Z
8
9
X
X

j
(2j 1)
sin x dx
2
sin
+4
sin
54
9
18
0
j=1

j=1

= 2.0000104

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

30 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Example

Solution (5/5)
Composite Simpsons rule with n = 18 gives

 


Z
8
9
X
X

j
(2j 1)
sin x dx
2
sin
+4
sin
54
9
18
0
j=1

j=1

= 2.0000104

This is accurate to within about 105 because the true value is


cos() ( cos(0)) = 2.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

30 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Conclusion


Composite Simpsons rule is the clear choice if you wish to
minimize computation.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

31 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Conclusion


Composite Simpsons rule is the clear choice if you wish to
minimize computation.
For comparison purposes, consider the Composite Trapezoidal
rule using h = /18 for the integral in the previous example.

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

31 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Conclusion


Composite Simpsons rule is the clear choice if you wish to
minimize computation.
For comparison purposes, consider the Composite Trapezoidal
rule using h = /18 for the integral in the previous example.
This approximation uses the same function evaluations as
Composite Simpsons rule but the approximation in this case

 
Z
17
X
j
sin x dx
2
sin
+ sin 0 + sin
36
18
0
j=1

Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

31 / 35

Example

Composite Simpson

Composite Trapezoidal

Example

Composite Numerical Integration: Conclusion


Composite Simpsons rule is the clear choice if you wish to
minimize computation.
For comparison purposes, consider the Composite Trapezoidal
rule using h = /18 for the integral in the previous example.
This approximation uses the same function evaluations as
Composite Simpsons rule but the approximation in this case

 
Z
17
X
j
sin x dx
2
sin
+ sin 0 + sin
36
18
0
j=1

 
17
X
j
=
2
sin
= 1.9949205
36
18
j=1

is accurate only to about 5 103 .


Numerical Analysis (Chapter 4)

Composite Numerical Integration I

R L Burden & J D Faires

31 / 35

Questions?

Reference Material

The Extreme Value Theorem


If f C[a, b], then c1 , c2 [a, b] exist with f (c1 ) f (x) f (c2 ), for all
x [a, b]. In addition, if f is differentiable on (a, b), then the numbers
c1 and c2 occur either at the endpoints of [a, b] or where f is zero.
Return to Derivation of the Composite Simpsons Rule

y 5 f (x)

c2

c1

Intermediate Value Theorem


If f C[a, b] and K is any number between f (a) and f (b), then there
exists a number c (a, b) for which f (c) = K .
y
(a, f (a))
f (a)
y 5 f (x)
K
f (b)

(b, f (b))

(The diagram shows one of 3 possibilities for this function and interval.)
Return to Derivation of the Composite Simpsons Rule

Вам также может понравиться