Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 28

Numerical Integration

1
Introduction to Numerical
Integration
 Definitions
 Upper and Lower Sums
 Trapezoid Method (Newton-Cotes Methods)
 Romberg Method
 Gauss Quadrature
 Examples

2
Integration
Indefinite Integrals Definite Integrals

2 1 2 1
x x 1
 x dx  2  c 0 xdx  2 
2
0

Indefinite Integrals of a Definite Integrals are


function are functions numbers.
that differ from each
other by a constant.

3
Fundamental Theorem of Calculus
If f is continuous on an interval [a,b] ,
F is antiderivative of f (i.e., F ' (x)  f(x) )
b
 a
f(x)dx  F(b)  F(a)

x2
There is no antiderivative for : e
b
x2
No closed form solution for :  e dx
a
4
The Area Under the Curve
One interpretation of the definite integral is:
Integral = area under the curve

f(x)

b
Area   f(x)dx
a

a b
5
Newton-Cotes Methods
 In Newton-Cote Methods, the function
is approximated by a polynomial of
order n.
 Computing the integral of a polynomial
is easy.


a
b
f ( x)dx  
a
b
a 0  a1 x  ...  a n xn
dx
b (b 2  a 2 ) (b n 1  a n 1 )

a
f ( x)dx a0 (b  a )  a1
2
 ...  an
n 1

6
Newton-Cotes Methods
 Trapezoid Method (First Order Polynomials are used)

b b
a f ( x)dx  
a
a0  a1x dx

 Simpson 1/3 Rule (Second Order Polynomials are used)

a
b
f ( x)dx  
b
a
a0  a1 x  a 2 x 
2
dx

7
Trapezoid Method
 Derivation-One Interval
 Multiple Application Rule
 Estimating the Error
 Recursive Trapezoid Method

Read 21.1

8
Trapezoid Method
b
I   f ( x)dx
f (b)  f (a) a
f (a )  ( x  a)
ba b  f (b)  f (a ) 
I    f (a)  ( x  a ) dx
f(x)
a
 ba 
b
 f (b)  f (a ) 
  f (a)  a x
 ba  a
2 b
f (b)  f ( a ) x

ba 2 a
a b f (b)  f (a )
 b  a 
2
9
Trapezoid Method
Derivation-One Interval
b b f (b)  f (a ) 
I   f ( x)dx    f (a)  ( x  a) dx
a a
 ba 
b f (b)  f (a) f (b)  f (a) 
I    f (a)  a  x dx
a
 ba ba 
b 2 b
 f (b)  f (a)  f (b)  f (a ) x
  f (a)  a x 
 ba  a ba 2 a

 f (b)  f (a)  f (b)  f (a ) 2


  f (a)  a b  a   (b  a 2 )
 ba  2(b  a )
f (b)  f (a )
 b  a 
2
10
Trapezoid Method
f(x)

f (b)

f (a )
ba
Area   f (a)  f (b) 
2
a b
11
Trapezoid Method
Multiple Application Rule
f ( x2 )  f ( x1 )
Area  x2  x1 
f(x) 2
The interval [a, b] is
partitioned into n segments
a  x0  x1  x2  ...  xn  b
b

a
f ( x)dx  sum of the areas
of the trapezoids
x
x0 x1 x2 x3
a b
12
Trapezoid Method
General Formula and Special Case

If the interval is divided into n segments (not necessaril y equal)


a  x0  x1  x2  ...  xn  b
b 1
n 1

 f ( x)dx   xi 1  xi  f ( xi 1 )  f ( xi ) 
i 0 2
a

Special Case ( Equaliy spaced base points)


xi 1  xi  h for all i
b 1 n 1

 f ( x)dx  h   f ( x0 )  f ( xn )  f ( xi ) 
a
2 i 1 
13
Example
Given a tabulated Time (s) 0.0 1.0 2.0 3.0
values of the velocity of
an object. Velocity (m/s) 0.0 10 12 14

Obtain an estimate of
the distance traveled in
the interval [0,3].

Distance = integral of the velocity


3
Distance   0
V (t ) dt
14
Example 1
The interval is divided Time (s) 0.0 1.0 2.0 3.0

into 3 subintervals Velocity 0.0 10 12 14

Base points are0,1,2,3


(m/s)

Trapezoid Method
h  xi 1  xi  1
 n 1 1 
T  h  f ( xi )   f ( x0 )  f ( xn ) 
 i 1 2 
 1 
Distance  1(10  12)  (0  14)  29
 2 
15
Error in estimating the integral
Theorem
Assumption : f ' ' ( x) is continuous on [a,b]
Equal intervals (width  h)
Theorem : If Trapezoid Method is used to
b
approximate  a
f ( x)dx then
b  a 2 ''
Error   h f ( ) where   [a,b]
12
ba 2
Error  h max f ' ' ( x)
12 x[ a ,b ]

16
Estimating the Error
For Trapezoid Method

How many equally spaced intervals are



needed to compute  0
sin( x)dx
to 5 decimal digit accuracy ?

17
Example


1
sin( x )dx, find h so that error   105
2
0
ba 2
Error  h max f ' ' ( x )
12 x[ a ,b ]
b   ; a  0; f ' ( x )  cos( x ); f ' ' ( x )   sin( x )
 2 1
f ' ' ( x )  1  Error  h   105
12 2
2 6
 h   105  h  0.00437

(b  a ) 
 n   719 intervals
h 0.00437 18
Example
x 1.0 1.5 2.0 2.5 3.0

f(x) 2.1 3.2 3.4 2.8 2.7

3
Use Trapezoid method to compute :  1
f ( x)dx

1
n 1
Trapezoid T ( f , P )   xi 1  xi  f ( xi 1 )  f ( xi ) 
i 0 2

Special Case : h  xi 1  xi for all i,


 n 1 1 
T ( f , P)  h  f ( xi )   f ( x0 )  f ( xn ) 
 i 1 2 
19
Example
x 1.0 1.5 2.0 2.5 3.0

f(x) 2.1 3.2 3.4 2.8 2.7

3 n1 1 
1 f ( x)dx  h  f ( xi )   f ( x0 )  f ( xn ) 
 i 1 2 
 1 
 0.5  3.2  3.4  2.8  2.1  2.7 
 2 
 5.9
20
Simpson’s Rule

21
Simpson’s Rule

22
Simpson’s Rule

23
Simpson’s Rule

24
Simpson’s Rule

25
Simpson’s Rule

26
Simpson’s Rule

27
Homework

Problem- 21.1, 21.2, 21.3, 21.4,


21.10, 21.11, 21.13

28

You might also like