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

Numerical

The document discusses numerical solutions of ordinary differential equations, focusing on methods such as Euler's Method, Euler's Modified Method (Runge Kutta), and Taylor's Method. It provides step-by-step instructions for applying these methods to specific differential equations, including examples and calculations for approximating values. Additionally, it includes classwork and homework problems for practice with these numerical methods.

Uploaded by

bilalsz281919
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Numerical

The document discusses numerical solutions of ordinary differential equations, focusing on methods such as Euler's Method, Euler's Modified Method (Runge Kutta), and Taylor's Method. It provides step-by-step instructions for applying these methods to specific differential equations, including examples and calculations for approximating values. Additionally, it includes classwork and homework problems for practice with these numerical methods.

Uploaded by

bilalsz281919
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

DIFFERENTIAL EQUATIONS 123

3.4. NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL


EQUATIONS(14)

Contents Question No Marks

Runga Kutta method 4(c) 08

Taylor’s/Euler’s /Euler’s modified method 5(b) 06

The four methods discussed in this section are as follows


1. Euler’s Method
2. Euler’s Modified Method or Runge Kutta Method of Second Order
3. Taylor’s Method
4. Runge- Kutta Method.

Euler’s Method

dy
Consider the differential equation = f (x, y) with the initial condition y = y0 at x = x0.The
dx

approximation is given by y n  yn 1  hf ( xn 1 , yn 1 )

dy
1. Express the given differential equation as  f  x, y 
dx
2. Write the initial conditions i.e.x0 , y0
3. To find y at x (given)
4. Write the interval h (if given)

x  x0
5. Find the number of steps ‘n’ using n  .
h

6. If h is not given and n is given then find h using h 


x  x0
n

1. Using Euler’s Method find the approximate value of y where


dy = x - y and y(0) = 1 at x = 1, taking
dx
h = 0.2
dy
Solution:- The given differential equation is  x  y  f  x, y 
dx
Initial Conditions : x0  0, y0  1

To find : y at x = 1.
Interval : h = 0.2

SHREE L R TIWARI COLLEGE OF ENGINEERING


124 APPLIED MATHEMATICS - II
The table is calculated as follows

No of steps xn yn f (xn , yn) = xn - yn yn+1= yn + h f (xn , yn)


1 0 1 -1 0.8
2 0.2 0.8 -0.6 0.68
3 0.4 0.68 -0.28 0.624
4 0.6 0.624 -0.024 0.6192
5 0.8 0.6912 -0.1808 0.6554
6 1.0 0.6554

dy y  x
2. Using Euler’s Method find the approximate value of y at x = 2 taking h = 0.2 given that 
dx x

and y1  2 . Also compare it with exact value.

dy y  x
Solution:- The given differential equation is   f  x, y 
dx x

Initial Conditions : x0  1, y0  2

To find : y at x = 2.
Interval : h = 0.2
The table is calculated as follows

yn  xn
No of steps xn yn f x n , y n   yn+1= yn + h f (xn , yn)
xn

1 1 2 1 2.2
2 1.2 2.2 0.8333 2.3667
3 1.4 2.3667 0.6905 2.5048
4 1.6 2.5048 0.5655 2.6179
5 1.8 2.6179 0.4544 2.7088
6 2.0 2.7088
Hence the approximate value of y is 2.7088 at x = 2.

dy y  x
Exact Solution: The given differential equation is 
dx x

dy y
  1
dx x

dy y
   1 which is a linear differential equation.
dx x

SHREE L R TIWARI COLLEGE OF ENGINEERING


DIFFERENTIAL EQUATIONS 125
dy 1
Comparing with  Py  Q we get P  , Q  1
dx x

 1 
   dx 1
Here integrating function is e 
Pdx 1
e  x 
 e log x  e log x 
x

Its solution is given by ye    Qe 


Pdx Pdx
dx  c

1 1
 y      1  dx  c
x  x

y
   log x  c
x

At initial condition x = 1 and y = 2, we get 2   log1  c  c  2

y
Hence   log x  2  y   x log x  2 x
x
At x = 2, we get y = 2.6137.
Classwork Problems

dy
1. Using Euler’s Method find the approximate value of y where   y with y (0) =1, taking h = 0.01
dx
at x = 0.04. Compare it with the exact value. Ans: 0.9606, 0.9608

dy
2. Using Euler’s Method find the approximate value of y where  1  y 2 with y (0) = 0 taking
dx
h = 0.2 at x = 1. Ans: 1.2941

dy y
3. Using Euler’s Method find the approximate value of y where  y 2  with y (1) =1, taking
dx x
h = 0.1 at x = 1.3,1.5. Compare it with the exact value. Ans: 1.0268, 1.0889
Homework Problems

dy y  x
1. Using Euler’s Method find the approximate value of y where  with y (0) =1, taking h = 0.02
dx y  x

at x = 0.1. Ans: 1.0927

dy y  x
2. Using Euler’s Method find the approximate value of y where  with y (1) = 2, taking h = 0.1
dx xy
at x = 1.5. Ans: 2.29409

dy
3. Using Euler’s Method find the approximate value of y where  x  y with y (0) =1, taking h = 0.1
dx
at x = 1. Ans: 3.18

SHREE L R TIWARI COLLEGE OF ENGINEERING


126 APPLIED MATHEMATICS - II

dy
4. Using Euler’s Method find the approximate value of y where  x  2 y with y (1) =1, taking h = 0.2
dx
at x = 2. Ans: 8.1619
dy
5. Using Euler’s Method find the approximate value of y where  x  y  xy with y (0) =1, taking
dx
h = 0.025 at x = 0.1. Ans: 1.1468.

Euler’s Modified Method or Runge Kutta Method of Second Order


dy
Consider the differential equation = f (x, y) with the initial condition y = y0 at x = x0.
dx
h
The first approximation of y is given by y1
(1)
 y0   f x0 , y0   f x1 , y1  where
2

y1 = y0 + h f  x0 , y0  . Using this approximate value y1


(1)
in the place of y1 we get the second
h
approximation y1
( 2)
 y0 
2
 
f  x0 , y0   f x1 , y1
(1)

This process is continued till we do not find any difference between two approximation.

dy
1. Express the given differential equation as  f  x, y 
dx
2. Write the initial conditions i.e.x0 , y0
3. To find y at x(given)
4. Write the interval h (if given)
x  x0
5. Find the number of steps ‘n’ using n  .
h
x  x0
6. If h is not given then take n = 2 and find h using h 
2
Step I: From the initial conditions x0 , y0 find f(x0 , y0 ). Also find x1 = x0 + h and y1 = y0 + hf( x0 , y0 ).

Start with the approximation y1(1) and continue with the approximation till y1 n   y1 n 1 .

Step II: The above calculated y1n  at x1 in step I become the initial conditions for step II i.e at x0 , y0.

Then repeat the same procedure as in step I.


Note : If two values of y are required at 2 given x values (say x1 and x2) then h = x1 - x0 or h = x2 - x1
dy
1. Solve the following by Euler’s modified method = log(x + y), y(0)= 2 at x = 1.2 and 1.4 with
dx
h = 0.2.
dy
Solution:- The given differential equation is = log(x + y)
dx
Initial Conditions : x0  0, y0  2

To find : y at x = 1.2 and x = 1.4.


Interval : h = 0.2

SHREE L R TIWARI COLLEGE OF ENGINEERING


DIFFERENTIAL EQUATIONS 127
Various calculations are arranged as follows
dy
x = log(x+y) Mean slope Oldy + 0.2 (mean slope) = new y
dx
0.0 log (0 + 2) — 2 + 0.2 (0.301) = 2.0602
1
0.2 log (0.2 + 2-0602) (0 301 + 0-3541) 2 + 0.2(0.3276) = 2.0655
2
1
0.2 log (0.2 + 2 0655) (0 301 + 0 3552) 2 + 0.2(0.3281) = 2.0656
2
0.2 0.3552 — 2.0656 + 0.2(0.3552) = 2.1366
1
0.4 log (0.4 + 2.1366) (0 3552+ 0 4042) 2.0656 + 0.2(0.3797) = 2.1415
2
1
0.4 log (0.4 + 2.1415) (0-3552 +0 4051) 2.0656 + 0.2(0.3801) = 2.1416
2
0.4 0.4051 — 2.1416 + 0.2(0.4051) = 2.2226
1
0.6 log (0.6 + 2.2226) (0 4051+ 0-4506) 2.1416 + 0.2(0.4279) = 2.2272
2
1
0.6 log (0.6 + 2.2272) (0 4051+0-4514) 2.1416 + 0.2(0.4282) = 2.2272
2
0.6 0.4514 — 2.2272 + 0.2(0.4514) = 2.3175
1
0.8 log (0.8 + 2.3175) (0-4514 + 0-4938) 2.2272 + 0.2(0.4726) = 2.3217
2
1
0.8 log (0.8 + 2.3217) (0-4514+ 0-4943) 2.2272 + 0.2(0.4727) = 2.3217
2
0.8 0.4943 — 2.3217 + 0.2(0.4943) = 2.4206
1
1.0 log (1 + 2.4206) (0 4943 + 0 5341) 2.3217 + 0.2(0.5142) = 2.4245
2
1
1.0 log (1 + 2.4245) (0 4943+0-5346) 2.3217 + 0.2(0.5144) = 2.4245
2
1.0 0.5346 — 2.4245 + 0.2(0.5346) = 2.5314
1
1.2 log (1.2 + 2.5314) (0-5346 + 0-5719) 2 .4245 + 0.2(0.5532) = 2.5351
2
1
1.2 log (1.2 + 2.5351) (0-5346 + 0-5723) 2.4245 + 0.2(0.5534) = 2.5351
2
1.2 0.5723 — 2-5351 + 0-2(0 5723) = 2.6496
1
1.4 log (1.4 + 2.6496) (0-5723 + 0-6074) 2.5351 + 0.2(0.5898) = 2.6531
2
1
1.4 log (1.4 + 2.6531) (Q 5723 + 0 6078) 2.5351 + 0.2(0.5900) = 2.6531
2

Hence y(1.2) = 2.5351 and y(1.4)= 2.6531 approximately.

SHREE L R TIWARI COLLEGE OF ENGINEERING


128 APPLIED MATHEMATICS - II

dy
2. Solve  x  3 y with x0  0, y0  1 by Euler’s modified formula for x = 0.1 taking h = 0.05. Also
dx
find the exact value.

dy
Solution:- The given differential equation is  x  3 y  f  x, y 
dx

Initial Conditions : x0  0, y0  1

To find : y at x = 0.1.
Interval : h = 0.05.

Step I : At x0  0, y0  2

f  x0 , y0   x0  3 y0  0  31  3

Also x1  x0  h  0  0.05  0.05 and y1  y0  h f  x0 , y0   1  0.053  1.15

The table is calculated as below

h
y1
n 

f x1 , y1
n 
 x  3y  
1 1
n y1
( n 1)
 y0 
2
 
f  x0 , y0   f x1 , y1
n 

0.05
1.15 0.05  1.153  3.5 1 3  3.5   1.1625
2

0.05
1.1625 0.05  31.1625  3.5375 1 3  3.5375  1.1634
2

0.05
1.1634 0.05  31.634  3.5402 1 3  3.5402   1.1635
2

0.05
1.1635 0.05  31.635  3.5405 1 3  3.5405  1.1635
2

Hence the approximate value of y  1.1635 at x = 0. 05.

Step II : At x0  0.05, y0  1.1635

f  x0 , y0   x0  3 y0  0.05  31.1635  3.5405

Also x1  x0  h  0.05  0.05  0.1 and

y1  y0  h f  x0 , y0   1.1635  0.053.5405  1.3405

The table is calculated

SHREE L R TIWARI COLLEGE OF ENGINEERING


DIFFERENTIAL EQUATIONS 129

h
y1
n 

f x1 , y1
n 
 x  3y  
1 1
n y1
( n 1)
 y0 
2
 
f  x0 , y0   f x1 , y1
n 

0.05
1.3405 0.1  31.3405  4.1215 1.1635  3.5405  4.1215  1.3551
2

0.05
1.3551 0.1  31.3551  4.1653 1.1635  3.5405  4.1653  1.3561
2

0.05
1.3561 0.1  31.3561  4.1683 1.1635  3.5405  4.1683  1.3562
2

0.05
1.3562 0.1  31.3562  4.1686 1.1635  3.5405  4.1686  1.3562
2

Hence the approximate value of y = 1.3562 at x = 0.1.

dy
Exact Solution : The given differential equation is  x  3y
dx

dy
  3 y  x which is a linear differential equation.
dx

dy
Comparing with  Py  Q we get P  3, Q  x
dx

Here integrating function is e  3 dx


 e
Pdx
 e 3 x

Its solution is given by ye    Qe


Pdx Pdx
dx  c

 ye 3 x    x e 3 x dx  c

 e 3 x   e 3 x 
 ye 3 x   x    1   c
 3   9 

xe 3 x e 3 x
 ye 3 x    c
3 9

At initial conditions x0  0, y0  1 , we get

 1e 30   
0e 30   e 30   c  c
10
3 9 9

x 1 10 3 x
Hence y     e
3 9 9

SHREE L R TIWARI COLLEGE OF ENGINEERING


130 APPLIED MATHEMATICS - II

0.1  1  10 e 0.3
At x = 0.1, we get y   = 1.3544
3 9 9
Thus the value of y = 1.3544 at x = 0.1

Classwork Problems

1. Use Euler’s Modified Method to find the value of y up to 4 places of decimals satisfying the equation:

dy
(i)  x 2  y , y0   1 for x = 0.02, 0.04, 0.06 Ans:1.020, 1.0406, 1.0616
dx
dy
(ii)  x  y , y (0 .1)  1 .1104 for x  0.15 and x  0.2 Ans:1.3107, 1.3869
dx
dy
(iii) x y , y (0)  1 for x  0.2 Ans:1.2309
dx
dy
(iv)  2 x  y, y (0)  1 for x  0.2 . also compare with exact value
dx
Ans: -0.7818, -0.7813
Homework Problems
1. Using Euler’s Modified Method i.e. Runge-Kutta Method of second order to find the value of y

dy
satisfying the equation  log( x  y ), y (1)  2 for x  1.2 & x  1.4 correct to four decimal
dx
places by taking h = 0.2. Ans: 2.2332, 2.4924

dy
2. Solve  2  xy with x 0  1.2, y 0  1.6403 by Euler’s Modified formula i.e. by Runge-Kutta
dx
method of second order for x  1.6 correct to four places of decimals by taking h = 0.2
Ans: 2.3625, 3.1695

dy
3. Determine the value of y when x  0.1 given that y (0) = 1 and  x 2  y by Euler’s Modified
dx
Method i.e. Runge-Kutta Method of second order correct to four places of decimals, taking h = 0.05
Ans:1.0513, 1.10553

dy
4. Solve  x  3 y with x0  0, y0  1 by Euler’s modified formula . i. e. by Runge - Kutta Method
dx
of second order for (i) x = 0.1 correct to four places of decimals. Also find the exact value.
Ans:1.1635, 1.3548, 1.0835

5. Use Euler’s modified method to find y 0.1 from dy  y  2 x given, y 0   1 taking h = 0.1.
dx y

Ans:1.0957

SHREE L R TIWARI COLLEGE OF ENGINEERING


DIFFERENTIAL EQUATIONS 135
Runge Kutta Method Or Runge -Kutta Method of Fourth Order.

dy
Consider the differential equation = f (x,y) with the initial condition y = y0 at x = x0.
dx

dy
1. Express the given differential equation as  f  x, y 
dx
2. Write the initial conditions i.e.x0 , y0
3. To find y at x(given)
4. Write the interval h (if given)

x  x0
5. Find the number of steps ‘n’ using n  .
h
x  x0
6. If h is not given then take n = 2 and find h using h 
2
Step I: From the initial conditions x0 , y0 find f(x0 , y0 ).To find the value of y = y0 + k at x = x0 + h,
calculate.

k1  hf  x0 , y0 

 h k 
k 2  hf  x0  , y0  1 
 2 2

 h k 
k3  hf  x0  , y0  2 
 2 2
k 4  hf  x0  h, y0  k3 
1
Lastly we calculate k  k1  2k 2  2k3  k 4 
6
The required value of y = y0 + k
StepII: The value of y obtained at x in step I becomes the initial conditions for stepII. Repeat the above
procedure as in step I

dy
1. Solve  xy with initial conditions y(1) = 2 and find y at x = 1.2, 1.4 by Runge - Kutta Method of
dx
fourth order.

dy
Solution:- The given differential equation is  xy  f  x, y  .
dx
Initial conditions : x0 = 1, y0= 2.
To find : y at x = 1.2 and 1.4.
Interval : h = 1.2 - 1 = 0.2 or h = 1.4 - 1.2 = 0.2
Step I: At x0 = 1, y0= 2

k1  hf x 0 , y 0   0 .2 12   0. 4

SHREE L R TIWARI COLLEGE OF ENGINEERING


136 APPLIED MATHEMATICS - II

 h k   0.2  0. 4  
k 2  hf  x0  , y0  1   0.2 1   2    0.21.12.2   0.4840
 2 2  2  2 

 h k   0.2  0.4840 
k3  hf  x0  , y0  2   0.2 1   2    0.2 1.12.2420   0.4932
 2 2  2  2 
k 4  hf  x0  h, y0  k3   0.2 1  0.2 2  0.4932   0.2 1.2 2.4932  0.5984
1
Now k  k1  2k 2  2k3  k 4 
6
1
= 0.4  20.4840   20.4932  0.5984
6
= 0.4921 .

 y  y0  k  2  0.4921  2.4921

Hence y  2.4921 at x = 1.2

Step II: Now x0  1.2, y0  2.4921

k1  hf  x0 , y0   0.2 1.2 2.4921  0.5981

 h k   0.2  0.5981 
k 2  hf  x0  , y0  1   0.2 1.2   2.4921    0.21.32.7912  0.7257
 2 2  2  2 

 h k   0.2  0.7257  
k3  hf  x0  , y0  2   0.2 1.2   2.4921    0.2 1.32.8550   0.7423
 2 2  2  2  

k 4  hf  x0  h, y0  k3   0.21.2  0.2 2.4921  0.7423  0.21.4 3.2344  0.9056

1
Now k  k1  2k2  2k3  k4 
6
1
= 0.5981  20.7257   20.7423  0.9056
6
= 0.7400 .

 y  y0  k  2.4921  0.7400  3.2321

Hence y  3.2321 at x = 1.4

dy
2. Apply Runge Kutta of fourth order to find an approximate value of y at x = 0.2 if = x + y2, given
dx
that y = 1 when x = 0 in steps of h = 0.1.
dy
Solution:- The given differential equation is = x + y2 = f(x,y)
dx
Initial Conditions : x0 = 0, y0 = 1
To find : y at x = 0.2

SHREE L R TIWARI COLLEGE OF ENGINEERING


DIFFERENTIAL EQUATIONS 137
Interval : h = 0.1
Step I : At x0 = 0, y0 = 1

k1  hf  x0 , y0  = 0.1 [0 + 12] = 0.1.

 h k 
k 2  hf  x0  , y0  1  = 0.1 [ (0 + 0.05) + (1 + 0.05)2 ] = 0.11525.
 2 2

 h k 
k3  hf  x0  , y0  2  = 0.1 [ (0 + 0.05) + ( 1 + 0.05762 )2 ] = 0.11686.
 2 2

k 4  hf  x0  h, y0  k3  = 0.1 [ ( 0 + 0.1 ) + ( 1 + 0.11686 )2 ] = 0.13474.

1
Now k  k1  2k 2  2k3  k 4 
6
1
= 0.1  20.11525  20.11686  0.13474
6
= 0.1165

 y  y0  k  1  0.1165  1.1165

Hence y  1.1165 at x = 0.1.

Step II: Now x0  0.1, y0  1.1165

k1  hf  x0 , y0  = 0.1 [0.1 + 1.11652] = 0.13466.

 h k 
k 2  hf  x0  , y0  1  = 0.1 [ (0.1 + 0.05) + (1.1165 + 0.06733)2 ] = 0.15514.
 2 2

 h k 
k3  hf  x0  , y0  2  = 0.1 [ (0.1 + 0.05) + ( 1.1165 + 0.0775762 )2 ] = 0.157581686.
 2 2

k 4  hf  x0  h, y0  k3  = 0.1 [ ( 0.1 + 0.1 ) + ( 1.1165 + 0.15758 )2 ] = 0.18233.

1
Now k  k1  2k 2  2k3  k 4 
6
1
= 0.13466  20.15514   20.15758  0.18233
6
= 0.1571.
Therefore y = y0 + k = 1.1165 + 0.1571 = 1.2736.

Hence y  1.2736 at x = 0.2


Classwork Problems
1. Apply Runge-Kutta method of fourth order to find an approximate value of y given that

dy
 3x  y 2 , x 0  1, y 0  1.2 at x  1.1 Ans: 1.7271
dx

SHREE L R TIWARI COLLEGE OF ENGINEERING


138 APPLIED MATHEMATICS - II
2. Apply Runge-Kutta method of fourth order to find an approximate value of y given that

dy
(i)  1  y 2 , x 0  0, y 0  0 at x  0.2,0.4 & 0.6 Ans: 0.2027, 0.4228, 0.6891
dx

dy
(ii)  x  y , x 0  0 .4 , y 0  0 .41 at x  0.8 in two steps. Ans: 0.8311
dx
3. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 0.2 if

dy
 x 2  y 2 given that y = 1 when x = 0 in steps of h = 0.1 Ans: 0.11146
dx
4. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 1.1 if

dy x  y
 given that y = 1 when x = 1 Ans: 1.19967
dx xy
5. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 0.1, 0.2 if

dy
 1  xy given that y = 2 when x = 0 Ans: -1.3714, -1.2844
dx
Homework Problems
1. Solve Numerically (Using Runge-Kutta method of fourth order formula) the differential equation

dy
 x 2  y 2 with the given condition x = 1, y = 1.5 in the interval (1,1.2) with h = 0.1
dx
Ans:1.8955, 2.5043

dy 1
2. Solve the differential equation  , x 0  0, y 0  1 for the interval (0,1) choosing h = 0.5
dx x y
by Runge-Kutta Method of fourth order Ans:1.3571, 1.5837

3. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 0.2 if

dy
 x  y 2 given that y = 1 when x = 0 in steps of h = 0.1. Ans: 1.1165, 1.2736
dx
4. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 0.2 if

dy y 2  x 2
 given that y = 1 when x = 0 Ans: 1.19598
dx y 2  x 2
5. Apply Runge-Kutta Method of fourth order to find an approximate value of y at x = 1.2, 1.4 if

dy
 xy given that y = 2 when x = 1. Ans: 2.492143, 3.23107.
dx

dy
6. Solve  xy with interval condition y (1) = 2 & 4 find the y at x = 1.2 & 1.4 by Runge-Kutta
dx
method of forth order Ans: 2.4921, 3.23107

SHREE L R TIWARI COLLEGE OF ENGINEERING

You might also like