Professional Documents
Culture Documents
Numerical Methods-I PDF
Numerical Methods-I PDF
= f x 2h 2 f x h f x
(ii) y0 y1 y0
(iii) 2 y0 y2 2 y1 y0
The differences are systematically set out as follows called as Forward Difference table
Value of Value of First diff. Second Third diff Fourth Fifth diff
x y diff diff
x0 y0 y 0 2 y0 3 y0 4 y0 5 y0
x0 h y1 y1 2 y1 3 y1 4 y1
x0 2 h y2 y2 2 y 2 3 y 2
x0 3h y3 y 3 2 y3
x0 4 h y4 y4
x0 5h y5
ILLUSTRATIONS
Ex.1. Prepare the forward difference table for the following data.
X 0 1 2 3 4
Y 5 4 9 26 61
Solution-
x y y 2 y 3 y 4 y
0 = x0 5 = y0 -1 = y0 6 = 2 y0 6 = 3 y0 0 = 4 y0
1 = x1 4 = y1 5= y1 12 = 2 y1 6 = 3 y1
18 =
2 = x2 9 = y2 17= y1
2 y2
3 = x3 26 = y3 35= y2
4 = x4 61 = y 4
Remark-
(i) 2 f x = f x
= f x f x h
= f x f x h f x h f x 2h
= f x 2 f x h f x 2h
(ii) y1 y1 y0
(iii) The differences are systematically set out as follows called as Backward
Difference table
Value of Value of First diff. Second Third diff Fourth Fifth diff
x y diff diff
x0 y0
x0 h y1 y1
x0 2 h y2 y 2 2 y2
x0 3h y3 y3 2 y3 3 y3
x0 4 h y4 y 4 2 y4 3 y4 4 y4
x0 5h y5 y5 2 y5 3 y5 4 y5 5 y5
ILLUSTRATIONS
Ex.2. Prepare the Backward difference table for the following data.
X 0 1 2 3 4
Y 5 4 9 26 61
Solution-
X y y 2 y 3 y 4 y
0 = x0 5 = y0
1 = x1 4 = y1 -1 = y1
2 = x2 9 = y2 5= y2 6 = 2 y2
3 = x3 26 = y3 17= y3 12 = 2 y3 6 = 3 y3
6 =
4 = x4 61 = y 4 35= y4 18 = 2 y4 0 34yy4
4
h h
3. Central difference operator - It is defined as f x f x f x
2 2
Remark-
(i) 2 f x = f x
h h
= f x f x
2 2
= f x h f x f x f x h
= f x h 2 f x f x h
1 h h
4. Average operator - It is defined as f x f x f x
2 2 2
Remark-
(i) 2 f x = f x
1 h h
= f x f x
2 2 2
1 1
=
2 2
f x h f x f x f x h
1
2
1
= f x h 2 f x f x h
4
(i) 1 E
(ii) 1 E 1
1
(iii) E2
1
(iv) E 2
ILLUSTRATIONS
f x f x 2 f x
= x 2 2 x 2
=2
Ex.2. If f x x 2 2, h 2 then find f x
f x f x f x 2
= x 2 2 x 2 2
2
= x 2 2 x 2 2 x 4 2
= 2x 4
h h
Solution. - we know that, f x f x f x but h 1
2 2
1 1
= f x f x
2 2
1 1
= x x
2 2
=1
1 h h
Solution. - we know that, f x f x f x but h 2
2 2 2
1 2 2
= f x f x
2 2 2
1
f x 1 f x 1
2
=
1
x 1 x 1
2 2
=
2
= x2 1
= f x 4 2 f x 2 f x
= x 4 2 x 2 x
2 2 2
= x 8x 16 2 x 4 x 4 x
2 2 2
= 12
= f x 2 2 f x f x 2
= x 2 2 x x 2
=0
1
Solution. - we know that, 2 f x h 2 f x f x h but h 2
4
1
f x h 2 f x f x h
4
=
= x 2 2 x x 2
=0
Notes:
Newton’s Forward Difference Interpolation Formula
u u 1 2 u u 1 u 2 3
y y0 u y0 y0 y0 ............
2! 3!
x x0
where u =
h
ILLUSTRATIONS
Ex.1. Find the value of y for x 0.5 the following table of x, y values using Newton’s
X 0 1 2 3 4
Y 1 5 25 100 250
X y y 2 y 3 y 4 y
0 1 4 16 39 -19
1 5 20 55 20
2 25 75 75
3 100 150
4 250
Here h 1 , x0 0 , y0 0, x 0.5
u u 1 2 u u 1 u 2 3
y y0 u y0 y0 y0 ............
2! 3!
x x0 0.5 0
where u = 0.5
h 1
0.5 0.5 1 0.5 0.5 1 0.5 2 0.5 0.5 1 0.5 2 0.5 3
y x0.5 1 0.5 4 16 39 19
2! 3! 4!
= 4.1796
EXERCISE
dy
Ex.1. Find the value of y at x 1.5 and at x 1.5 for the following tabulated data.
dx
X 1 2 3 4 5
Notes:
1. Newton’s Backward Difference Interpolation Formula
u u 1 2 u u 1 u 2 3
y yn u yn yn yn ............
2! 3!
x xn
where u =
h
Ex.1. The distance travelled by a point P in x-y plane in a mechanism is as shown in the table
below. Estimate the distance travelled, velocity and acceleration of point P when x 0.5
x 1 2 3 4 5
y 14 30 62 116 198
X y y 2 y 3 y 4 y
1 14
2 30 16
3 62 32 16
4 116 54 22 6
5 198 82 28 6 0
u u 1 2 u u 1 u 2 3
y y5 u y5 y5 y5
2! 3!
x xn x 5
where u = x5
h 1
y 198 x 5 82
x 5 x 4 28 x 5 x 4 x 3
6
2! 3!
x3 2 x 2 3x 8
= distance travelled
dy
Velocity is given by v
dx
x3 2 x 2 3x 8
d
dx
3 x 2 4 x 3
81.75
dv
Acceleration
dx
d
dx
3x 2 4 x 3
6x 4
EXERCISE
Ex2. Given the table of square roots. Calculate the values of 155 by Newton’s interpolation
formula.
Notes:
ILLUSTRATIONS
Ex.1. The velocity distribution of a fluid near a flat surface is given below:
x is the distance from the surface (mm) and v is the velocity (mm/sec). use Lagrange’s
v
x x1 x x2 x x3 v x x0 x x2 x x3 v +
x0 x1 x0 x2 x0 x3 0 x1 x0 x1 x2 x1 x3 1
x x0 x x1 x x3 v x x0 x x1 x x2 v
x2 x0 x2 x1 x2 x3 2 x3 x0 x3 x1 x3 x2 3
v
0.4 0.3 0.4 0.6 0.4 0.8 0.72 0.4 0.1 0.4 0.6 0.4 0.8 1.81
0.1 0.3 0.1 0.6 0.1 0.8 0.3 0.1 0.3 0.6 0.3 0.8
0.4 0.1 0.4 0.3 0.4 0.8 2.73 0.4 0.1 0.4 0.3 0.4 0.6 3.47
0.6 0.1 0.6 0.3 0.6 0.8 0.8 0.1 0.8 0.3 0.8 0.6
= 2.1602
x 0 1 2
y 4 3 6
3
dy
use it to findy at x 1.5 , at x 0.5 , and yd x
dx 0
y
x x1 x x2 y0
x x0 x x2 y1
x x0 x x1 y2
x0 x1 x0 x2 x1 x0 x1 x2 x2 x0 x2 x2
x 1 x 2 4 x 0 x 2 3
x 0 x 1 6
0 1 0 2 1 0 1 2 2 0 2 1
4
2
1 2
x 3x 2 3 2 x x 2 6 x 2 x
1
2
2 x 2 3x 4
dy
4x 3
dx
dy
4 0.5 3 1
dx 0.5
3 3
ydx x 3x 4 dx
2
0 0
3
x3 x2
2 3 4 x
3 2 0
3
33 32
2 3 4 3
3 2 0
16.5
EXERCISE
Ex.1. Use Lagrange’s formula to find the value of y when x 10 , if the following values of x
and y
are given:
x: 5 6 9 11
y: 12 13 14 16
x: 0 2 3 6
y: 648 704 729 792
Notes:
d y 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y0 y0 y0 y0
d x xn h 2 6 24
d y 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
yn yn yn yn
d x xn h 2 6 24
ILLUSTRATIONS
x 0 1 2 3 4 5
dy
find at x 5.5
dx
X Y y 2 y 3 y 4 y 5 y
0 1.12
1 3.45 2.33
xn x 5 5.5
Here h 1 , xn 5 , yn 24.52, x 5.5 , u 0.5
h 1
d y 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
yn yn yn yn
d x xn h 2 6 24
11.6871
dy
find at x 500
dx
x Y y 2 y 3 y 4 y 5 y
550 6.3099
x0 x 500 500
Here h 10 , x0 500 , y0 6.2146, x 500 , u 0
h 10
d y 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y0 y0 y0 y0
d x xn h 2 6 24
dy 1 1 1 1 1
0.0198 0.0004 0.0001 0.0002 0.0003
dx x 500 10 2 3 4 5
dy 1
0.0198 0.0002 0.0003 0.00005 0.00006
dx x 500 10
0.0002
EXERCISE
x 0 1 2 3 4 5
y 4 8 15 7 6 2
dy
find at x 0 and x 5
dx
Notes:-
1) Euler’s Method
f x, y with the initial condition y y0 at
dy
Consider the differential equation
dx
x x0
Suppose we want to solve the equation we use the following approximation
y1 y0 h f x0 , y0 ,
y2 y1 h f x1 , y1 ,
And so on, In general y n1 y n h f xn , y n , n 0,1, 2,
To obtain the solution with desired accuracy, one has to take a smaller value of h , hence
the solution is obtained very slowly. Due to this the method is rarely used. The more
accurate method will be obtained by the modified method.
ILLUSTRATIONS
dy
Ex.1. Use Euler’s method to solve the equation 1 xy
dx
30
Solution: - given f x , y 1 xy , h 0.1, x0 0, y0 1 and h 0.5
6
y1 y0 h f x0 , y0
1 0.1 f 0,1
y2 y1 h f x1 , y1
y3 y2 h f x2 , y2
y4 y3 h f x3 , y3
y3 y2 h f x2 , y2
1.211 0.1 f 0.2,1.211
y1
n 1
2
n
y 0 f x0 , y 0 f x1 , y1 , n 1, 2,
h
……….. (1)
i.e. new y old y h Meanslope , where Mean slope f x0 , y 0 f x1 , y1
1
2
n
1 2 n1 n
by making use of (1) we can obtain approximations y1 , y1 ,, y1 , y1 . This
n1 n
process is repeated till no significant change occurs. i e. y1 y1 we call this as y1
Then y1 is more correct approximation at x x1
To find the value of y at x x2 , the above procedure is repeated in the interval x1 , x2
(note x2 x1 h )
ILLUSTRATIONS
dy
Ex.1. Use modified Euler’s method to solve x y 2 , y 0 1 to calculate y 0.4 taking
dx
h 0.2
by Euler’s method
y11 y0 f x0 , y0 f x1 , y10
h
2
0.2
1 f 0,1 f 0.2, 0.8
2
0.2
1 1 0.44 0.8560
2
y12 y0 f x0 , y0 f x1 , y11
h
2
0.2
1 f 0,1 f 0.2, 0.8560
2
0.2
1 1 0.5327 0.8467
2
y1 y x 0.2 0.8467
by Euler’s method
y21 y1 f x1 , y1 f x2 , y2 0
h
2
0.2
0.8467 f 0.2, 0.8467 f 0.4, 0.7962
2
0.2
0.8467 0.5193 0.2340 0.7728
2
y2 2 y1 f x1 , y1 f x2 , y21
h
2
0.2
0.8467 f 0.2, 0.8467 f 0.4, 0.7728
2
0.2
0.8467 0.5193 0.1972 0.7765
2
y2 y x 0.4 0.7765
dy
Ex.2. Use modified Euler’s method to solve x 2 y, y 0 1 to calculate y 0.1 taking
dx
h 0.05
by Euler’s method
y11 y0 f x0 , y0 f x1 , y10
h
2
0.05
1 f 0,1 f 0.05,1.05
2
0.05
1 1 1.0525 1.0513
2
y12 y0 f x0 , y0 f x1 , y11
h
2
0.05
1 f 0,1 f 0.05,1.0513
2
0.05
1 1 1.0538 1.0513
2
y1 y 05 1.0513
by Euler’s method
y21 y1 f x1 , y1 f x2 , y2 0
h
2
0.05
1.0513 f 0.1,1.0513 f 0.1,1.1040
2
0.05
1.0513 1.0538 1.114 1.1055
2
y2 2 y1 f x1 , y1 f x2 , y21
h
2
0.05
1.0513 f 0.05,1.0513 f 0.1,1.1055
2
0.05
1.0513 1.0538 1.1155 1.1055
2
y2 y x 0.1 1.1055
EXERCISE
dy
Ex.1. Use Euler’s method to solve the equation x y, y 0 0 find y 0.4
dx
Ex.2. Use Modified Euler’s method to find the value of y satisfying the equation
Ex.3. Use Modified Euler’s method to find the value of y satisfying the equation
d y yx
, y 0 1for x 0.1 take h 0.05
d x yx
Session -7 Numerical Solution of Ordinary Differential equations by Runge-Kutta Method
Notes:
1) Runge-Kutta Method of fourth order
The fourth order Runge-kutta method is most commonly used.Working rule for finding
the increment k of y corresponding to an increment h of x by Runge-kutta method
ILLUSTRATIONS
dy
Ex.1. Use fourth order Runge- Kutta method to solve x y , y 0 1 to calculate
dx
y at x = 0.2
k1 h f x0 , y0 0.2 0 1 0.2
h k 0.2 0.2
k2 h f x0 , y0 1 0.2 f 0 ,1
2 2 2 2
h k 0.2 0.2191
k3 h f x0 , y0 2 0.2 f 0 ,1
2 2 2 2
1
0.2 2 0.2191 2 0.2120 0.2377
6
0.2167
y1 y x 0.2 y0 k 1.2167
dy 1
Ex.2. Use fourth order Runge- Kutta method to solve , y 0 1 to find
dx x y
1
Solution: - given f x , y , h 0.2, x0 0, y0 1
x y
h k 0.2 0.2
k2 h f x0 , y0 1 0.2 f 0 ,1
2 2 2 2
1
0.2 0.167
0.1 1.1
h k 0.2 0.167
k3 h f x0 , y0 2 0.2 f 0 ,1
2 2 2 2
1
0.2 0.169
0.1 1.0835
1
0.2 0.1461
0.2 1.169
1
k k1 2k2 2k3 k4
6
1
0.2 2 0.167 2 0.169 0.1461
6
0.1697
y1 y x 0.2 y0 k 1.1697
1
k1 h f x1 , y1 0.2 0.146
0.2 1.1697
h k 0.2 0.146
k2 h f x1 , y1 1 0.2 f 0.2 ,1.1697
2 2 2 2
1
0.2 0.1296
0.3 1.2497
h k 0.2 0.1296
k3 h f x1 , y1 2 0.2 f 0.2 ,1.1697
2 2 2 2
1
0.2 0.1303
0.3 1.2345
1
0.2 0.1176
0.4 1.3
1
k k1 2k2 2k3 k4
6
1
0.146 2 0.1296 2 0.1303 0.1176
6
0.1306
y2 y x0.4 y1 k 1.3003
EXERCISE
dy
Ex.1. Use fourth order Runge- Kutta method to solve log x y , y 1 2 to find
dx
dy
Ex.2. Use fourth order Runge- Kutta method to solve x 2 y 2 , y 1 1.5 to find
dx
Find out the enthalpy at pressure 2.1 bar by Lagrange’s interpolation method.
x 1 2 3 4 5
x 2 6 10 14 18
dy
Estimate the values of y at x 2.05 and at x 14.5
dx
Obtain f (4.05) using Newton’s forward difference formula and f (4.35) using Newton’s
backward difference formula.
2
sin x
Q.5 Use Simpson’s 1/3 rule to evaluate
0
x
dx , by diving the interval into four parts.
sin 2
Q.6 Evaluate
0
5 4 cos
d taking h by using i)Trapezoidal rule.
6
ii)Simpson’s 3/8 rule.
dy
Q.7 Use Modified-Euler’s method to solve x y 2 , y (0) 1 . Find the value of
dx
y (0.2) and y (0.4) in steps of 0.2 using.
dy
Q.8 Using Modified-Euler’s method solves the equation x 2 y ; y (0) 1 to find y
dx
at x 1.2 correct to three decimal places taking h 0.2 .
dy 1
Q.9 Use Runge – Kutta method of fourth order to solve , y ( 0) 1
dx x y
y 1 3 8 16
dy x y
3. Given equation is with initial condition y (2) 2 and step size h 0.5 by Euler’s formula
dx x
y1 at x 2.5 is equal to 3 .First approximation y1(1) at x 2.5 calculated by modified Euler’s formula
is
A) 1.375 B) 4.5 C) 3.375 D) 3.05
dy
4. Given equation is x 2 y 2 with initial condition y (1) 1.5 and step size h 0.1 . k1 is
dx
calculated as 0.325. k2 is given by using Runge-Kutta method
A) 0.37554 B) 0.35791 C) 0.38664 D)
0.4252
5. Newton’s Gregory forward finite difference interpolation formula for a set of data points
xi x0 ih, i 0,1, 2, 3, , n is x x0 uh
xi , yi , i 0,1, 2, 3, , n with
u u 1 2 u u 1 u 2 3
A) y y0 u y0 y0 y0
2! 3!
u u 1 2 u u 1 u 2 3
B) y y0 u y0 y0 y0
2! 3!
u u 1 2 u u 1 u 2 3
C) y y0 u y0 y0 y0
2! 3!