0% found this document useful (0 votes)
30 views11 pages

Numerics Hawassa Num Chap 6 Edited

Uploaded by

brolali904
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)
30 views11 pages

Numerics Hawassa Num Chap 6 Edited

Uploaded by

brolali904
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/ 11

CHAPTER VI

Numerical Differentiation and Integration


Numerical Differentiation
Numerical differentiation is a process of computing derivatives of a function f (x ) at
some desired values of x, when the function is defined by a set of tabulated data.
For this, we first replace the exact relation y  f (x) by the best interpolating formula
and then
dy
If the values of x are equidistant and is
dx
i. required near the beginning of the data we employ Newton’s forward formula
ii. required near the end of the data we employ Newton’s backward formula
If the values of x are not equidistant we use Lagrange’s formula as an interpolating
polynomial.
Derivative using Newton’s forward formula
u u (u  1) 2 u (u  1)(u  2) 3
y  y 0  y 0   y0   y0
1! 2! 3!
u (u  1)(u  2)(u  3) 4
  y 0  ....
4!
x  x0
where x  x 0  uh  u 
h

dy dy du 1 dy
  
dx du dx h du
1 2u  1 2 3u 2  6u  2 3 4u 3  18u 2  22u  6 4 
 y 0   y0   y0   y 0  
h 2 3! 4! 

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


and    y 0   y 0   y 0  
dx2 h 2  3! 4! 
d 3x d 4x
Similarly we can proceed to obtain , ,...
dx 3 dx 4

dy d2y
If we want to find and 2
at exactly x  x0  u  0
dx dx

1
dy 1 1 1 1 
 y0  2 y0  3 y0  4 y0  .......
dx x  x 0
h 2 3 4 

d2y 1  2 11 4 5 5 
 2 
 y 0  3
y 0   y 0   y0  .......
dx2 x  x0
h  12 6 

Derivative using Newton’s backward formula


u u (u  1) 2 u (u  1)(u  2) 3
y  y n  y n   yn   yn
1! 2! 3!
u (u  1)(u  2)(u  3) 4
  y n  ....
4!
x  xn
where x  x n  uh  u 
h

dy dy du 1 dy
  
dx du dx h du
1 2u  1 2 3u 2  6u  2 3 4u 3  18u 2  22u  6 4 
 y n   yn   yn   y n  
h 2 3! 4! 

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


and 2
 2 
 y n   y 0   y0  
dx h  3! 4! 
d 3x d 4x
Similarly we can proceed to obtain , ,...
dx 3 dx 4

dy d2y
If we want to find and at exactly x  x n  u  0
dx dx 2
dy 1 1 1 1 
 y n   2 y n  3 y n   4 y n  .......
dx x x h 2 3 4 
n

d2y 1  2 3 11 4 5 5 
  y n   y n  12  y n  6  y n  .......
dx 2 x xn h2

dy d2y
Example: - Evaluate and at x  1.2 , x  2 & x  2.2 from the following table.
dx dx 2

2
x 1.0 1.2 1.4 1.6 1.8 2.0 2.2
y 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250

Solution: - Forming the difference table

2 3 4 5 6
x y Dy Dy Dy Dy Dy Dy
1 2.7183
0.6018
1.2 3.3201 0.1333
0.7351 0.0294
1.4 4.0552 0.1627 0.0067
0.8978 0.0361 0.0013
1.6 4.953 0.1988 0.008 0.0001
1.0966 0.0441 0.0014
1.8 6.0496 0.2429 0.0095
1.3395 0.0535
2 7.3891 0.2964
1.6359
2.2 9.025
2 3 4 5 6
x y Vy Vy Vy Vy Vy Vy

dy 1 1 1 1 1 
 y0  2 y0  3 y0  4 y0  5 y0   3.32032
dx x1.2 h  2 3 4 5 

dy 1 1 1 1 
 y5   2 y5   3 y5   4 y5   5 y   7.3895
dx x2 h  2 3 4 5 
dy 1 1 1 1 
 y6   2 y6   3 y6   4 y6   5 y   6 y   9.8562
dx x2.2 h  2 3 4 6 6

Exercise: -
1. Given that

x 1.0 1.1 1.2 1.3 1.4 1.5 1.6


y 7.989 8.404 8.781 9.129 9.451 9.750 10.031

dy d2y
find the values of and at x  1.1 , 1.6 and 1.5
dx dx 2

3
2. Find the first and the second derivatives of the function tabulated below at tpoints
x  1.1 and 1.9

x 1.0 1.2 1.4 1.6 1.8 2.0


y 0.000 0.128 0.544 1.296 2.432 4.000

3. A slider n a machine moves along a fixed straight rod. Its distance y cm. along the
rod is given below for various values of the time t seconds. Find the velocity and
acceleration of the slider when t  0.1 , 0.5 and 0.6 seconds.

x 0.0 0.1 0.2 0.3 0.4 0.5 0.6


y 30.13 31.62 32.87 33.64 33.95 33.81 33.24

Numerical Integration
The process of integrating a definite integral from a set of tabulated values of the
integrand f(x) is called Numerical Integration. This process when applied to a function
of one variable is called Quadrature formula. In particular, this process can be used for
those definite integrals that have no explicit antiderivative or whose antidervative is not
easy to obtain.

e x sin x cos(x  3)
6 1 2
Like,  e  x dx ,  cos(x )dx , 1 ln x tan( x  3) dx , etc.
2
2

0 0

To apply numerical integration, we first represent f(x) by interpolation formula, for this
case we use Newton Forward Difference Interpolation Formula.

2 y 0 3 y 0 n y 0
f ( x)  y 0  uy 0  u (u  1)  u (u  1)(u  2)  ........u (u  1)(u  2)....(u  (n  1))
2! 3! n!
x  x0
where u 
h
b
Let I   f ( x)dx
a
Dividing the interval [a, b] into n subintervals of width h we form the following table

x x0 x1 x2 x3 …………. xn
y=f(x) y0 y1 y2 y3 …………. yn

4
Where xi  x0  ih , i  0, 1, 2, 3, 4, ...........

Trapezoidal Rule
b
To approximate  f ( x)dx
a
using this rule, we first divide [a, b] into subintervals of step

size h with xi  x0  ih , i  0, 1, 2, 3, 4, ........... and form the table of values as follow

x x0 x1 x2 x3 …………. xn
y=f(x) y0 y1 y2 y3 …………. yn

For each interval [xi, xi+1] i=0, 1, 2, 3…, we approximate f(x) by a linear forward
difference interpolation formula
y

f(x)

…………

x
a=x0 x1 x2 x3 x4 xn-1 xn

b xn x1 x2 x3 xn


a
f ( x)dx  
x
f ( x)dx  
x
f ( x)dx  
x
f ( x)dx  
x
f ( x)dx  .....
x
 f ( x)dx ...... (1)
0 0 1 2 n 1
x1

To evaluate x f ( x)dx
0
x  x0  uh  dx  hdu
x  x0  u  0 and x  x1  x0  h  u  1
1
 u2 
x1
  h
1
1

x0
f ( x)dx  h  ( y 0  uy 0 )du  h  y 0 u  y 0  h  y 0  y 0   [ y 0  y1 ]
0  2 0  2  2
x1
h
 f ( x)dx  2 [ y
x
0  y1 ] .................... (2)
0

5
To evaluate
x2

 f ( x)dx
x1

x  x1  uh  dx  hdu
x  x1  u  0 and x  x 2  u  1
x2 1
1
 u2   1  h
x f ( x)dx  h0 ( y1  uy1 )du  h y1u  y1 2  h y1  2 y1   2 [ y1  y 2 ]
1 0
x2
h
 f ( x)dx  2 [ y
x
1  y 2 ] .................... (3)
1
Similarly

x3
h
 f ( x)dx  2 [ y
x2
2  y3 ] .................... (4)

x4
h
 f ( x)dx  2 [ y
x3
3  y 4 ] .................... (5)

.
.
.
xn
h
x
 f ( x) dx 
2
[ y n 1  y n ] ..............
n 1

Substituting the results of (2), (3), (4)…, into (1) we get

b xn
h
 f ( x)dx  x f ( x)dx  2 [( y
a
0  y n )  2( y1  y 2  y3  ..... y n1 )
0

And this is known as Trapezoidal Rule. This formula gives exact value if f(x) is a

polynomial function of degree at most 1.

6
Simpson’s 1/3 Rule
b
To approximate  f ( x)dx
a
using this rule subdivide [a, b] into an even number of equally

space subintervals.

x x0 x1 x2 x3 x4 …………. xn-2 xn-1 xn


y=f(x) y0 y1 y2 y3 y4 …………. yn-2 yn-1 yn

f(x)

..………..

x
a=x0 x2 x4 xn-2 b= xn

For each interval [x2i, x2i+2], i = 0, 1, 2…, we approximate f(x) by a quadratic Newton
Forward Difference Interpolating Polynomial.

For this

b xn x2 x4 x6 xn

 f ( x)dx  x f ( x)dx  x f ( x)dx  x f ( x)dx  x f ( x)dx  ...... x  f ( x)dx


a
...... (1)
0 0 2 4 n2

x2

To evaluate  f ( x)dx
x0

x  x0  uh  dx  hdu
x  x0  u  0 and x  x2  u  2

7
x2
u (u  1) 2
2
h
 f ( x)dx  h  ( y
x 0
0  uy 0 
2!
 y 0 )du  [ y 0  4 y1  y 2 ]
3
........ (2)
0
x4

To evaluate  f ( x)dx
x2

x  x 2  uh  dx  hdu
x  x 2  u  0 and x  x 4  u  2
x4
u (u  1) 2
2
h
 f ( x)dx  h  ( y
x 0
2  uy 2 
2!
 y 2 )du  [ y 2  4 y 3  y 4 ]
3
........ (3)
2

Similarly
x6
h
x f ( x)dx  3 [ y 4  4 y5  y6 ] .............. (4)
4
.
.
xn
h
x
 f ( x)dx  3 [ y n2  4 y n 1  y n ]
n2

Substituting the results of (2), (3), (4)…, in (1) we get

b xn
h
 f ( x)dx  x f ( x)dx  3 [( y
a
0  y n )  4( y1  y3  ..... y n1 )  2( y 2  y 4  ..... y n2 )
0
and this is Simpson ' s 1 / 3 Rule

Note: - This rule requires the division of [a, b] in to an even number of subintervals of
width h and this formula gives exact value if f(x) is a polynomial function of degree at
most 2.

Simpson’s 3/8 Rule


b
To approximate  f ( x)dx
a
using this rule subdivide [a, b] into equal subintervals of

number multiple of 3.

x x0 x1 x2 x3 x4 x5 x6 …………. xn-3 xn-2 xn-1 xn


y=f(x) y0 y1 y2 y3 y4 y5 y6 …………. yn-3 yn-2 yn-1 yn

8
y

f(x)

..………..

x
a=x0 x3 x6 xn-3 b= xn

For each interval [x3i, x3i+3], i = 0, 1, 2…, we approximate f(x) by Newton Forward
Difference Interpolating Polynomial of degree 3.

For this
b xn x3 x6 x9 xn

 f ( x)dx  x f ( x)dx  x f ( x)dx  x f ( x)dx  x f ( x)dx  ...... x  f ( x)dx


a
...... (1)
0 0 3 6 n 3
x3

To evaluate  f ( x)dx
x0

x  x0  uh  dx  hdu
x  x0  u  0 and x  x3  u  3
x3
u (u  1) 2 u (u  1)(u  2) 3
3
3

x
f ( x)dx  h  ( y 0  uy 0 
0
2!
 y0 
3!
 y 0 )du  h[ y 0  3 y1  3 y 2  y 3 ] ........(2)
8
0
x6

To evaluate  f ( x)dx
x3

x  x3  uh  dx  hdu
x  x3  u  0 and x  x6  u  3
x6
u (u  1) 2 u (u  1)(u  3) 3
3
3

x
f ( x)dx  h  ( y 3  uy 3 
0
2!
 y3 
3!
 y 3 )du  h[ y 3  3 y 4  3 y 5  y 6 ]........(3)
8
3

Similarly
x6
3
 f ( x)dx  8 h[ y
x
6  3 y 7  3 y8  y 9 ] ............. (4)
3
.
.

9
.
xn
3
x
 f ( x)dx  8 h[ y n 3  3 y n  2  3 y n 1  y n ] .............
n 3

Substituting the results of (2), (3), (4)…, in (1) we get

b xn

 f ( x)dx  x f ( x)dx
a 0
3h

[( y 0  y n )  3( y1  y 2  y 4  y5  ..... y n  2  y n 1 )  2( y3  y 6  ..... y n 3 )
8
and this is Simpson ' s 3 / 8 Rule

Note: - While applying Simpson’s 3/8 rule the number of subintervals should be taken as
multiple of 3 and this formula give exact value if f(x) is a polynomial function of degree
at most 3.

Remark: - In every rule accuracy could be increased by decreasing the step size h.

6
dx
Example: - By considering six subintervals evaluate  , using
0 1  x 2

a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule

60 1
Solution: - Dividing [0, 6] into 6 subintervals means h   1 . And f ( x) 
6 1 x2
x 0 1 2 3 4 5 6
y = f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027

6
dx h
a. 1 x
0
2
 [( y0  y 6 )  2( y1  y 2  y3  y 4  y5 )]  1.4108
2
6
dx h
b. 1 x
0
2
 [( y0  y6 )  4( y1  y3  y5 )  2( y 2  y 4 )  1.3662
3
6
dx
3h
c.
0
1 x
8 2

[( y0  y6 )  3( y1  y 2  y 4  y5 )  2( y3 )  1.3571

And from the following table we can see that accuracy in each method increases as h
decrease.
6
dx
Exact solution of   [tan 1 x]60  tan 1 6  1.40564765
0 1 x
2

10
n h Trapezoidal Simpson’s 1/3 Simpson’s 3/8
6 1 1.41079867 1.3661735 1.3570808
12 0.5 1.40547621 1.403702 1.3996111
24 0.25 1.40560222 1.4056442 1.4055574
48 0.125 1.40563631 1.4056478 1.4056478

1
dx
Example: - Evaluate 1 x
0
using Simpson’s 1/3 rule for h = 0.25.

Solution: -
x 0 0.25 0.50 0.75 1.00
y = f(x) 1 0.8 0.6667 0.5714 0.5

1
dx h
 1  x  3 [( y
0
0  y 4 )  4( y1  y3 )  2 y 2  0.69325399

And from the following table we can see that accuracy in each method increases as h
decrease.
1
dx
Exact solution of   [ln(1  x)]10  ln 2  0.693147181
0
1  x

n h Trapezoidal Simpson’s 1/3 Simpson’s 3/8


3 1/3 0.699999 0.69374996
4 0.25 0.697023809 0.69325399
5 0.2 0.69563496
6 1/6 0.69487738 0.69316983 0.69319534
12 1/12 0.693580866 0.69314873 0.69315046
24 1/24 0.69325578 0.69314724 0.69314742
48 1/48 0.693174362 0.69314718 0.6931473

Exercise: -
6
1. Evaluate  e  x dx using Simpson’s 1/3 rule for h = 1.
2

0
2

x
3
2. Evaluate cos x 2 dx for h = 0.5 using
1
a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule.

11

You might also like