Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
69 views9 pages

Numerical Integration Notes

Uploaded by

Johnson Chisanga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views9 pages

Numerical Integration Notes

Uploaded by

Johnson Chisanga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

6.

NUMERICAL INTEGRATION

n
We will use the methods called numerical quadrature which use a sum  a f (x )
i 0
i i to

approximate

b
a
f ( x) dx. (6.1)

The method that involves integrating the Lagrange interpolating polynomial can be used to

derive what are known as Newton-Cotes formulas for evaluating (6.1). For example, using

the first and second Lagrange interpolating polynomials with equally-spaced nodes gives the

Trapezoidal rule and Simpson’s rule, respectively. To derive these, we need the following

theorem:

Theorem 6.1.1 (Weighted Mean Value Theorem for Integrals)

If f  C[a, b], g is integrable on [ a, b] and g ( x) does not change sign on [ a, b] , then there

exists a number  , a    b, such that

b b
a
f ( x) g ( x) dx  f ( )  g ( x) dx.
a

Let x0  a, x1  b and h  b  a. Using the linear Lagrange interpolating polynomial

( x  x1 ) ( x  x0 ) f ( ( x))
f ( x)  f ( x0 )  f ( x1 )  ( x  x0 )( x  x1 )
( x0  x1 ) ( x1  x0 ) 2!

we get

b x1  ( x  x ) ( x  x0 )  x1  f ( ( x )) 
a
f ( x) dx   
x0 ( x  x )
 0 1
1
f ( x0 ) 
( x1  x0 )
f ( x1 )  dx   

x0  2!
( x  x0 )( x  x1 )  dx

x1
( x  x1 ) 2 ( x  x0 ) 2 1 x1
 f ( x0 )  f ( x1 )   f ( ( x ))( x  x0 )( x  x1 ) dx
2( x0  x1 ) 2( x1  x0 ) x
2 x0
0

h 1
 f ( x1 )  f ( x0 )  x0 f ( ( x))( x  x0 )( x  x1 ) dx.
x1

2 2

1
We can now apply Theorem 6.1.1, since ( x  x0 )( x  x1 ) does not change sign on [ x0 , x1 ] to get

x1 x1  x3 ( x  x ) x 2 x1

x0
f ( ( x))( x  x0 )( x  x1 ) dx  f ( ( x))  ( x  x0 )( x  x1 ) dx  f ( ( x ))  
x0  3
1

2
0
 x0 x1 x 

 x0 

 x 3 x x 2 x 3 x 2x 
 f ( ( x))   1  0 1  0  0 1 
 6 2 6 2 
   x1  x0 3 

 f ( ( x))  
 6 
3
h
 f ( ( x)).
6
Thus, the Trapezoidal rule is

h 1 h3 h h3
 1 0   1 0 
b
 a
f ( x) dx 
2
f ( x )  f ( x )  .
2 6
f ( ( x )) 
2
f ( x )  f ( x ) 
12
f ( ( x))

y y  f ( x)

a  x0 b  x1 x

ba
Letting x0  a, x1  a  h and x2  b with h  and using the second Lagrange
2
polynomial, we can derive the Simpson’s rule with an O (h 4 ) error term involving f (3) .

y y  f ( x)

y  P2 ( x)

a  x0 x1 b  x2 x

We can use the third Taylor polynomial about x1 to obtain a higher-order term involving

f (4) . Then, for each x in [ x0 , x2 ], there exists a number 1 ( x) in  x0 , x2  such that

2
f ( x1 ) f ( x1 ) f (4) (1 ( x))
f ( x)  f ( x1 )  f ( x1 )( x  x1 )  ( x  x1 ) 
2
( x  x1 ) 
3
( x  x1 ) 4
2! 3! 4!
for some number 1 ( x) in  x0 , x2  , so that
b x2  f ( x1 ) f ( x1 ) 
a
f ( x) dx    f ( x1 )  f ( x1 )( x  x1 ) 
x0
 2!
( x  x1 ) 2 
3!
( x  x1 )3  dx

x2  f
(4)
(1 ( x)) 
  ( x  x1 ) 4  dx
x0
 4! 
x
 f ( x1 ) f ( x1 ) f ( x1 ) 
2

  f ( x1 )( x  x1 )  ( x  x1 ) 2  ( x  x1 )3  ( x  x1 ) 4 
 2 6 24  x0
x2  f
(4)
(1 ( x)) 
  ( x  x1 ) 4  dx
x0
 4! 

 f ( x1 ) f ( x1 ) f ( x1 )
  f ( x1 )( x2  x1 )  ( x2  x1 ) 2  ( x2  x1 )3  ( x2  x1 ) 4
 2 6 24
f ( x1 ) f ( x1 ) f ( x1 ) 
 f ( x1 )( x1  x0 )  ( x1  x0 ) 2  ( x1  x0 )3  ( x1  x0 ) 4 
2 6 24 
x2  f
(4)
(1 ( x)) 
  ( x  x1 ) 4  dx
x0
 4! 
f ( x1 ) 3 x2  f
(4)
(1 ( x)) 
 2hf ( x1 )  h   ( x  x1 ) 4  dx, since h  x2  x1  x1  x0 .
3 x0
 4! 
Thus, by Theorem 6.1.1, we have that
x2
x2  f (4) (1 ( x)) 4 f (4) (1 ( x)) x2 f (4) (1 ( x))
      ( x  x1 )5
4
 ( x x1 )  dx ( x x1 ) dx
x0
 4!  24 x0 120 x0

f (4) (1 ( x)) f (4) (1 ( x))


 ( x2  x1 )5  ( x0  x1 )5   ( x2  x1 )5  ( x1  x0 )5 
120 120
f (1 ( x)) 5
(4)
 h
60
b h3 h5 (4)
  a
f ( x) dx  2hf ( x1 ) 
3

f ( x1 ) 
60
f (1 ( x)).

Using the second derivative midpoint formula, we have that

1 h 2 (4) 1 h 2 (4)
f ( x1 )  [ f ( x1  h )  2 f ( x1 )  f ( x1  h )]  f (1 ( x ))  [ f ( x0 )  2 f ( x1 )  f ( x2 )]  f (1 ( x))
h2 12 h2 12
so that
b h3  1 h 2 (4)  h5 (4)
a
f ( x) dx  2hf ( x1 ) 
3  h2
[ f ( x0 )  2 f ( x1 )  f ( x2 )] 
12
f (1 ( x ))   60 f (1 ( x)).

3
Therefore, the Simpson’s rule is

h h5
 f ( x0 )  4 f ( x1 )  f ( x2 )  f (4) (1 ( x)).
b
 a
f ( x) dx 
3 90

The error term in Simpson’s rule involves the fourth derivative of f , so it gives exact

results when applied to any polynomial of degree three or less.

Example 6.1.1

2
Use the Trapezoidal rule and the Simpson’s rule to evaluate  0
1  x2 .

Solutions:

Using Trapezoidal rule, we have that x0  0, x1  2 and h  2 so that

2
 f ( x0 )  f ( x2 )  f (0)  f (2)  1  5  3.236067977
2
0
1  x2 
2

20
Using Simpson’s rule, we have that x0  0, x1  1, x2  2 and h   1 so that
2

h 1
 f ( x0 )  4 f ( x1 )  f ( x2 )   f (0)  4 f (1)  f (2)
2
 0
1  x2 
3 3

1
1  4 2  5   2.964307409.
3

The Newton-Cotes formulas, however, are generally unsuitable for use over large integration
intervals because of the oscillatory nature of high-degree polynomials.

Theorem 6.1.2

ba
Let f  C 2 [a, b], h  and x j  a  jh for each j  0,1, 2,..., n. There exists a   (a, b)
n
for which the Composite Trapezoidal rule for n subintervals can be written with its error
term as

h n 1  ba 2

b
a
f ( x) dx  
2
f ( a )  2
j 1
f ( x j )  f (b)  
 12
h f (  ).

4
Example 6.1.2

(a) Find an approximation to the area of the region bounded by the normal curve

2
x
 
 
1
f ( x) 
2
e
 2

and the x  axis on the interval [ ,  ] using the Composite Trapezoidal rule with n  8.

(b) Using the Composite Trapezoidal rule, determine the value of n and h required to
2
approximate 
0
e 2 x sin 3 x dx to within 104.

Solutions:

(a) Clearly, f  C 2   ,  .

  ( )   
With a   , b   and n  8, we have that h   and x j    j  
8 4 4
 3   3 
 x1     , x2      , x3      , x4      0,
4 4 2 2 4 4
5  3  7 3
x5     , x6     and x7    
4 4 2 2 4 4
2
  
 
   
1
1 1
 f (a )  f ( )  
2 2
e e
 2  2
2
 3 
 
 4 
  
 
 3 
  
9
1 1
f ( x1 )  f    
2 32
e e
 4   2  2
2
  
 
 2 
  
 
 
  
1
1 1
f ( x2 )  f     
2 8
e e
 2   2  2
2
  
 
 4 
  
 
 
  
1
1 1
f ( x3 )  f     
2 32
e e
 4   2  2
1
f ( x4 )  f (0) 
 2

5
2
 
 
 4 
 
 
 
  
1
1 1
f ( x5 )  f    
2 32
e e
 4   2  2
2
 
 
 2 
 
 
 
  
1
1 1
f ( x6 )  f    
2 8
e e
2  2  2
2
 3 
 
 4  2
    
   

 3
 

  
9

1
1 1 1 1
f ( x7 )  f    and f (b)  f ( )  
2 32 2 2
e e e e .
 4   2  2  2  2

 h 81 


f ( x) dx   f ( )  2 f ( x j )  f ( ) 
2 j 1 

  f ( )  2 f ( x1 )  2 f ( x2 )  2 f ( x3 )  2 f ( x4 )  2 f ( x5 )  2 f ( x6 )  2 f ( x7 )  f ( ) 
8

  1   1 8   1   1 
1 9 1 1
   
1
 e  2   2 e   2   2 
2 32 32
 e e
8   2   2    2    2    2 
 1 32   1 8   1 32  2 
1 1 9 1
   
1
2 e   2 e   2 e  e 
  2    2    2   2 

  2 
1 9 1 1
  
2
 .     1
32 8 32

 e 2e 2e 2e
8  2  
 0.680163689
(b) Here, a  0, b  2 and f ( x)  e2 x sin 3x

 f ( x)  2e2 x sin 3x  3e2 x cos 3x

f ( x)  2 2e2 x sin 3x  3e2 x cos3x   3 2e2 x cos3x  3e2 x sin 3x   12e2 x cos3x  5e2 x sin 3x.

The error function for the Composite Trapezoidal rule is


ba 2
E( f )   h f (  )
12

ba 2  2 
  h f (  )  104   h 2  Max 12e 2 x cos 3 x  5e 2 x sin 3 x   10 4.
12  12  0,2

Since Max 12e2 x cos 3 x  5e2 x sin 3 x   705.3601029, we have that


0,2

6 104
h2 
705.3601029
6
 h  8.506293417 107  0.0009222956911.
ba
Since h  , we have that
n
2 2
 0.0009222956911 n  2168.501945
n 0.0009222956911
 n  2168.

Theorem 6.1.3

ba
Let f  C 4 [a, b], n be even, h  and x j  a  jh for each j  0,1, 2,..., n. There exists a
n
  (a, b) for which the Composite Simpson’s rule for n subintervals can be written with its
error term as

h  b  a 4 (4)
n1 n

f ( x) dx   f (a)  2 f ( x2 j )  4 f ( x2 j 1 )  f (b)  
b 2 2


a 3  j 1 j 1  180
h f (  ).

Example 6.1.3

(a) A car laps a race track in 84 seconds. The speed of the car at each 6  second interval

is determined by using a radar gun and is given from the beginning of the lap, in
feet/second, by the entries in the following table:

Time 0 6 12 18 24 30 36 42 48 54 60 66 72 78 84
Speed (ft/s) 124 134 148 156 147 133 121 109 99 85 78 89 104 116 123

How long is the track?

(b) Determine the value of n and h required to approximate

2  1 

0   dx
 x4

to within 10 5 and compute the approximation using Composite Simpson’s rule.

7
Solutions:

(a) Here h  6, x0  0, x1  6, x2  12,..., x13  78, x14  84.

Since n  14, we can use Composite Simpson’s rule:

h 
1
14 14

f ( x) dx   f ( x0 )  2 f ( x2 j )  4 f ( x2 j 1 )  f ( x14 ) 
84 2 2

 Length of the track, l  


0 3  j 1 j 1 

h
  f ( x0 )  2 f ( x2 )  2 f ( x4 )  2 f ( x6 )  2 f ( x8 )  2 f ( x10 )  2 f ( x12 )  4 f ( x1 )  4 f ( x3 )  4 f ( x5 ) 
3
4 f ( x7 )  4 f ( x9 )  4 f ( x11 )  4 f ( x13 )  f ( x14 ) 
h
 124  2(148)  2(147)  2(121)  2(99)  2(78)  2(104)  4(134)  4(156)  4(133) 
3
4(109)  4(85)  4(89)  4(116)  (123)
 4232 ft.

b  a 4 (4) 1 1 2
(b) E( f )   h f (  ), where f ( x)   f ( x)   , f ( x)  ,
180 x4 ( x  4) 2
( x  4)3

6 24
f ( x)   and f (4) ( x)  .
( x  4) 4
( x  4)5

24
 f (4) (  ) 
(   4)5

 2 4  (4)
 E( f )   h  f (  )  105
 180 
h4  24  5
 Max    10
90 0,2  (   4)5 
h4  4  5
  5   10
15  4 
 h 4  105 (3840)  0.0384
 h  0.442672767.
ba
h  0.442672767
n
2
n  4.518
0.442672767
 n  4.
Using Composite Simpson’s rule, we take n  6 so that

8
 1  h
 dx   f ( x0 )  2 f ( x2 )  2 f ( x4 )  4 f ( x1 )  4 f ( x3 )  4 f ( x5 )  f ( x6 )]
2

0 
 x4 3
2 
1  1   1   1   1   1  1 
 6   2 2   2 4   4 1   4   4 5  
3  4  3  4   3  4   3  4   1  4   3  4  2  4 
 0.405466374.
2  1 

2
The exact value is   dx  ln x  4 0  ln 6  ln 4 0.405465108
0
 x4

giving the error | ln 32  0.405466374 | 0.00000126589184  105.

THE END!

You might also like