Chapter 8

advertisement
Chapter 8
Numerical Integration
Lecture (I)1
Ref.: “Applied Numerical Methods with MATLAB for Engineers and
Scientists”, Steven Chapra, 2nd ed., Ch. 17, McGraw Hill, 2008.
1
Dr. Jie Zou PHY3320
1
Outline

Introduction




What is integration?
When do we need numerical integration?
Applications of integration in engineering and
science
Newton-cotes formulas

(1) The trapezoidal rule



Error of the Trapezoidal rule
The composite trapezoidal rule
Implementation in MATLAB
Dr. Jie Zou PHY3320
2
Introduction

What is integration?




Ref. Fig. 17.1 Graphical
representation of the
integral
Mathematically: A definite
integration is
b
represented by I   f x dx .
a
It means: The total value, or summation, of
f(x)dx over the range x = a to b.
Graphical representation: For functions lying
above the x axis, the integral corresponds to
the area under the curve of f(x) between x =
a and b.
When do we need numerical integration
(also referred to as quadrature)?


Functions that are difficult to or cannot be
integrated analytically.
Only a table of discrete data are available.
Dr. Jie Zou PHY3320
3
Applications of integration in
engineering and science


Examples related to “the integral as
the area under a curve”:
Examples related to the analogy
between integration and summation:

Ref. Fig. 17.3
An example: To determine the mean of a
continuous function
4
Newton-cotes formulas

Ref. Fig. 17.4 The approx. of an integral by the
area under (a) a straight line and (b) a parabola
Ref. Fig. 17.5 The
approx. of an integral
by the area under
three straight-line
segments
Basic strategy:
Replacing a
complicated function or
tabulated data with a
polynomial that is
easy to integrate.
b
b
I   f x dx   f n x dx
a
a


fn(x) = a0 + a1x + … +
an-1xn-1+anxn
n: The order of the
polynomial.
Dr. Jie Zou PHY3320
5
Newton-cotes formulas: (1)
The trapezoidal rule

Ref. Fig. 17.7 Single application

Basic idea: Replacing the complicated
function or tabulated data with a
polynomial or a series of polynomials of
the first order (linear).
Single and Composite applications

Single application formula:
f a   f b
I  b  a 

2
Width 
Average Height

Composite application formula:
n 1
f x0   2 f xi   f xn 
Ref. Fig. 17.9 Composite application
i 1
I  b  a 

2n

Width 
Average Height
6
Error of the trapezoidal rule

For single applications, an estimate
for the error:
1
1
3
3





Et  
f  b  a ; Ea  
f b  a 
12
12
If the function being integrated is linear,
Et = 0; otherwise, Et  0.


Ref. Fig. 17.8 Truncation
error for a single application
of the trapezoidal rule
For composite applications, an
estimate for the error:
n
Et   Et ,i
i 1


3

b  a

12n
3
n
 f   ; E
i 1
i
a
3

b  a

12n
2
If the number of segments is doubled, Et
is approximately quartered.
b
Here, f   1
f  x dx
b  a a
f 
7
Example: Composite application
of the trapezoidal rule

Example 17.2 (Ref.): Use the
two-segment trapezoidal rule
to estimate the integral of f(x)
= 0.2 + 25x – 200x2 + 675x3
– 900x4 + 400x5 from a = 0 to
b = 0.8. Also, find the true
error Et and the approximate
error, Ea.

x0 = a
x1
Two segments n = 2;
x2 = b

(1) By hand.
(2) Implement on a computerwrite an M-file.
Dr. Jie Zou PHY3320
8
Results
n
2
3
4
5
6
7
8
9
10
h
0.4
0.2667
0.2
0.16
0.1333
0.1143
0.1
0.0889
0.08
Dr. Jie Zou PHY3320
I
1.0688
1.3695
1.4848
1.5399
1.5703
1.5887
1.6008
1.6091
1.6150
t (%)
34.9
16.5
9.5
6.1
4.3
3.2
2.4
1.9
1.6
9
Implementation of composite
trapezoidal rule on a computer


Write an M-file called
My_Trapezoidal_Rule.m to do
Example 17.2.
A copy of the code will be handed out
later.
Dr. Jie Zou PHY3320
10
Download