CH 6 - Application of Interoplations

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

Wolaita Sodo University

College of Natural & Computational Science


Department of Mathematics

Numerical Analysis I

Prepared By
Biruk Endeshaw Mekonnen

March 8, 2021
Chapter 6

Numerical Differentiation and Integration


6.1 INTRODUCTION
The differentiation and integration are losely linked processes which are actually inversely
related. For example, if the given function y(t) represents an objects position as a function of
time, its differentiation provides its velocity,

d
v(t) = y(t)
dt
On the other hand, if we are provided with velocity v(t) as a function of time, its integration
denotes its position. Z t
y(t) = v(t) dt
0

There are so many methods available to find the derivative and definite integration of a func-
tion. But when we have a complicated function or a function given in tabular form, they we
use numerical methods. In the present chapter, we shall be concerned with the problem of
numerical differentiation and integration.

6.2 NUMERICAL DIFFERENTIATION


The method of obtaining the derivatives of a function using a numerical technique is known
as numerical differentiation. There are essentially two situations where numerical differenti-
ation is required.
They are:

1. The function values are known but the function is unknown, such functions are called
tabulated function.

2. The function to be differentiated is complicated and, therefore, it is difficult to differen-


tiate.

The choice of the formula is the same as discussed for interpolation if the derivative at a point
near the beginning of a set of values given by a table is required then we use Newton’s forward
interpolation formula, and if the same is required at a point near the end of the set of given
tabular values, then we use Newton’s backward interpolation formula. The central difference
formula (Bessel’s and Stirling’s) used to calculate value for points near the middle of the set
of given tabular values. If the values of x are not equally spaced, we use Newton’s divided
difference interpolation formula or Lagrange’s interpolation formula to get the required value
of the derivative.

Prepared By:- Biruk E.(Assi. Professor)


112 Chapter 6. Numerical Differentiation and Integration

6.2.1 Derivatives Using Newton’s Forward Interpolation Formula

Consider the data (xi , f (xi )) given at equispaced points xi = x0 + ih, i = 0, 1, 2, . . . , n where h
is the step length. The Newton’s forward Interpolation formula is given by

u(u − 1) 2 u(u − 1)(u − 2) 3 u(u − 1) · · · (u − (n − 1)) n


y = y0 + u∆y0 + ∆ y0 + ∆ y0 + · · · + ∆ y0
2! 3! n!
u2 − u 2 u3 − 3u2 + 2u 3 u4 − 6u3 + 11u2 − 6u 4
= y0 + u∆y0 + ∆ y0 + ∆ y0 + ∆ y0
2! 3! 4!
u5 − 10u4 + 35u3 − 50u2 + 24u 5
+ ∆ y0 + · · · (6.1)
5!

where u = x−x h
0

Differentiating equation (6.1) with respect to x, we get

dy dy du 1 dy
= =
dx du dx h du
dy 1 2u − 1 2 3u2 − 6u + 2 3 4u3 − 18u2 + 22u − 6 4
= ∆y0 + ∆ y0 + ∆ y0 + ∆ y0
dx h 2! 3! 4!
5u4 − 40u3 + 105u2 − 100u + 24 5

+ ∆ y0 + · · · (6.2)
5!

Again differentiating equation (6.2) with respect to x, we get

d2 y
   
d dy du 1 d dy
= = ×
dx2 du dx dx h du dx
12u2 − 36u + 22 4

1 6u − 6 3
= 2 ∆2 y0 + ∆ y0 + ∆ y0
h 3! 4!
20u3 − 120u2 + 210u − 100 5

+ ∆ y0 + · · · (6.3)
5!

and so on.
Equations (6.2) & (6.3) give the approximate derivatives of f (x) at arbitrary point x = x0 + uh.
When x = x0 , u = 0, Eqs.(6.2) and (6.3) becomes
   
dy 0 1 1 2 1 3 1 4
= f (x0 ) = ∆y0 − ∆ y0 + ∆ y0 − ∆ y0 + · · · (6.4)
dx x=x0 h 2 3 4
 2   
dy 00 1 2 3 11 4 5 5
and = f (x0 ) = 2 ∆ y0 − ∆ y0 + ∆ y0 − ∆ y0 + · · · (6.5)
dx2 x=x0 h 12 6

and so on.
dy d2 y
Example 6.1. Find the value of dx and dx2 at x = 0.1 from the following table:

x 0.1 0.2 0.3 0.4


y 0.9975 0.9900 0.9776 0.9604

Solution: The forward difference table is

Prepared By:- Biruk E.(Assi. Professor)


6.2. NUMERICAL DIFFERENTIATION 113

x y ∆y ∆2 y ∆3 y
0.1 0.9975
-0.0075
0.2 0.9900 -0.0049
-0.0124 0.0001
0.3 0.9776 -0.0048
-0.0172
0.4 0.9604

We have h = 0.1, x0 = 0.1, and u = x−xh . For x = 0.1, we get u = 0.


0

Therefore,
   
dy 1 1 2 1 3
= ∆y0 − ∆ y0 + ∆ y0
dx x=x0 h 2 3
 
1 1 1
= − 0.0075 − (−0.0049) + (0.0001) = −0.050167.
0.1 2 3

Example 6.2. The table given below reveals the velocity ‘v’of a body during the time ‘t ’specified.
Find its acceleration at t = 1.1.
t: 1.0 1.1 1.2 1.3 1.4
v: 43.1 47.7 52.1 56.4 60.8

Solution: The difference table is:


t v ∆v ∆2 v ∆3 v ∆4 v
1.0 43.1
4.6
1.1 47.7 -0.2
4.4 0.1
1.2 52.1 -0.1 0.1
4.3 0.2
1.3 56.4 0.1
4.4
1.4 60.8

Let t0 = 1.1, y0 = 47.7 and h = 0.1


Acceleration at t = 1.1 is given by
   
dv 1 1 2 1 3
= ∆v0 − ∆ v0 + ∆ v0
dt t=t0 h 2 3
 
1 1 1
= 4.4 − (−0.1) + (0.2)
0.1 2 3
= 45.1667.

Hence the required acceleration is 45.1667.

Prepared By:- Biruk E.(Assi. Professor)


114 Chapter 6. Numerical Differentiation and Integration

Example 6.3. Find f 0 (1.1) and f 00 (1.1) from the following table:

x 1.0 1.2 1.4 1.6 1.8 2.0


f (x) 0 0.1 0.5 1.25 2.4 3.9

Solution: We first construct the forward difference table as shown below

x y ∆f (x) ∆2 f (x) ∆3 f (x) ∆4 f (x) ∆5 f (x)


1.0 1
0.1
1.2 0.1 0.3
0.4 0.05
1.4 0.5 0.35 0
0.75 0.05 0
1.6 1.25 0.40 0
1.15 0.05
1.8 2.40 0.45
1.5
2.0 3.9

Since x = 1.1 is a non-tabulated point near the beginning of the table, we take x0 = 1.0 and
compute u = x−x h =
0 1.1−1.0
0.2 = 0.5.

3u2 − 6u + 2 3
 
0 1 2u − 1 2
Hence, f (x) = ∆f (x0 ) + ∆ f (x0 ) + ∆ f (x0 )
h 2! 3!
3(0.5)2 − 6(0.5) + 2
 
1
f 0 (1.1) = 0.1 + 0 + (0.05)
0.2 6
= 0.4895
 
1 6u − 6 3
f 00 (x) = 2
∆ f (x0 ) + ∆ f (x0 )
h2 3!
 
1 6(0.5) − 6
f 00 (1.1) = 0.3 + (0.05)
(0.2)2 6
= 6.875.

6.2.2 Derivatives Using Newton’s Backward Interpolation Formula

Consider the data (xi , f (xi )) given at equispaced points xi = x0 +ih, where h is the step length.
The Newton’s backward interpolation formula is given by

u(u + 1) 2 u(u + 1)(u + 2) 3 u(u + 1) · · · (u + (n − 1)) n


y = yn + u∇yn + ∇ yn + ∇ yn + · · · + ∇ y0
2! 3! n!
u2 + u 2 u3 + 3u2 + 2u 3 u4 + 6u3 + 11u2 + 6u 4
= yn + u∇yn + ∇ yn + ∇ yn + ∇ yn
2! 3! 4!
u5 − 10u4 + 35u3 − 50u2 + 24u 5
+ ∇ yn + · · · (6.6)
5!
Prepared By:- Biruk E.(Assi. Professor)
6.2. NUMERICAL DIFFERENTIATION 115

where u = x−x h
n

Differentiating equation (6.6) with respect to x, we get

3u2 + 6u + 2 3 4u3 + 18u2 + 22u + 6 4



dy 1 2u + 1 2
= ∇yn + ∇ yn + ∇ yn + ∇ yn
dx h 2! 3! 4!
5u4 + 40u3 + 105u2 + 100u + 24 5

+ ∇ y0 + · · · (6.7)
5!

Again differentiating equation (6.7) with respect to x, we get

d2 y 12u2 + 36u + 22 4

1 2 6u + 6 3
= ∇ yn + ∇ y n + ∇ yn
dx2 h2 3! 4!
20u3 + 120u2 + 210u + 100 5

+ ∇ y0 + · · · (6.8)
5!

and so on.
Equations (6.7) and (6.8) can be used to determine the approximate differentiation of first,
second, etc. order at any point x, where x = xn + uh.
If x = xn , then u = 0.
Equations (6.7) and (6.8) become
 
0 1 1 2 1 3 1 4
f (xn ) = ∇yn + ∇ yn + ∇ yn + ∇ yn + · · · (6.9)
h 2 3 4
 
00 1 2 3 11 4 5 5
f (xn ) = 2 ∇ yn + ∇ yn + ∇ yn + ∇ yn + · · · (6.10)
h 12 4

dy d2 y
Example 6.4. Find dx and dx2 of y = ex + 1 at x = 2.5 from the following table:

x 1.0 1.5 2.0 2.5


y 3.7183 5.4817 8.3891 13.1825

Solution: The backward difference table is given below.

x y ∇y ∇2 y ∇3 y
1.0 3.7183
1.7634
1.5 5.4817 1.1440
2.9074 0.7420
2.0 8.3891 1.8860
4.7934
2.5 13.1825

We have h = 0.5, xn = 2.5, and u = x−x n


h . For x = 2.5, we get u = 0.

Prepared By:- Biruk E.(Assi. Professor)


116 Chapter 6. Numerical Differentiation and Integration

From the formula


   
dy 1 1 2 1 3
= ∇yn + ∇ yn + ∇ yn
dx x=xn h 2 3
 
1 1 1
= 4.7934 + (1.8860) + (0.7420)
0.5 2 3
 2  = 11.9675.
dy 1
= 2 ∇2 yn + ∇3 yn

2
dx x=xn h
1  
= 1.8660 + 0.7420
(0.25)2
= 10.5120.

dy d2 y
Example 6.5. From the following table, find the values of dx and dx2 at x = 2.03.

x 1.96 1.98 2.00 2.02 2.04


y 0.7825 0.7739 0.7651 0.7563 0.7473

Solution: The backward difference table is

x y ∇y ∇2 y ∇3 y ∇4 y
1.96 0.7825
-0.0086
1.98 0.7739 -0.0002
-0.0088 0.0002
2.00 0.7651 0 -0.0004
-0.0088 -0.0002
2.02 0.7563 -0.0002
-0.0090
2.04 0.7473

Here, xn = 2.04, h = 0.02 and u = x−x h . For x = 2.03, we get u = −0.5


n

Therefore,

3u2 + 6u + 2 3 4u3 + 18u2 + 22u + 6 4


 
0 1 2u + 1 2
y (x) = ∇yn + ∇ yn + ∇ yn + ∇ yn
h 2! 3! 4!
3(−0.5)2 + 6(−0.5) + 2

0 1
y (2.03) = − 0.0090 + 0 + (−0.0002)
0.02 6
4(−0.5)3 + 18(−0.5)2 + 22(−0.5) + 6

+ (−0.0004)
24
= −0.44875
12u2 + 36u + 22 4
 
00 1 2 6u + 6 3
y (x) = 2 ∇ yn + ∇ yn + ∇ yn
h 3! 4!
12(−0.5)2 + 36(−0.5) + 22
 
00 1
y (2.03) = − 0.0002 + (−0.5 + 1)(−0.0002) + (−0.0004)
(0.02)2 24
= −1.05

Prepared By:- Biruk E.(Assi. Professor)


6.2. NUMERICAL DIFFERENTIATION 117

Example 6.6. The distance covered by an athlete for the 50 meter race is given in the following
table:
T ime(sec) 0 1 2 3 4 5 6
Distance(meter) 0 2.5 8.5 15.5 24.5 36.5 50
Determine the speed of the athlete at t = 5 sec., correct to two decimals.

Solution: Here we are to find derivative at t = 5 which is near the end of the table, hence we
shall use the formula obtained from Newton’s backward difference formula. The backward
difference table is as follows:
t s ∇s ∇2 s ∇3 s ∇4 s ∇5 s ∇6 s
0 0
2.5
1 2.5 3.5
6 -2.5
2 8.5 1 3.5
7 1 -3.5
3 15.5 2 0 1
9 1 -2.5
4 24.5 3 -2.5
12 -1.5
5 36.5 1.5
13.5
6 50
The speed of the athlete at t = 5 sec is given by
   
ds 1 1 2 1 3 1 4 1 5
= ∇s5 + ∇ s5 + ∇ s5 + ∇ s5 + ∇ s5
dt t=5 h 2 3 4 5
 
1 1 1 1 1
= 12 + (3) + (1) + (0) + (−3.5)
1 2 3 4 5
= 13.1333 meter/sec.

6.2.3 Derivatives Using Stirling’s Interpolation Formula

If we want to determine the values of the derivatives of the function near the middle of the
given set of arguments. We may apply any central difference formula. Therefore using Stir-
ling’s formula, we get

u2 2 u3 − u ∆3 y−1 + ∆3 y−2
   
u ∆y0 + ∆y−1
f (x) = y0 + + ∆ y−1 +
1! 2 2! 3! 2
4 2
u − 5u + 4u ∆5 y−2 + ∆5 y−3
5 3
 
u −u 4
+ ∆ y−2 + + · · · (6.11)
4! 5! 2

Prepared By:- Biruk E.(Assi. Professor)


118 Chapter 6. Numerical Differentiation and Integration

Where u = x−xh
0

When Equation (6.11) is differentiated with respect to x successively, we obtain

3u2 − 1 ∆3 y−1 + ∆3 y−2


  
0 1 ∆y0 + ∆y−1 2
f (x) = + u∆ y−1 +
h 2 6 2
3
5u − 15u + 4 ∆ y−2 + ∆5 y−3
4 2
 5  
2u − u 4
+ ∆ y−2 + + ··· (6.12)
12 120 2
 3
∆ y−1 + ∆3 y−2 6u2 − 1 4
 
00 1 2
and f (x) = 2 ∆ y−1 + u + ∆ y−2
h 2 12
2u3 − 3u ∆5 y−2 + ∆5 y−3
  
+ + ··· (6.13)
12 2

At x = x0 , u = 0 and Equation (6.12) and (6.13) become

1 ∆y0 + ∆y−1 1 ∆3 y−1 + ∆3 y−2 1 ∆5 y−2 + ∆5 y−3


     
0
f (x0 ) = − + + ···
h 2 6 2 30 2
 
00 1 2 1 4 1 6
f (x0 ) = 2 ∆ y−1 − ∆ y−2 + ∆ y−3 + · · ·
h 12 90

Example 6.7. Find f 0 (0.6) and f 00 (0.6) from the following table:

x 0.4 0.5 0.6 0.7 0.8


f (x) 1.5836 1.7974 2.0442 2.3275 2.6510

Solution: Here, the derivatives are required at the central point x = 0.6, so we use Stirling’s
formula. The difference table is:

x f (x) ∆f (x) ∆2 f (x) ∆3 f (x) ∆4 f (x)


x−2 = 0.4 1.5836
0.2138
x−1 = 0.5 1.7974 0.0330
0.2468 0.0035
x0 = 0.6 2.0442 0.0365 0.0002
0.2833 0.0037
x1 = 0.7 2.3275 0.0402
0.3235
x2 = 0.8 2.6510

Her we have x0 = 0.6, x = 0.6, h = 0.1, u = x−x


h
0
= 0.6−0.6
0.1
=0
By using Stirling’s formula for derivatives, we get

1 ∆y0 + ∆y−1 1 ∆3 y−1 + ∆3 y−2


    
dy
= −
dx x=x0 h 2 6 2
     
dy 1 0.2468 + 0.2833 1 0.0035 + 0.0037
= +0− +0
dx x=0.6 0.1 2 6 2
= 10(0.26505 − 0.0006)

Prepared By:- Biruk E.(Assi. Professor)


6.2. NUMERICAL DIFFERENTIATION 119

f 0 (0.6) = 2.6445.
d2 y
   
1 2 1 4
= 2 ∆ y−1 − ∆ y−2
dx2 x=x0 h 12
 
1 1
= 0.0365 + 0 − (0.0002)
(0.1)2 12
= 100(0.0365 − 0.000016)
f 00 (0.6) = 3.6484.

Example 6.8. Compute the values of f 0 (3.1) and f 00 (3.1) using the following table.
x 1 2 3 4 5
f (x) 0 1.4 3.3 5.6 8.1
Solution: The central difference table is
x y = f (x) ∆y ∆2 y ∆3 y ∆4 y
x−2 = 1 0
1.4
x−1 = 2 1.4 0.5
1.9 -0.1
x0 = 3 3.3 0.4 -0.1
2.3 -0.2
x1 = 4 5.6 0.2
2.5
x2 = 5 8.1
3.1−3
Let x0 = 3, h = 1, u = 1
= 0.1

3u2 − 1 ∆3 y−1 + ∆3 y−2 2u3 − u 4


   
0 1 ∆y0 + ∆y−1 2
f (x) = + u∆ y−1 + + ∆ y−2
h 2 6 2 12
3(0.1)2 − 1 −0.1 − .2 2(0.1)3 − 0.1
   
0 1 1.9 + 2.3
f (1.6) = + (0.1)(0.4) + + (−0.1)
1 2 6 2 12
= 2.1 + 0.04 + 0.02425 + 0.00082
= 2.16507  3
∆ y−1 + ∆3 y−2 6u2 − 1 4
  
00 1 2
f (x) = 2 ∆ y−1 + u + ∆ y−2
h 2 12
6(0.1)2 − 1
   
1 −0.1 − 0.2
= 2 0.4 + 0.1 + (−0.1)
1 2 12
= 0.4 − 0.015 + 0.00783
= 0.39283.

Prepared By:- Biruk E.(Assi. Professor)


120 Chapter 6. Numerical Differentiation and Integration

6.2.4 Derivatives Using Newton’s Divided Difference Formula

The divided difference interpolation polynomial fitting the data (xi , f (xi )), i = 0, 1, 2, . . . , n is
given by

y = f (x) = y0 + (x − x0 )f [x0 , x1 ] + (x − x0 )(x − x1 )f [x0 , x1 , x2 ]+


· · · + (x − x0 )(x − x1 ) · · · (x − xn−1 )f [x0 , x1 , x2 , . . . , xn ] (6.14)

Differentiating Equation (6.14) with respect to x, we get

f 0 (x) = f [x0 , x1 ] + [(x − x0 ) + (x − x1 )]f [x0 , x1 , x2 ] + [(x − x1 )(x − x2 ) + (x − x0 )(x − x2 )


+ (x − x0 )(x − x1 )]f [x0 , x1 , x2 , x3 ] + [(x − x1 )(x − x2 )(x − x3 ) + (x − x0 )(x − x2 )(x − x3 )
+ (x − x0 )(x − x1 )(x − x3 ) + (x − x0 )(x − x1 )(x − x2 )]f [x0 , x1 , x2 , x3 , x4 ] + · · · (6.15)

If the derivative f 0 (x) is required at any particular point x = x∗ , then we substitute x = x∗ in


(6.15). If the data is equispaced, then the formula is simplified.
Differentiating Equation (6.15) again, we obtain

f 00 (x) = 2f [x0 , x1 , x2 ] + 2[(x − x0 ) + (x − x1 ) + (x − x2 )]f [x0 , x1 , x2 , x3 ]


+ 2[(x − x0 )(x − x1 ) + (x − x0 )(x − x2 ) + (x − x0 )(x − x3 ) + (x − x1 )(x − x2 )
+ (x − x1 )(x − x3 ) + (x − x2 )(x − x3 )]f [x0 , x1 , x2 , x3 , x4 ] + · · · (6.16)

If the second derivative f 00 (x) is required at any point x = x? , then we substitute x = x? in


(6.16). Again, if the data is equispaced, then the formula is simplified.

However, we can also determine the Newton’s divided differences interpolation polynomial
and differentiate it to obtain f 0 (x) and f 00 (x).
Example 6.9. Find the first and second derivatives at x = 1.6, for the function represented by
the following tabular data:

x 1.0 1.5 2.0 3.0


f (x) 0.0 0.40547 0.69315 1.09861
Solution: The data is not equispaced. We use the divided difference formulas to find the
derivatives. We have the following difference table:

x f (x) First d.d Second d.d Third d.d


1.0 0.0000
0.81094
1.5 0.40547 - 0.235580
0.57536 0.061157
2.0 0.69315 - 0.113267
0.40546
3.0 1.09861

Prepared By:- Biruk E.(Assi. Professor)


6.2. NUMERICAL DIFFERENTIATION 121

Substituting x = 1.6 in the formula

f 0 (x) = f [x0 , x1 ] + [(x − x0 ) + (x − x1 )]f [x0 , x1 , x2 ] + [(x − x1 )(x − x2 )


+(x − x0 )(x − x2 ) + (x − x0 )(x − x1 )]f [x0 , x1 , x2 , x3 ]
we obtain f 0 (1.6) = 0.81094 + [(1.6 − 1.0) + (1.6 − 1.5)](−0.23558) + [(1.6 − 1.5)(1.6 − 2.0)
+(1.6 − 1.0)(1.6 − 2.0) + (1.6 − 1.0)(1.6 − 1.5)](0.061157)
= 0.81094 + 0.7(−0.23558) − 0.22(0.061157) = 0.63258.

Substituting x = 1.6 in the formula

f 00 (x) = 2f [x0 , x1 , x2 ] + 2[(x − x0 ) + (x − x1 ) + (x − x2 )]f [x0 , x1 , x2 , x3 ]


we obtain f 00 (1.6) = 2(−0.23558) + 2[(1.6 − 1.0) + (1.6 − 1.5) + (1.6 − 2.0)](0.061157)
= −0.47116 + 0.03669 = −0.43447.

Remark 6.1. Often, in applications, we require the maximum and/ or minimum of a func-
tion given as a tabulated data. We may obtain the interpolation polynomial, differentiate it
and set it equal to zero to find the stationary points. Alternatively, we can use the numerical
differentiation formula for finding the first derivative, set it equal to zero to find the station-
ary points. The numerical values obtained for the second derivatives at these stationary points
decides whether there is a maximum or a minimum at these points.
Example 6.10. Find x for which y is maximum and find this value of y

x 1.2 1.3 1.4 1.5 1.6


y 0.9320 0.9636 0.9855 0.9975 0.9996

Solution: The Difference table is as follows:

x y ∆ ∆2 ∆3 ∆4
1.2 0.9320
0.0316
1.3 0.9636 -0.0097
0.0219 -0.0002
1.4 0.9855 -0.0099 0.0002
0.120 0
1.5 0.9975 -0.0099
0.0021
1.6 0.9996

Let y0 = 0.9320 and x0 = 1.2

Prepared By:- Biruk E.(Assi. Professor)


122 Chapter 6. Numerical Differentiation and Integration

By Newton’s forward difference formula

u(u − 1) 2
y = y0 + u∆y0 + ∆ y0 + . . .
2
u(u − 1)
= 0.9320 + 0.031u + (−0.0097) (Neglecting higher differences)
  2
dy 2u − 1
= 0.0316 + (−0.0097)
du 2

At a maximum,

dy
=0
du  
1
⇒ 0.0316 = u − (0.0097) ⇒ u = 3.76
2
∴ x = x0 + uh = 1.2 + (0.1)(3.76) = 1.576

To find ymax , we use backward difference formula,

x = xn + uh
⇒ 1.576 = 1.6 + (0.1)u ⇒ u = −0.24
u(u + 1) 2 u(u + 1)(u + 2) 3
y(1.576) = yn + u∇yn + ∇ yn + ∇ yn
2! 3!
(−0.24)(1 − 0.24)
= 0.9996 − (0.24 × 00021) + (−0.0099)
2
dy
= 0.9999988 = 0.9999nearly
du
∴ Maximum y = 0.9999. (Approximately)

PROBLEM SET 6.1

dy d2 y
1. From the following table find the value of dx and dx2 at the point x = 1.0.

x 1 1.1 1.2 1.3 1.4 1.5


[Ans. 1.7020, 5.4040]
y 5.4680 5.6665 5.9264 6.2551 6.6601 7.1488

dy d2 y
2. From the following table of values of x and y, obtain dx and dx2 for x = 1.2, 2.2 and 1.6

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

[Ans. y 0 (1.2) = 3.3205, y 00 (1.2) = 3.318; y 0 (2.2) = 9.0228, y 00 (2.2) = 8.992; y 0 (1.6) = 4.953, y 00 (1.6) =
4.9525]

3. A rod is rotating in a plane. The following table gives the angle θ(radians) through which
the rod has turned for various values of the time t (seconds).

Prepared By:- Biruk E.(Assi. Professor)


6.2. NUMERICAL DIFFERENTIATION 123

t 0 0.2 0.4 0.6 0.8 1.0 1.2


θ 0 0.12 0.49 1.12 2.02 3.20 4.67
Calculate the angular velocity and acceleration of the rod when t = 0.6 sec.
[Ans. (i) 3.82 radians/sec. (ii) 6.75 radians/sec2 ]

4. From the table below, for what value of x, y is minimum? Also find this value of y.
x 3 4 5 6 7 8
[Ans. 5.6875, 0.2628]
y 0.25 0.240 0.259 0.262 0.250 0.224

Prepared By:- Biruk E.(Assi. Professor)


124 Chapter 6. Numerical Differentiation and Integration

6.3 NUMERICAL INTEGRATION


Like numerical differentiation, we need to seek the help of numerical integration techniques
in the following situations:

1. Functions do not possess closed from solutions. Example:


Rx 2
f (x) = C 0 e−t dt.

2. Closed form solutions exist but these solutions are complex and difficult to use for cal-
culations.

3. Data for variables are available in the form of a table, but no mathematical relationship
between them is known as is often the case with experimental data.

6.4 NEWTON-COTES CLOSED QUADRATURE FORMULA


The general form of the problem of numerical integration may be stated as follows:
Given a set of data points (xi , yi ), i = 0, 1, 2, . . . , n of a function y = f (x), where f (x) is
not explicitly known. Here, we are required to evaluate the definite integral
Z b
I= y dx (6.17)
a

Here, we replace y = f (x) by an interpolating polynomial φ(x) in order to obtain an approxi-


mate value of the definite integral of Equation (6.17).
In what follows, we derive a general formula for numerical integration by using New-
ton’s forward difference formula. Here, we assume the interval (a, b) is divided into n-equal
subintervals such that
h = b−a
n
a = x0 < x1 < x2 < · · · < xn = b
with xn = x0 + nh
where h = the internal size
n = the number of subintervals
a and b = the limits of integration with b > a.
Hence, the integral in Equation (6.17) can be written as
Rx
I = x0n y dx
Using Newton’s forward interpolation formula, we have
xn  
u(u − 1) 2 u(u − 1)(u − 2) 3 u(u − 1)(u − 2)(u − 3) 4
Z
I= y0 +u∆y0 + ∆ y0 + ∆ y0 + ∆ y0 +· · · dx
x0 2! 3! 4!

where x = x0 + uh
Z n
u2 − u 2 u3 − 3u2 + 2u 3 u4 − 6u3 + 11u2 − 6u 4

I=h y0 + u∆y0 + ∆ y0 + ∆ y0 + ∆ y0 + · · · du
0 2! 3! 4!

Prepared By:- Biruk E.(Assi. Professor)


6.5. TRAPEZOIDAL RULE 125

Hence, after simplification, we get

xn
n(n − 2)2 3

n(2n − 3) 2
Z
n
I= y dx = nh y0 + ∆y0 + ∆ y0 + ∆ y0
x0 2 12 24
1 n4 3n3 11n2 1 n5 35n3 50n2
   
4 4
+ − + − 3n ∆ y0 + − 2n + − + 12n ∆5 y0
24 5 2 3 120 6 4 3
1 n6 5n5 225n3 274n2
  
4 6
+ − + 17n − + − 60n ∆ y0 + · · · (6.18)
720 7 2 4 3

The formula given by Equation (6.18) is known as Newton-Cotes closed quadrature formula.
From the general formula ((6.18)), we can derive or deduce different integration formulae by
substituting n = 1, 2, 3, . . ., etc.

6.5 TRAPEZOIDAL RULE


In this method, the known function values are joined by straight lines. The area enclosed by
these lines between the given end points is computed to approximate the integral as shown
in Figure 6.1.

Figure 6.1

Each subinterval with the line approximation for the function forms a trapezoid as shown in
Figure 6.1. The area of each trapezoid is computed by multiplying the interval size h by the
average value of the function value in that subinterval. After the individual trapezoidal areas
are obtained, they are all added to obtain the overall approximation to the integral.

Substituting n = 1 in Equation (6.18) and considering the curve y = f (x) through the points
(x0 , y0 ) and (x1 , y1 ) as a straight line (a polynomial of first degree so that the differences of
order higher than first become zero), we get
Z x1    
1 h 1 h
I1 = y dx = h y0 + ∆y0 = y0 + (y1 − y0 ) = (y0 + y1 ) (6.19)
x0 2 2 2 2

Similarly, we have
Z x2
h
I2 = y dx =
(y1 + y2 )
x1 2
Z x3
h
I3 = y dx = (y2 + y3 )
x2 2

and so on. (see Fig.6.2)

Prepared By:- Biruk E.(Assi. Professor)


126 Chapter 6. Numerical Differentiation and Integration

In general, we have Z xn
h
In = y dx = (yn−1 + yn ) (6.20)
xn−1 2

Figure 6.2

Adding all the integrals (Eq.(6.19), Eq.(6.20)) and using the interval additive property of the
definite integrals, we obtain
n Z xn
X h 
I= Ii = y dx = y0 + 2(y1 + y2 + y3 + · · · + yn−1 ) + yn (6.21)
i=1 x0 2

Equation (6.21) is known as the trapezoidal rule.

Summarising, the trapezoidal rule signifies that the curve y = f (x) is replaced by n-straight
lines joining the points (xn , yn ), i = 0, 1, 2, 3, . . . , n. The area bounded by the curve y = f (x),
the ordinates x = x0 , x = xn and the x-axis is then approximately equivalent to the sum of the
areas of the n-trapezoids so obtained.

6.5.1 Error Estimate in Trapezoidal Rule

Let y = f (x) be a continuous function with continuous derivatives in the interval [x0 , xn ].
Expanding y in a Taylor’s series around x = x0 , we get
x1 x1
(x − x0 )2 00
Z Z  
y dx = y0 + (x − + x0 )y00
y0 + · · · dx
x0 x0 2!
h2 0 h3 00 h4 000
= hy0 + y0 + y0 + y0 + · · · (6.22)
2 6 24
h2 00

h h h 0
Likewise, (y0 + y1 ) = (y0 + y(x0 + h)) = y0 + y0 + hy0 + y0 + · · ·
2 2 2 2
2 3 4
h h h
= hy0 + y00 + y000 + y0000 + · · · (6.23)
2 4 12
Hence, the error e1 in (x0 , x1 ) is obtained from Eqs. (6.22) and (6.23) as
x1
−1 3 00
Z
h
e1 = y dx − (y0 + y1 ) = h y0 + · · ·
x0 2 12

Prepared By:- Biruk E.(Assi. Professor)


6.5. TRAPEZOIDAL RULE 127

In a similar way, we can write


x2
−1 3 00
Z
h
e2 = y dx − (y1 + y2 ) = h y1 + · · ·
x1 2 12
−1 3 00
e3 = h y2 + · · ·
12
−1 3 00
e4 = h y3 + · · · (6.24)
12
and so on.
In general, we can write

−1 3 00
en = h yn−1 + · · ·
12
Hence, the total error E in the interval (x0 , xn ) can be written as
n
X −h3  00
y0 + y100 + y200 + · · · + yn−1
00

E= en = (6.25)
n=1
12

If y 00 (x̄) is the largest value of the n quantities in the right hand side of Eq.(6.25), then we have

−1 3 00 b − a 2 00
E= h ny (x̄) = − h y (x̄) (6.26)
12 12

Now, since h = b−a n


, the total error in the evaluation of the integral of Eq.(6.17) by the trape-
zoidal rule is of the order of h2 .
R 1.2
Example 6.11. Evaluate the integral 0 ex dx, taking six intervals by using trapezoidal rule
up to three significant figures.

Solution: Let h = b−a


n
= 1.2−0
6
= 0.2 and f (x) = ex , then the values of y are given for the
arguments which are obtained by dividing the interval (0, 1.2) into 6 equal parts given below:

x 0 0.2 0.4 0.6 0.8 1.0 1.2


y = f (x) 1 1.221 1.492 1.822 2.226 2.718 3.320
y0 y1 y2 y3 y4 y5 y6

The trapezoidal rule can be written as

h 
I = (y0 + y6 ) + 2(y1 + y2 + y3 + y4 + y5 )
2
0.2  
I = (1 + 3.320) + 2(1.221 + 1.492 + 1.822 + 2.226 + 2.718)
2
I = 2.3278 ≈ 2.328

The exact value is


1.2
R 1.2 x
0
e dx = ex = 2.320.
0
R 12 1
Example 6.12. Evaluate 0 1+x 2 dx by using trapezoidal rule, taking n = 6, correct to five

Prepared By:- Biruk E.(Assi. Professor)


128 Chapter 6. Numerical Differentiation and Integration

significant figures.
b−a 12−0
Solution: Dividing the interval (0, 12) into 6 equal parts, each of width h = n
= 6
= 2.
1
The values of f (x) = 1+x 2 at each points of sub-divisions are given by

x 0 2 4 6 8 10 12
y = f (x) 1 0.2 0.05882 0.02703 0.01538 0.00990 0.00690
y0 y1 y2 y3 y4 y5 y6
The trapezoidal rule can be written as

h 
I = (y0 + y6 ) + 2(y1 + y2 + y3 + y4 + y5 )
2
2 
I = (1 + 0.00690) + 2(0.2 + 0.05882 + 0.02703 + 0.01538 + 0.00990)
2
I = 1.62916

The exact value is


R 12 1 12
0 1+x2
dx = tan−1 x 0 = 1.48766.
R6
Exercise 6.1. Evaluate 2 log10
x dx by using trapezoidal rule, taking n = 8, correct to four deci-
mal places.
6−2
Solution: Dividing the interval (2, 6) into 8 equal parts, each of width h = 8
= 0.5.
The values of f (x) = logx10 are given below:
x 2 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
f (x) 0.3010 0.3979 0.4771 0.5440 0.6020 0.6532 0.6989 0.7403 0.7781
y0 y1 y2 y3 y4 y5 y6 y7 y8
The trapezoidal rule is

h
I= [(y0 + y8 ) + 2(y1 + y2 + y3 + y4 + y5 + y6 + y7 )]
2
0.5  
I= (0.3010 + 0.7781) + 2(0.3979 + 0.4771 + 0.5440 + 0.6020 + 0.6532 + 0.6989 + 0.7403)
2
I = 2.32666

The exact value is given by


R 6 10
2
logx dx = [x log x − x]62 = 6.06685

Prepared By:- Biruk E.(Assi. Professor)

You might also like