Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

CHAPTER FIVE

NUMERICAL DIFFERENTIATION AND NUMERICAL INTEGRATION

In chapter four, we were concerned with a general problem of interpolation, i.e., given a
set of values (x 0 , y0 ), (x1 , y1 ), … (x n, yn) of x and y, to find a polynomial Pn (x) of degree at
most n such that y(x) and Pn (x) agree at the set of tabulated points. In the present
chapter, we shall be concerned with driving formulas to compute:
dy d 2 y
(i) , ,  for any value x in [ x0 , xn ]
dx dx 2
xn y n xn

(ii)  f ( x) dx ,   f ( x, y) dx dy
x0 y 0 x0

Numerical Differentiation
The general method for driving Numerical differentiation formulae is to differentiate
the interpolating polynomial.

1. Derivatives using Newton’s forward interpolation formula

Newton’s forward interpolation formula is


u (u  1) 2 u (u  1)(u  2) 3 u (u  1)(u  2)(u  3) 4
y  y0  uy0   y0   y0   y0   (1)
2! 3! 4!
x  x0
where u  . (2)
h
Differentiating (1) with respect to u and (2) with respect to x, we get

dy 2u  1 2 3u 2  6u  2 3 4u 3  18u 2  22u  6 4
 y 0   y0   y0   y0   (3)
du 2! 3! 4!

du 1
and  (4)
dx h
By chain rule, we have

dy dy du 1  2u  1 2 3u 2  6u  2 3 4u 3  18u 2  22u  6 4 
 .  y 0   y0   y0   y 0   (5)
dx du dx h  2! 3! 4! 
dy
Expression (5) gives the value of at any x which may not be tabulated
dx

1
x−x0
In particular x = x 0 ⇒ u = =0
h

Putting u = 0 in to (5), we get


dy 1 1 1 1 
  y 0  2 y 0  3 y 0  4 y 0   (6)
dx x  x0 h 2 3 4 

Differentiating (5) once again we obtain

d2y 1  2 6u  6 3 12u 2  36u  226 4 


2
 2 
 y 0   y 0   y 0   (7)
dx h  6 24 
Again Putting u = 0 in to (7), we get

d2y 1  2 11 4 
  y 0   y 0  2  y 0  
3
(8)
dx 2 x  x0
h2

Note: Formulas for computing higher derivatives may be obtained by successive


differentiation
2. Derivative using Newton’s backward interpolation formula
The backward difference formula is
v(v  1) 2 v(v  1)(v  2) 3 v(v  1)(v  2)(v  3) 4
y  y n  vy n   yn   yn   yn   (9)
2! 3! 4!
x  xn
Where v  . (10)
h

From (9) & (10) together with chain rule

dy dy dv 1  2v  1 2 3v 2  6v  2 3 4v 3  18v 2  22v  6 4 
 .  y n   yn   yn   y n   (11)
dx dv dx h  2 6 24 
dy 1 1 1 1 
  y n   2 y n   3 y n   4 y n   (12)
dx x  xn h 2 3 4 

Differentiating (11) with respect to x gives

d 2 y d  dy  dv 1  2 6u  6 3 12u 2  36u  22 4 
  .  2  y n   yn   y n   (13)
dx 2
dv  dx  dx h  6 24 

d2y 1  2 11 4 
and   y n   y n  12  y n  
3
(14)
dx 2 x  xn
h2

2
Similarly higher derivatives may be obtained by successive differentiation.
Note: In a similar way different formulae can be derived by starting with other
interpolation formulae.
Example: Given the following function
X 1 3 5 7 9 11
Y -3 -9 25 147 405 847

dy d2y
Compute and for
dx dx 2
(a) x=1 (b) x=3 (c) x=11 (d) x=10
Solution: the difference table is

X y y 2 y 3 y 4 y
1 -3
-6
3 -9 40
34 48
5 25 88 0
122 48
7 147 136 0
258 48
9 405 184
442
11 847

(a) Since x= 1 is at the beginning of the table, use Newton’s forward formula.
Here x0 = 1, h = 2 & x = 1
dy 1 1 2 1 3 1 4 
  y 0   y 0   y 0   y 0  
dx x  x0 h 2 3 4 

1 1  1
 6  (40)  (48)  (0)   6  20  16  0  5 and
dy 1 1
  
dx x 1 2 2 3 4  2

d2y 1  2 11 4 
  y 0   y 0  2  y 0  
3

dx 2 x  x0
h2

d2y  11  1
40  48  2 (0)  4 40  48  0  2
1
 2 
dx x 1
22  

3
(b) Again since x= 3 is near the beginning of the table, use Newton’s forward
formula. Here x0 =1 and x=3  u  1 .

dy 1  2u  1 2 3u 2  6u  2 3 4u 3  18u 2  22u  6 4 
 y 0   y0   y0   y 0  
dx h  2! 3! 4! 
dy dy 1 2 1 36 2 4  18  22  6 
    6  (40)  (48)  (0)  3 and
dx x 3 dx u 1 2  2! 3! 4! 

d2y 1  2 6u  6 3 12u 2  36u  226 4 


2
 2   y 0   y 0   y 0  
dx h  6 24 

d2y d2y 1  66 12  36  226 


   40  6 (48)  (0)  10
dx 2 x 3
dx 2 u 1
22  24 

(c) Since x= 11 is at the end of the table, use Newton’s backward difference formula.
Here xn = 11 and h = 2.
dy 1 1 1 1 
 y n   2 y n   3 y n   4 y n  
dx x  xn h 2 3 4 

dy 1 1 1 1 
   442  (184)  (48)  (0)  275 and
dx x 11 2 2 3 4 

d2y 1  2 11 4 
  y n   y n  2  y n  
3

dx 2 x  xn
h2

d2y 1  11 
  184  48  2 (0)  58
dx 2 x 11
22  

(d) Again since x=10 is near the end of the table , we use Newton’s back ward
difference formula. Here xn=11, h=2 and x=10  u  0.5 .

dy 1  2v  1 2 3v 2  6v  2 3 4v 3  18v 2  22v  6 4 
 y n   yn   yn   y n  
dx h  2 6 24 

 2(0.5)  1 3(0.5) 2  6(0.5)  2 


 442  (184 )  (48)
dy dy 1 2 6
    
dx x 10 dx u  0.5 2  4(0.5)  18(0.5)  22(0.5)  6
3 2

 24
( 0) 

 442  0  2  0  220
1
2

4
d2y 1  2 6u  6 3 12u 2  36u  22 4 
and 2
 2 
 y n   y n   y n  
dx h  6 24 

d2y d2y 1  6(0.5)  6 12(0.5) 2  36(0.5)  22 


   184  ( 48)  (0)  52
dx 2 x 10
dx 2 u  0.5
22  6 24 

Numerical Integration
The primary purpose of numerical integration (also known as quadrature) is the
evaluation of integrals which are either impossible or else very difficult to evaluate
analytically. Numerical integration is also essential for the evaluation of integrals of
functions available only at discrete points. Such functions often arise in the numerical
solution of differential equations or from experimental data taken at discrete intervals.
Numerical integration or quadrature formulas can be developed by replacing f(x) by an
interpolating polynomial Pn (x) and integrating the polynomial to get an approximate
b b

value of the definite integral I   f ( x) dx   Pn ( x) dx .


a a

If f(x) is known at equally spaced points,


a  x0  x1  x2    xn  b where xi  x0  ih ,

f(x) can be approximated by Newton’s forward difference polynomial


u (u  1) 2 u (u  1)(u  2) 3 u (u  1)(u  2)(u  3) 4
Pn ( x)  y0  uy0   y0   y0   y0  
2! 3! 4!
where x  x0  uh  dx  h du . The resulting formula is called Newton-Cotes formula.

Hence
b xn xn n
I   f ( x) dx   f ( x) dx  h  Pn ( x) dx  h  Pn (u ) du
a x0 x0 0

Each choice of the degree of the interpolating polynomial yields a different Newton-
Cotes formula.
(i) If n=1,
1
 u2 
x1 1 1
f ( x) dx  h  P1 (u ) du  h   y 0  uy 0 du  h  y 0 u  y 0    y 0  y1 
h

x0 0 0  2 0 2

5
(ii) If n=2,

u (u  1) 2 
x2

2 2

 f ( x) dx  h P (u) du  h  y
x0 0
2
0
0  uy 0 
2!
 y 0 du 

2
 u2 2u 3  3u 2 
   y 0  4 y1  y 2 
h
 h  y 0 u  y 0  2 y 0
 2 12 0 3
(iii) If n=3,
u (u  1) 2 u (u  1)(u  2) 3 
X3

3 2
 y 0 du   y 0  3 y1  3 y 2  y 3 
3h

x0
f ( x) dx  h  P3 (u ) du  h   y 0  uy 0 
0 0
2!
 y0 
3!  8

1. Trapezoidal rule
b xn x1 x2 x3 xn


a
f ( x) dx  
x0
f ( x) dx  
x0
f ( x) dx   f ( x) dx   f ( x) dx   
x1 x2
 f ( x) dx
xn 1


h
 y0  y1   h  y1  y 2   h  y 2  y3     h  y n1  y n 
2 2 2 2
  y 0  2 y1  y 2    y n 1   y n 
h
2
1
2. Simpson’s rule (Simpson’s rule)
3
b xn x2 x4 x6 xn

 f ( x) dx   f ( x) dx   f ( x) dx   f ( x) dx   f ( x) dx     f ( x) dx
a x0 x0 x2 x4 xn  2


h
 y0  4 y1  y 2   h  y 2  4 y3  y 4   h  y 4  2 y5  y6     h  y n2  4 y n1  y n 
3 3 3 3
  y 0  4 y1  y 3    y n 1   2 y2  y 4    y n  2   y n 
h
3
3
3. Simpson’s rule
8
b xn x3 x6 x9 xn

 f ( x) dx   f ( x) dx   f ( x) dx   f ( x) dx   f ( x) dx     f ( x) dx
a x0 x0 x3 x6 xn  3


3h
 y0  3 y1  3 y 2  y3   3h  y3  3 y 4  3 y5  y6      3h  y n3  3 y n2  3 y n1  y n 
8 8 8
  y 0  3 y1  y 2  y 4  y 5    y n 1  y n  2   2 y3  y 6  y 9    y n 3   y n 
3h
8

6
1
x
Example: Evaluate  1  x dx with n  6 intervals by the trapezoidal rule
0

x ba 1 0 1
Solution: We have f ( x)  , a  0, b  1 and n  6  h    .
1 x n 6 6
X 0 1/6 1/3 1/2 2/3 5/6 1
f(x) 0 1/7 1/4 1/3 2/5 5/11 1/2

The trapezoidal rule can be written as


1

 1  x dx  2 y  2 y1  y 2    y n 1   y n 
x h
0
0

1   1 1 1 2 5  1
  0  2         0.30512
12   7 4 3 5 11  2 
0.6

Example: Evaluate e dx , taking n  6 , using


x

(a) Simpson’s rule (b) Simpson’s 3/8 rule


0.6  0
Solution: We have f ( x)  e x , a  0, b  0.6 and n  6  h   0.1 .
6
x 0.0 0.1 0.2 0.3 0.4 0.5 0.6

f ( x)  e x 1.00000 1.10517 1.22140 1.34986 1.49182 1.64872 1.82212

(a) Simpson’s rule


0.6

e
x
dx 
h
 y 0  3 y1  y3  y5   2 y2  y4   y 6   0.82212
0
3

(b) Simpson’s 3/8 rule


0.6

e
x
dx 
3h
 y 0  3 y1  y 2  y 4  y5   2 y3   y 6   0.82212
0
8

You might also like