Unit V Notes Numerical Methods II 2
Unit V Notes Numerical Methods II 2
UNIT-V
NUMERICAL METHODS-II
Introduction:
Numerical analysis plays a great role in engineering and in the quantitative parts of pure and
applied science. Interpolation, the computing of values for a tabulated function at points not
in the table, is historically a most important task. Many famous mathematicians have their
names associated with procedures for interpolation: Gauss, Newton, Bessel, Stirling. The
need to interpolate began with the early studies of astronomy when the motion of heavenly
bodies was to be determined from periodic observations. Interpolation methods demonstrate
some important theory about polynomials and the accuracy of numerical methods.
Interpolating with polynomials serves as an excellent introduction to some techniques for
drawing smooth curves. These methods are the basis of many other procedures. Among
these procedures, we will focus on numerical differentiation and integration in this unit.
Forward difference:
If 𝑦0 , 𝑦1 , 𝑦2 ,…… 𝑦𝑛 denote the set of values of the function y=f(x).Then 𝑦0 =𝑦1 - 𝑦2 ,
𝑦1 =𝑦2 - 𝑦1 ........., 𝑦𝑛−1 =𝑦𝑛 -𝑦𝑛−1 are called the First Forward Differences of the function
y=f(x) where ∆ is called the forward difference operator. The differences are called first
forward differences denoted by 𝑦0 , 𝑦1 𝑦𝑛 second forward differences and are
denoted by 𝑦0 , 𝑦1 ,......, 𝑦𝑛−1 . i.e. 𝑦0 = 𝑦1 - 𝑦0 , 𝑦1 = 𝑦2 - 𝑦1 , ...,𝑦𝑛−1 = 𝑦𝑛
- 𝑦𝑛−1
Similarly we can define third, fourth forward differences etc.
In general the nthforward differences is defined by the equation, ∆𝑛 𝑦𝑖 = ∆𝑛−1 𝑦𝑖+1 − ∆𝑛−1 𝑦𝑖
x y=f(x) ∆𝑦 ∆2 𝑦 ∆3 𝑦 ∆4 𝑦 ∆5 𝑦
𝑥0 𝑦0
Δ𝑦0
𝑥1 = 𝑥0 + ℎ 𝑦1 Δ2 𝑦0
Δ𝑦1 Δ3 𝑦0
𝑥2 = 𝑥0 + 2ℎ 𝑦2 2
Δ 𝑦1 Δ4 𝑦0
Δ𝑦2 Δ3 𝑦1 Δ5 𝑦0
𝑥3 = 𝑥0 + 3ℎ 𝑦3 2
Δ 𝑦2 4
Δ 𝑦1
Δ𝑦3 3
Δ 𝑦2
𝑥4 = 𝑥0 + 4ℎ 𝑦4 Δ2 𝑦3
Δ𝑦4
𝑥5 = 𝑥0 + 5ℎ 𝑦5
Here 𝑦0 is called the First Entry and∆𝑦0 , ∆2 𝑦0 ,∆3 𝑦0 ,......∆5 𝑦0 are called the Leading
Differences.
Backward Difference:
Consider the function y = f(x). If 𝑦0 , 𝑦1 , 𝑦2 ,....,𝑦𝑛 denote the set of values of y.
Then∇𝑦1 =𝑦1− 𝑦0 , ∇𝑦2 = 𝑦2 − 𝑦1 , .........,∇𝑦𝑛 = 𝑦𝑛 − 𝑦𝑛−1 are called the First Backward
Differences and is called the backward difference operator.
The second backward difference of the function is given by,
∇2 𝑦2 = ∇𝑦2 − ∇𝑦1 , ∇2 𝑦3 = ∇𝑦3 − ∇𝑦2 , …….., ∇𝑛 𝑦𝑛 = ∇𝑦𝑛 − ∇𝑦𝑛−1
Similarly we can define higher order differences.
In general the nth backward difference is given by ∇𝑛 𝑦𝑖 = ∇𝑛−1 𝑦𝑖 − ∇𝑛−1 𝑦𝑖−1
x y=f(x) ∇𝑦 ∇2 𝑦 ∇3 𝑦 ∇4 𝑦 ∇5 𝑦
𝑥0 𝑦0
𝑥1 = 𝑥0 + ℎ 𝑦1
∇𝑦1
∇2 𝑦2
∇𝑦2 ∇2 𝑦3
𝑥2 = 𝑥0 + 2ℎ 𝑦2 ∇2 𝑦3 ∇4 𝑦4
∇𝑦3 ∇ 𝑦4
3
∇5 𝑦5
𝑥3 = 𝑥0 + 3ℎ 𝑦3 ∇2 𝑦4
∇4 𝑦5
∇𝑦4 ∇3 𝑦5
𝑥4 = 𝑥0 + 4ℎ 𝑦4 ∇2 𝑦5
∇𝑦5
𝑥5 = 𝑥0 + 5ℎ 𝑦5
2. Evaluate cos 2x
cos 2x = {cos 2 (𝑥 + ℎ) − cos 2𝑥 }
cos 2 (x + h) −cos 2x
= [cos2(x + 2h) – cos 2 (x + h)] – [cos 2 (x + h) – cos 2x]
= - 2 sin (2x + 3h) sin h + 2 sin (2x + h) sin h
= - 2 sin h [sin (2x + 3h) – sin (2x + h)]
= - 2 sin h [2 cos (2x + 2h) sin h] = -4 sin2 h cos (2x + 2h)
Differences of a Polynomial:
The nthdifferences of a polynomial of the nth degree are constant and all higher order
differences are zero.
Let f(x) =𝑎0 𝑥 𝑛 + 𝑎1 𝑥 𝑛−1 +. . . +𝑎𝑛 , then
n f(x) = 𝑎0 n (n - 1) (n - 2) … 1. ℎ𝑛 =𝑎0 n!ℎ𝑛 ........………………….(1)
and then for higher orders ∆𝑛+1 𝑓(𝑥)=∆𝑛+2 𝑓(𝑥 ) = . . . = 0. …….……….(2)
Problems:
1.Evaluate 10 [(1 – ax) (1 – b𝑥 2 ) (1 – c𝑥 3 ) (1 – d𝑥 4 )] with h=1,h=2.
Solution: Given,
∆10 [(1 – ax) (1 – b𝑥 2 ) (1 – c𝑥 3 ) (1 – d𝑥 4 )] = ∆10 [abcd𝑥 10 + ( ) 𝑥 9 + ( )𝑥 8 + ......+1]
=abcd∆10 (𝑥 10 ) [∆10 (𝑥 𝑛 ) = 0 or n<10]
= abcd (10 !) (for h = 1)
10
Similarly for h =2, = abcd (10!) (2)
x 5 10 15 20 25 30
y 9962 9848 9659 9397 9063 8660
3.Construct the finite difference table for the function f(x) = 𝑥 3 +x+1 where x takes the values
0,1,2,3,4,5,6. Identify the leading forward and backward differences. Hence find ∆2 𝑦1, ∇3 𝑦5 .
Solution:
x y First Second Third Fourth
difference difference difference difference
0 1
1 3
6
2 11
6
3 31
6
4 69
6
5 131
6 223
The leading forward differences are 2, 6, 6 and leading backward differences are 92, 30, 6.
∆2 𝑦1 = 12, ∇3 𝑦5 = 6 .
Note: Third differences are constants and higher order differences are zero as f(x) is a
polynomial of third degree.
Remark:
Newton’s Forward Interpolation Formula is used to interpolate the values of y near the
beginning of the set of tabulated values or for extrapolating values of y to the left of the
beginning. Newton’s Backward Interpolation Formula is used to interpolate the values of y
near the end of the set of tabulated values or for extrapolating values of y to the right of the
last tabulated value y.
Examples:
1. Find a cubic polynomial which takes the following data
x 0 1 2 3
f(x) 1 2 1 10
𝑥−𝑥0 𝑥−0
Here, 𝑥0 = 0, h = 1, p= = = x, ∆𝑦0 =1,∆2 𝑦0 = -2, ∆3 𝑦0 =12,
ℎ 1
𝑝(𝑝−1) 𝑝(𝑝−1)(𝑝−2)
f(x) = y0 + p𝑦0 + ∆𝑦0 + ∆𝑦0 + ......
2! 3!
𝑥(𝑥−1) 𝑥(𝑥−1)(𝑥−2)
f(x) = 1+x(1)++ (-2)+ (12) = 2x3 – 7x2 + 6x +1 is the required polynomial.
2! 3!
2.The table gives the distance in nautical miles of the visible horizon for the given heights
in feet above the earth’s surface.
Solution:
f(160)=13.03+0.402+0.0192+0.00384+0.00168
𝑝(𝑝+1) 𝑝(𝑝+1)(𝑝+2)
f(410) = 𝑦𝑛 + p∇𝑦𝑛 + ∇2 𝑦𝑛 + ∇3 𝑦𝑛 …….
2! 3!
0.2(1.2)
f(410)=21.27+0.2(1.37)+ 2
(-0.11)+…………….
3. From the following table, estimate the number of students who obtained marks between 40 and
45:
No. of students(y): 31 42 51 35 31
To find y(45) i.e. number of students with marks less than 45.
𝑥−𝑥0 5
Taking𝑥0 = 40, x=45, h=10, p = = = 0.5
ℎ 10
= 47.87
Exercise:
1. Fit a cubic polynomial to the following data using suitable interpolation formula.
x 0 1 2 3
f(x) -2 2 12 34
2. Using Newton-Gregory Interpolation formulae, estimate f (0.12) from the following data.
3. Apply Newton’s backward difference interpolation formula to find f(7.5) from the
following table:
4. Using Newton -Gregory Interpolation formulae, find tan170 from the following data.
x 0 4 8 12 16 20 24
f(x) 0 0.0699 0.1405 0.2126 0.2867 0.3640 0.4452
Numerical Differentiation:
Let the function y = f(x) is given by a table of values (x , y) then the process of computing the
𝑑𝑦 𝑑 2 𝑦
derivatives , etc. for some particular value of x is called Numerical Differentiation.
𝑑𝑥 𝑑𝑥 2
𝑥− 𝑥0
where, x = 𝑥0 + Ph (or) P= ………. (2)
ℎ
Formula (5) is used to compute 𝑦 ′ at any point x =𝑥0 + Ph , whereas formula (6) is used to
compute 𝑦 ′ at any of the value of x when y is specified.
Similarly,
𝑑2 𝑦 1 (6𝑃 2−18𝑃+11)
( )
2 𝑥=𝑥0 +𝑃ℎ
= 2
[∆𝑦0 + (𝑃 − 1)∆3 𝑦0 + ∆4 𝑦0 + ⋯ ] …. (7)
𝑑𝑥 ℎ 12
The formula (7) is used to compute y'' at any point x = 𝑥0+Phwhereas formula (8) is used to
compute y'' at any value of x where y is specified.
𝑃 𝑃 (𝑃+1) 𝑃 (𝑃+1)(𝑃+2)
y = 𝑦𝑛 + 1! ∇𝑦𝑛 + 2!
∇2 𝑦𝑛 + 3!
∇3 𝑦𝑛 + …… ……… (1)
𝑥−𝑥𝑛
Where, x = 𝑥𝑛 + Ph (or) P = ……… (2)
ℎ
𝑑𝑦 (2𝑃+1) (3𝑃2+6𝑃+2)
𝑑𝑃
= ∇𝑦𝑛 + 2!
∇2 𝑦𝑛 + 3!
∇3 𝑦𝑛+ …… ……… (3)
Formula (5) is used to compute y ' at any point x =𝑥𝑛 + Ph whereas formula (6) is used to
compute𝑦 ′ at any of the values of x when y is specified.
Similarly
𝑑2 𝑦 1 (6𝑃2+18𝑃+11)
(𝑑𝑥 2)𝑥= 𝑥𝑛+𝑃ℎ =ℎ 2 [𝛻 2 𝑦𝑛 + (𝑃 + 1)𝛻 3 𝑦𝑛 + 12
𝛻 4 𝑦𝑛 + ⋯ ] …. (7)
𝑑2 𝑦 1 11 5 137
( ) = 2 [𝛻 2 𝑦𝑛 + 𝛻 3 𝑦𝑛 + 𝛻 4 𝑦𝑛 + 𝛻 5 𝑦𝑛 + 𝛻 6 𝑦𝑛 + ⋯ ] …. (8)
𝑑𝑥 2 𝑥=𝑥𝑛 ℎ 12 6 180
The formula (7) is used to compute y'' at any point x = 𝑥𝑛 +Ph whereas formula (8) is used
tocompute y'' at any of the values of x when y is specified.
Solution: Here, the step-length is h = 0.2. We first form the following difference table.
1.0 2.27
0.60
1.2 3.32 0.14
0.74 0.02
1.4 4.06 0.16 0.01
0.90 0.03
1.6 4.96 0.19 0.03
1.09 0.06
1.8 6.05 0.25
1.34
2.0 7.39
We have to compute 𝑦 ′ and 𝑦 ′′ at x = 1.2, which is a specified value of x, for this purpose, we
take 𝑥0 = 1.2. Then we find from the table that,
𝑑𝑦 1 1 1 1
Then, (𝑑𝑥 ) = [(0.74) − (0.16) + (0.03) − (0.03)] = 3.3125
(1.2) (0.2) 2 3 4
𝑑2 𝑦 1 11
And (𝑑𝑥 2 )(1.2) = [(0.16) − (0.03) + (0.03)] = 3.39375
(0.2)2 12
2. Using appropriate interpolation formulas, find the values of 𝑦 ′ 𝑎𝑛𝑑 𝑦 ′′ when x = 4 using the
following table.
x 1 2 3 4
y 4 12 20 36
Solution: Here x = 4 is a specified value of x which is at the end of the given table.
For this purpose we take 𝑥𝑛 = 4.
The difference table is given by,
8
= 16+4+ = 22.667
3
1 1 1
And𝑦 ′′ (4) = [ (∇2 𝑦𝑛 ) + (∇3 𝑦𝑛 )] = [8 + 8]= 16
ℎ2 2 12
3.A rod is rotating in a plane, the following table gives the angle θ (in radians) through which the
rod is turned for various values of time t (in seconds): Find the angular velocity and angular
acceleration at t = 0.4 sec.
Solution: Given
0 0
0.12
0.2 0.12 0.25
0.37 0.01
0.4 0.49 0.26 0.00
0.63 0.01
0.6 1.12 0.27 0.00
0.90 0.01
0.8 2.02 0.28 0.00
1.18 0.01
1.0 3.20 0.29
1.47
1.2 4.67
To compute (dθ/dt) and (d2θ/dt2) at t = 0.4 sec, which is specified value of t. We take t 0 = 0.4
∆θ0 = 0.63, ∆2θ0 = 0.21, ∆3θ0 = 0.01, ∆4θ0 = 0.00
Using the formula,
𝑑𝜃 1 1 1 1
( 𝑑𝑡 )𝑥=𝑥0 =ℎ [∆𝑦0 − ∆2 𝑦0 + ∆3 𝑦0 − ∆4 𝑦0 + ⋯ ]
2 3 4
𝑑2 𝜃 1 11 5
( 𝑑𝑡 2 )𝑥=𝑥0 =ℎ2 [∆2 𝑦0 − ∆3 𝑦0 + ∆4 𝑦0 − 6 ∆5 𝑦0 + ⋯ ]
12
𝑑2𝜃 1
( 2
) = [(0.27) − 0.01] = 6.5
𝑑𝑡 (0.4) (0.2)
4. The following table gives the temperature θ (in degree Celsius) of a cooling body at different
T 1 3 5 7 9
T 𝜃 θ θ θ θ
1 85.3
-10.8
3 74.5 3.3
-7.5 -2.3
5 67.0 1.0 1.6
-6.5 -0.7
7 60.5 0.3
-6.2
9 54.3
P = (t –𝑡4 ) / h = -0.5
Exercise:
1. Given that,
𝑑𝑦 𝑑2 𝑦
Find𝑑𝑥 , 𝑑𝑥 2 at x = 1.1 and x = 1.6.
2. A slider in a machine moves along a fixed straight rod. Its distance x cm along the rod is
given below for various values of the time ‘t’ seconds. Find the velocity of the slider and its
acceleration when t = 0.1 second.
t 0 1.0 1.2 1.4 1.6 1.8 2.0
x 30.13 31.62 32.87 33.64 33.95 33.81 33.24
𝑑𝑥 𝑑2 𝑦
3. Find 𝑑𝑦 and at x =1.1 of the function tabulated below:
𝑑𝑥 2
x 0 1 2 3 4 5
y 4 8 15 7 6 2
5. Find 𝑓 ′ (1.5) using the differentiation formula based on Newton’s interpolation for the
following data:
x 1 2 3 4 5 6
f(x) 4 9 16 25 36 49
(𝑥−𝑥0 )(𝑥−𝑥1)……….(𝑥−𝑥𝑛−1 )
……..+(𝑥 𝑦𝑛
𝑛 −𝑥0)(𝑥𝑛 −𝑥1)………..(𝑥𝑛 −𝑥𝑛−1 )
Inverseinterpolation:
The process of estimating the value of x for a given value of y is called Inverse interpolation.
So far given a table of values of x and y, using one of the interpolation formulae we find the value
of y corresponding to some value of x which is not in the table. On the other hand the process of
estimating the value of x for some value of y which is not in the table is called inverse
interpolation.
This method is used when the values of x are not necessarily equally spaced. Lagrange’s
interpolation formula can be simply viewed as a relation between two variables and any one of
the variable can be taken as an independent variable. Therefore inverse interpolation formula can
be obtained by interchanging the variables x and y in Lagrange’s formula, we get.
Problems:
1.ByusingtheLagrange’s interpolation formula to fit a polynomial to the data given
2.Apply Lagrange’s formula to find f(5) and f(6) given that f(1) =2, f(2)=4,f(3)=8,f(7)=128
and explain why the results differ from those obtained by f(x) = 2𝑥 .
Solution: 𝑥0 = 1𝑥1= 2 𝑥 2 = 2 𝑥3 = 7
By Lagrange’s formula, we have
(𝑥−2)(𝑥−3)(𝑥−7) (𝑥−1)(𝑥−3)(𝑥−7)
f (x) = (1−2)(1−3)(1−7) 𝑓(𝑥0) + (2−1)(2−3)(2−7) 𝑓(𝑥1) +
(𝑥−1)(𝑥−3)(𝑥−17) (𝑥−1)(𝑥−2)(𝑥−3)
(3−1)(3−2)(1−7)
𝑓(𝑥2 ) + (7−1)(7−2)(7−3)
𝑓(𝑥3)
(𝑥−2)(𝑥−3)(𝑥−7) (𝑥−1)(𝑥−3)(𝑥−7)
f (x) = (2) + (4) +
−12 5
(𝑥−1)(𝑥−2)(𝑥−17) (𝑥−1)(𝑥−2)(𝑥−3)
(8) + (128)
−8 120
(3)(2)(−2) (4)(2)(−2) (4)(3)(−2) (4)(3)(2)
f (5) = (2) + (4) + (8) + (128)
−12 5 −8 120
= 2-12+20+64 = 74
But actual values of f(5) and f(6) are f(5) = 25 = 32 and f(6) = 26 = 64.
The difference in values of f(5) and f(6) are due to the assumption of f(x) as a polynomial,
when it is an exponential function of the form 2𝑥 .
3.Find x for y = 7
x 1 3 4
y 4 12 19
Solution:
𝑥0 =1 𝑥1 =3 𝑥2 =4
𝑦0 = 4 𝑦1 = 12 𝑦2 = 14
(𝑦−𝑦1 )(𝑦−𝑦2 ) (𝑦−𝑦0 )(𝑦−𝑦2 ) (𝑦−𝑦0 )(𝑦−𝑦1 )
x = (𝑦 𝑥 +
) 0 (𝑦
𝑥 +
) 1
𝑥2
0 −𝑦1 )(𝑦0 −𝑦2 1 −𝑦0 )(𝑦1 −𝑦2 (𝑦2 −𝑦0 )(𝑦2 −𝑦1 )
at y=7
60 108 60
x = 120 + - 105
56
= 1.85714
Numerical Integration:
Numerical integration is a process of evaluating a definite integral from a set of tabulated
values of the integrand f(x).If the integrand is a function of a single-valued, then the
numerical integration is known as Quadrature.
Newton – Cote’s Quadrature formula:
Let
𝑏
I=∫𝑎 𝑓(𝑥)dx,
where f (x) takes the value 𝑦0, 𝑦1 , 𝑦2 ……..,𝑦𝑛 for x = 𝑥0 ,𝑥1 ,𝑥2 ….,𝑥𝑛 .Divide the interval (a, b)
into n sub-intervals of width h, so that
𝑥0 = a, 𝑥1 =𝑥0 +h , 𝑥2 = 𝑥0 +2h,…..,𝑥𝑛 = 𝑥0 + nh = b
𝑥 +𝑛ℎ
Now, I = ∫𝑥 0 𝑓(𝑥) dx.
0
Let x=𝑥0 +rh then dx = h dr. Also when x =𝑥0 , r = 0 and when
x = 𝑥0 + nh, r = n,
𝑛
I=∫0 𝑓( 𝑥0 +rh) h dr.
Now by Newton’s forward interpolation formula, we have
𝑛 𝑟(𝑟−1) 𝑟(𝑟−1)(𝑟−2)
I = h∫0 [ 𝑦0 + r 𝛥 𝑦0 + 𝛥2 𝑦0 + 𝛥3 𝑦0 +……] dr
2! 3!
Integrating terms by terms, we get
𝑟2 1 𝑟3 𝑟2 1 𝑟4
I = h[𝑦0 r + 𝛥𝑦0 + ( - )𝛥2 𝑦0 + 3! ( 4 - 𝑟 3 + 𝑟 2 ) 𝛥3 𝑦0 +……]𝑛0
2 2! 3 2
𝑛 1 𝑛2 𝑛 1 𝑛2
I = nh [𝑦0 + (𝛥𝑦0 ) + ( - ) (𝛥2 𝑦0 ) + ( − 𝑛2 + 𝑛 ) (𝛥3 𝑦0 ) +….].
2 2! 3 2 3! 4
1. Simpson’s 1/3rdrule:
By taking n = 2 in the general Quadrature formula and neglecting terms containing𝛥3 𝑦0 , 𝛥4 𝑦0
, … then we get
ℎ
I = 3 [(𝑦0 + 𝑦𝑛 ] + 4 (𝑦1 + 𝑦3 +……. +𝑦𝑛−1 )+ 2 (𝑦2 +𝑦4 …..+ 𝑦𝑛−2 )]
2. Simpson’s 3/8thrule:
By taking n = 3 in the general Quadrature formula and neglecting terms containing𝛥4 𝑦0 , 𝛥5 𝑦0
,……we get
3ℎ
I= [(𝑦0 +𝑦𝑛 ) + 3(𝑦1 + 𝑦2 + 𝑦4 +𝑦5 + ⋯ + 𝑦𝑛−1 ) + 2 ( 𝑦3 +𝑦6 + ⋯ + 𝑦𝑛−3 ) ]
8
3. Weddle’s rule:
By taking n = 6 in the general Quadrature formula
𝑥 +𝑛ℎ
0 3ℎ
∫𝑥0 𝑓(𝑥) 𝑑𝑥 =10 [(𝑦0 + 𝑦𝑛 ) + 5(𝑦1 + 𝑦5 + ⋯ + 𝑦𝑛−5 + 𝑦𝑛−1 ) + (𝑦2 + 𝑦4 + ⋯ + 𝑦𝑛−4 +
𝑦𝑛−2 ) + 2(𝑦6 + 𝑦12 + ⋯ + 𝑦𝑛−6 ) + 6(𝑦3 + 𝑦9 + ⋯ + 𝑦𝑛−3 )]
5.2
2.Calculate ∫4 logx dx using (a) Simpson’s 1/3rd rule (b) Simpson’s 3/8th rule (c) Weddle’s
rule.
5.2−4 1.2
Solution: h= = =0.2
6 6
6 𝑑𝑥
3. Evaluate ∫0 using (a) Simpsons 1/3rd rule (b) Simpsons 3/8th rule(c)Weddle’s rule
1+𝑥 2
Solution:
Dividing the interval (0,6) into six equal parts of width h= 6−0
6
=1
x 0 1 2 3 4 5 6
f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027