0% found this document useful (0 votes)
3 views

Numerical Differentiation and Integration-BK9

This document covers numerical differentiation and integration techniques, including methods for approximating derivatives and evaluating definite integrals from tabulated data. Key methods discussed include the Trapezoidal Rule, Simpson’s One Third Rule, Simpson’s Three Eight Rule, Waddle’s Rule, and Cote’s Method. Additionally, examples are provided to illustrate the application of these numerical methods in practical scenarios.

Uploaded by

sarahaonyango70
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)
3 views

Numerical Differentiation and Integration-BK9

This document covers numerical differentiation and integration techniques, including methods for approximating derivatives and evaluating definite integrals from tabulated data. Key methods discussed include the Trapezoidal Rule, Simpson’s One Third Rule, Simpson’s Three Eight Rule, Waddle’s Rule, and Cote’s Method. Additionally, examples are provided to illustrate the application of these numerical methods in practical scenarios.

Uploaded by

sarahaonyango70
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/ 19

UNIT – III

NUMERICAL DIFFERENTIATION AND INTEGRATION

3.1 Introduction
3.2 Numerical Differentiation
3.3 Numerical Integration
3.4 Trapezoidal Rule
3.5 Simpson’s One Third Rule
3.6 Simpson’s Three Eight Rule

38
3.7 Waddle’s Rule
3.8 Cote’s Method

3.1 Introduction
We assume that a function f(x) is given in a tabular form at a set of n+1 distinct points
x0, x1, …, xn. From the given tabular data, we require approximations to the derivatives
f ( r ) (x), r  1 , where x  may be a tabular or a non-tabular point. We consider the cases
r = 1, 2.
In many applications of science and engineering, we require to compute the value of
b
the definite integral  f ( x ) dx , where f(x) may be given explicitly or as a tabulated data. Even
a

when f(x) is given explicitly, it may be a complicated function such that integration is not
easily carried out.
Here, we shall derive numerical methods to compute the derivatives or evaluate an
integral numerically.

3.2 Numerical Differentiation


Approximation to the derivatives can be obtained numerically using the following two
approaches
(i) Methods based on finite differences for equispaced data.
(ii) Methods based on divided differences or Lagrange interpolation for non-uniform data.
Numerical differentiation is the process of calculating the derivation of a given
function by means of a table of given values of that function. That is, if (xi, yi) are the given
dy d 2 y
set of values, then the process of computing the values of , ,, etc. at a given point is
dx dx 2
called numerical representation.
The interpolation formula depends on the particular value of x at which the
derivatives are required.
(i) If the values of x are not equally spaced, we represent the function by Newton’s
divided difference formula and the derivatives are obtained.
(ii) If the values of x are equally spaced the derivatives are calculated by using Newton’s
Forward or backward interpolation formula.

3.3 Numerical Integration

39
b
The process of evaluating a definite integral  f x  dx from a set of tabulated values
a

(xi, yi); i=0, 1, …, n of the integrand y = f(x) is called numerical integration.

Newton cote’s formula (or) General Quadrature formula for equidistant coordinates
b
Let I   y dx where y = f(x) takes the values y0, y1, …, yn for x0, x1, …, xn. Let us
a

divide the interval (a, b) into n sub intervals of width h so that x0 = a, x1 = x0+h, x2 = x0+2h,
…, xn = x0+nh = b. After simplification, we get

 n2n  3 2 nn  2 3 
xn 2
n
I   ydx  nh  y 0  y 0   y0   y 0   (1)
x0  2 12 24 

which is the general quadrature formula.

By putting n = 1 in equation (1), Trapezoidal rule is obtained.

1
By putting n = 2 in equation (1), Simpson’s rule is obtained.
3

3
By putting n = 3 in equation (1), Simpson’s rule is obtained.
8

3.4 Trapezoidal Rule

Putting n = 1 in equation (1), we get


x1 x0  h
 1 
 y dx 
x0

x0
y dx  h  y 0  y 0 
 2 


h
2 y0  y0 
2


h
y0   y0  y0 
2


h
y0  y1 
2

Similarly,
x2 x0  2 h
 1 
 y dx  
x1 x0  h
y dx  h  y1  y1 
 2 


h
2 y1  y1 
2
40

h
y1   y1  y1 
2


h
y1  y 2 
2

and so on.
xn x0  nh

 y dx   y dx 
h
y n1  y n 
xn 1 x0  n 1h
 2

 Adding all the above, we get


xn

 y dx  2  y  y n   2 y1  y 2  y3    y n 1  which is called Trapezoidal Rule.


h
0
x0

1
3.5 Simpson’s Rule (or) Simpson’s Rule
3

Putting n = 2 in equation (1) and neglecting the differences of higher order than
second order. We get,
xn

 y dx  3  y  y n   4 y1  y3    y n 1   2 y 2  y 4    y n 2  .
h
0
x0

Note:

It should be noted that for applying this rule, the interval must be divided into even
number of sub intervals of width h.

3
3.6 Simpson’s th Rule
8

Putting n = 3 in equation (1) and neglecting the higher order differences above the
third, we get
xn

 y dx  8  y  y n   3 y1  y 2  y 4  y5   y n 1   2 y3  y 6    y n 3 
3h
0
x0

Note:

This is not as accurate as Simpson’s rule. This rule is used when the number of
subintervals is a multiple of 3.

Example: 1

1
dx
Using Trapezoidal rule, evaluate 1 x
1
2
taking 8 intervals.

41
Solution

Given y  f x  
1
1 x2

Given x = -1 to 1.

 Length of interval = 2.

2 ba
h   0.25 . h 
8 number of int ervals

1   1
  0.25
8

 We form a table

x -1 -0.75 -0.5 -0.25 0 0.25 0.50 0.75 1

y 0.5 0.64 0.8 0.9412 1 0.9412 0.8 0.64 0.5

xn

 y dx  2  y  y n   2 y1  y 2  y3    y n 1 
h
 Trapezoidal rule is 0
x0

1 x
1
2
dx 
0.25
0.5  0.5  20.64  0.8  0.9412  1  0.9412  0.8  0.64
1
2


0.25
1  25.7624
2

=1.5656.

Example: 2
1
dx 1
Evaluate 1 x
0
2
with h 
6
by Trapezoidal rule.

Solution

Given y  f x  
1
1 x2

Given x = 0 to 1

1
Also h  .
6
42
The table is

x 0 1/6 2/6 3/6 4/6 5/6 1

y 1 36/37 9/10 4/5 9/13 36/61 1/2

By Trapezoidal rule,
xn

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

1
1
1  
6  1   36 9 4 9 36 
0 1  x 2 dx  2 1  2   2 37  10  5  13  31 

1 3 
   23.9554
12  2 

= 0.7842.

Example: 3

5.2

 log e dx by using (i) Trapezoidal rule (ii) Simpson’s rule (iii) Simpson’s
x
Evaluate
4

3
rule, given that h = 0.2.
8

Solution

Given y = f(x) = log ex

x = 4 to 5.2, h = 0.2.

The table is

x 4 4.2 4.4 4.6 4.8 5.0 5.2

y 1.737 1.824 1.910 1.997 2.084 2.171 2.258

(i) By Trapezoidal rule,


xn

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


0.2
1.737  2.258  21.824  1.910  1.997  2.084  2.171
2

43
= 0.3967.

1
(ii) By Simpson’s rule (or) Simpson’s rule,
3
xn

 y dx  3  y  y n   4 y1  y3    y n 1   2 y 2  y 4    y n 2 
h
0
x0

5.2

 log e
x
dx 
0.2
1.737  2.258  41.824  1.997  2.171  21.910  2.084
4
3

= 0.0666[3.995+4(5.992)+2(3.994)]

= 2.394.

3
(iii) By Simpson’s rule,
8
xn

 y dx  8  y  y n   3 y1  y 2  y 4  y5   y n 1   2 y3  y 6    y n 3 
3h
0
x0

30.2
 1.737  2.258  31.824  1.910  2.084  2.171  21.997
8

= 2.3967.

Romberg’s Method

b
Romberg’s method is used to evaluate the integral of the form I   y dx .
a

For Romberg’s method, let us apply Trapezoidal rule several times find the value of
I’s as follows:

h
I1: Dividing ‘h’ into 2 parts (i.e)
2

h h/2
I2: Dividing ‘h’ into 4 parts (i.e)  
4 2 

h h/4
I3: Dividing ‘h’ into 8 parts (i.e)  
8  2 

h  h/8
I4: Dividing ‘h’ into 16 parts (i.e)  
16  2 

and so on.

44
Applying Romberg’s formula,

I I 
I  I2   2 1 
 3 

For I1, I2; I2, I3; I3, I4; …

We get the values of I. This method continues till we get two successive values of I’s
are equal. The systematic refinement of the values of I’s is called Romberg’s method.

Example: 1

1
dx
Use Romberg’s method to compare  . Correct to 4 decimal places and hence
0 1  x 2

find an approximate value of π.

Solution

1
dx
Let I  
0 1 x
2

To find I1:

h
Dividing h into 2 parts (i.e) .
2

1 0
h   0.5
2

X 0 0.5 1

1 1 0.8 0.5
y=
1 x2

By Trapezoidal rule,

I1 
h
 y0  y 2   2 y1 
2


0.5
1  0.5  20.8
2

= 0.775.

To find I2:

h
Dividing h into 4 parts (i.e) .
4
45
1 0
h   0.25
4

x 0 0.02 0.50 0.75 1

y 1 0.941 0.8 0.64 0.5

By Trapezoidal rule,

I2 
0.25
1  0.5  20.941  0.8  0.64
2

= 0.7828.

To find I3:

h/4
Dividing h into 8 parts (i.e)
2

1 0
h   0.125
8

x 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1

y 1 0.9846 0.9412 0.8767 0.80 0.7191 0.64 0.5664 0.5

By Trapezoidal rule,

I3 
0.125
1  0.5  20.984  0.94  0.876  0.8  0.719  0.64  0.56
2

= 0.78475.

By Romberg’s Formula:

Iteration 1:

I I 
I  I2   2 1 
 3 

 0.7828  0.775 
 0.7828   
 3 

I = 0.7854.

Iteration 2:

46
I I 
I  I3   3 2 
 3 

 0.78475  0.7828 
 0.78475   
 3 

I = 0.7854.

From the last two iterations, I = 0.7854.

To find π:

1
 1  x 
1
dx
0 1  x 2  tan  1 
0

 tan 1 1  tan 1 0


 .
4

1
dx
But 1 x
0
2
 0.7854


0.7854 
4

π = 4(0.7854)

  3.1416 .

Two points and three points Gaussian Quadrature formulas


Gaussian Quadrature
1
Gauss derived a formula which is used to evaluate the integral of the form  F u  du.
1

One point Gaussian Formula


1

The one point Gaussian formula is given by  f x  dx  2. f 0 which is exact for
1
polynomials of degree up to 1.

Two point Gaussian Formula

47
1
 1  1
The two point Gaussian formula is 1 f  x  dx  f 
  
  f  
 3  and this is exact
 3   
for polynomial of degree up to 3.

Three point Gaussian Formula

5  3  3 
1

 f x  dx  9 f 0  9  f  
8
The three point Gaussian formula is  f  
1   5   5 

which is exact for polynomial of degree up to 5.
Note:
b 1
(i) The integral  F t  dt , can be transformed into
a
 f x  dx by the linear
1

transformation.
 b  a x  b  a 
t  .
 2
b 1
(ii) The integral  F x  dx , can be transformed into
a
 f t  dt by the linear
1

transformation.
 b  a t  b  a 
x  .
 2

Example: 1
1
dx
Evaluate 1 x
1
2
by two point and three point Gaussian formula and compare with

exact value.
Solution
1
 1  1
By two point Gaussian formula,  f x  dx  f   
3 
f 
3


1   

Given f x  
1
.
1 x2

 1 1 3
 f   
 
 3 1 4
1
3

 1 1 3
 f  
 
 3  1 1 4
3

48
1
  f x  dx 
3 3 6
   1.5
1
4 4 4
1
 f x  
1
1 x
1
2
dx  1.5 .

5  3  3 
1

 f x  dx  9 f 0  9  f  
8
By three point Gaussian formula,  f  
1   5  
 5 

f 0 
1
1
1 0

 3 1 5
 f   
 
 5 3 8
1
5

 3 1 5
 f  
 
 5  1 3 8
5

5 5 5 
1
  f x  dx 
8
1    
1
9 9 8 8 

8 5 10
  
9 9 8
1
  f x  dx  1.5833 .
1

But exact value is


1 1
dx dx
11  x 2  20 1  x 2

 
 2 tan 1 x  0
1

 2tan 1  tan 0


1 1

 
 2  0 
4 


2
1
dx
1 x
1
2
 1.5708 .

Thus, exact value is 1.5708.


By Gaussian two point formula value is 1.5.
49
By Gaussian three point formula value is 1.5833.
Example: 2
1
x2
Using three point Gaussian Quadrature formula, evaluate  dx .
1 1  x
4

Solution

5  3  3 
1
f x  dx  f 0   f  
8
Three point Gaussian Quadrature formula is  9  
 f
5 

 5 
1
9  
1
x2
Given  dx
1 1  x
4

x2
Here f x  
1 x4

 f 0 
0
0
1 0

3
 3 15
f    5 2 
 5  3 34
1 2
5
Similarly,

 3  15
f  
 34
 5 

5  3  3 
1
f x  dx  f 0   f  
8
 9  
 f
5 

 5 
1
9  

8 5  15 15 
 0   
9 9  34 34 

1
x2
 dx  0.4902 .
11  x
4

Double integrals using Trapezoidal and Simpson’s Rules


b d
We shall evaluate double integral I    f x, y  dx dy using Trapezoidal and
a c

Simpson’s rule.

The formula for the evaluation of a double integral can be obtained by repeatedly
applying the Trapezoidal and Simpson’s rules.

50
Trapezoidal Rule for Double Integral

The formula for the evaluation of double integral using Trapezoidal rule is,

sum of the values at four corner of the box   


hk 
I  2sum of the values at the boundary of the box except the corner   
4
4sum of the remaing values  

where h – length of x values and k – length of y values.

Simpson’s Rule for Double Integral

The formula for the evaluation of double integral using Simpson’s rule is,

sum of the values at four corner of the box   


hk 
I  4sum of the values at the boundary of the box except the corner   
9
16sum of the remaing values  

where h – length of x values and k – length of y values.

Example: 1

2 2
Evaluate   f x, y  dx dy by Trapezoidal rule for the following data:
0 0

x 0 0.5 1 1.5 2

0 2 3 4 5 5

1 3 4 6 9 11

2 4 6 8 11 14

Solution

Here, h = 0.5, k = 1.

2 2
 I    f x, y  dx dy
0 0

By Trapezoidal rule,
51
sum of the values at four corner of the box   
hk 
I  2sum of the values at the boundary of the box except the corner   
4
4sum of the remaing values  


0.5  1 2  5  14  4  23  4  5  11  11  8  6  3  44  6  9
4

I = 25.375.

Example: 2

1 1
1 1
Using Simpson’s
3
rule evaluate   1  x  y dx dy taking h = k = 0.5.
0 0

Solution

x = 0, 0.5, 1; y = 0, 0.5, 1. The table values are

x 0 0.5 1

0 1 0.6667 0.5

0.5 0.6667 0.5 0.4

1 0.5 0.4 0.3333

Let

1
gy  
1
dx dy
0
1  x  y

By Simpson’s rule,

sum of the values at four corner of the box   


hk 
I 4sum of the values at the boundary of the box except the corner   
9 
16sum of the remaing values  

g 0 
0.5
1  0.5  40.6667  1.5  2.66668
3

g 0  0.69441889 .

g 0.5 
0.5
0.6667  0.4  3.0667  40.5
3
52
g 0.5  0.51111 .

g 1 
0.5
0.5  0.3333  40.4
3

g 1  0.405538 .

Hence

1
I   g  y  dy
0


0.5
0.9441889  0.405538  40.51111
3

I  0.5241.
3.7 Weddle’s Rule
Put n = 6 in Newton-Cot’s Quadratic formula and neglecting all differences of orders
higher than sixth, we get
x 0  nh

 f (x)dx  10 y0  5y1  y 2  6y3  y 4  5y5  y6   y6  5y7  y8  6y9  y10  5y11  y12 
3h
x0

   y n6  5y n5  y n4  6y n3  y n2  5y n1  y n 

This equation is called Weddle’s rule.


x5  x 0  5h

Example: 1
1
dx
Evaluate  1  x using Weddle’s rule with 6 equal intervals.
0

Solution
1
Here n = 6,  h  ,
6
1 1 2 3 6
Let y  f ( x )   x  0, , , ,, .
1 x 6 6 6 6

x 0 1 2 3 4 5 1
6 6 6 6 6
1 1 0.8571 0.75 0.667 0.6 0.5455 0.5
y
1 x

53
By Weddle’s rule,
1
 1  x dx  10 y 0  5y1  y 2  6y3  y 4  5y5 
1 3h
0

1
3 
   1  5(0.8571)  0.75  6(0.6667)  0.6  5(0.5455  0.5
6
10
= 0.69320.
3.8 Newton’s – Cote’s Formula (or) Cote’s Formula
b
Newton’s-Cote’s formula gives a way for computing the integral  f ( x )dx
a

numerically, when y = f(x) is known at equidistance values of x, but its derivation is based
on the integration of Lagrange’s interpolation formula.
b n n
 f (x)dx  h  y k  C k (u)du
a k 0 0

Where C k (u )  (1) n k u k . n  u nk


k!(n  k )!
Here Ck (u ) is a polynomial of degree n equation is called the cote’s polynomial.
Example: 1
Find the Cote’s polynomials for n=1.
Solution
The Cote’s polynomials are C0(u) and C1(u)

C k (u )  (1) n k
u k . n  u nk
k!(n  k )!
Put n = 1 and k = 0 in Ck (u )

C 0 (u ) 
u 0 . 1  u 1  u  1.
0!(1  0)!

C1 (u ) 
u 1. 1  u 0  u.
1!(1  1)!
Example: 2
Find the Cote’s polynomials for n=2.
Solution

C k (u )  (1) n k
u k . n  u nk
k!(n  k )!

54
C 0 (u ) 
u 0 . 2  u 2
0!(2  0)!
(2  u )(1  u )

2
2  3u  u 2

2

C (u ) 
u  . 2  u 
1 1

1!(2  1)!
1

u (2  u )

1
= 2u-u2

C 2 (u ) 
u 2 . 2  u 0
2!(2  2)!
u (u  1)

2
 u  u2
C2 (u)  .
2

Exercises:

2
dx
1. Evaluate the integral 1 x
1
2
using Trapezoidal rule with two subintervals.


2
2. Dividing the range into 10 equal parts, find the value of  sin x dx by (i) Trapezoidal rule
0

(ii) Simpson’s rule.


1
3. Using Simpson’s one third rule evaluate  xe
x
dx taking 4 intervals. Compare your result
0

with actual value.


0.7

e
x
4. Calculate x dx taking 5 ordinates by Simpson’s rule.
0.5
2
dx
5. Evaluate x
0
2
4
using Romberg’s method. Hence, obtain an approximate value of π.


6. Using Romberg’s method, Evaluate  sin x dx correct to four decimal places.
0
1
1
7. Using three point Gaussian Quadrature formula, Evaluate  dt .
0 1 t
2

55
x 2  2x  1
2
8. Evaluate  1  x  1
0
4
dx by Gaussian three point formula.

1.5

e
 x2
9. Evaluate dx using the three point Gaussian Quadrature.
0.2
1
dx
10. Evaluate  1  x by Gaussian formula with two points.
0
5
1
11. Use Gaussian three point formula and evaluate  dx .
1
x

 3x   3x 
1 1
12. Using Gaussian three point formula, evaluate (i) 2
 5 x 4 dx (ii) 2
 5 x 4 dx .
1 0

Also compare with exact values.


2 x

13. Evaluate e
2
2
dx by Gaussian two point formula.

1 2
2 xy
14. Evaluate   1  x 1  y  dx dy by Trapezoidal rule with h = k = 0.25.
0 1
2 2

2 2
dx dy
15. Evaluate  x
1 1
2
 y2
numerically with h = 0.2 along x direction and k = 0.25 along y

direction.
3 2
16. The function f(x, y) is defined by the following table. Compute   f x, y  dx dy using
1 0

Simpson’s rule in both direction.

x 0 0.5 1 1.5 2

1 2 1.5 1.3 1.4 1.6

2 3.1 2.5 2 2.3 2.9

3 4.2 4 3.8 4.1 4.4


6
dx
17. Apply Weddle’s rule to evaluate the approximate value of the integral  1 x2 by
0

dividing the range into 6 equal parts.


18. Compute Cote’s polynomials for n = 3, 4, 5 and 6.
19. Compute Cote Numbers for n=1, 2, 3, 4, 5 and 6.
20. Verify that sum of Cote’s Numbers is 1 for n=1, 2, 3, 4, 5 and 6.

56

You might also like