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

4.3 Intial Value Problems For Ordinary Differential Equations

The document discusses numerical methods for solving initial value problems in ordinary differential equations, focusing on single-step and multi-step methods. It details the Taylor series method for approximating solutions and provides examples, followed by an explanation of Euler's method and modified Euler's method for improved accuracy. The document includes exercises for practice and highlights the limitations of these methods in terms of accuracy and computational efficiency.

Uploaded by

batmanflyinsky
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)
29 views11 pages

4.3 Intial Value Problems For Ordinary Differential Equations

The document discusses numerical methods for solving initial value problems in ordinary differential equations, focusing on single-step and multi-step methods. It details the Taylor series method for approximating solutions and provides examples, followed by an explanation of Euler's method and modified Euler's method for improved accuracy. The document includes exercises for practice and highlights the limitations of these methods in terms of accuracy and computational efficiency.

Uploaded by

batmanflyinsky
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

4.

3 Initial Value Problems for Ordinary Differential Equations

Introduction :

The analytic methods of solving differential equations are applicable only to


limited class of equations. The differential equations appearing in physical
problems do not fall into the category of familiar types. Therefore one has to
study numerical method to solve such equations. Basically a first order
differential equation of the form
y = f(x,y), y(x 0 ) = y0 ………………….. (1)
is to be solved numerically by different methods. The methods for the solution
of the initial value problem (1) can be classified mainly into two types. They
are single step method and multi step methods. In single step methods, the
solution at any point Xi+1 is obtained using the solution at only the previous
point xi where as in multistep method the solution is obtained using the
solution at a number of previous points. These methods yield the solution in one
of the two forms:
(i) A series for y in terms of powers of x, from which the value of y can
be obtained by direct substitution.
(ii) A set of tabulated values of x and y.

Taylor Series Method :


Here, we describe the method to solve the initial value problems using Taylor
series method. This method is the fundamental numerical method for the
solution of initial value problems (1).

Consider the differential equation (1)


Let y = y(x) be a continuously differentiable function satisfying the equation
(1). Expanding y in terms of Taylor series around the point x = x 0, we get
(x-x 0 )2 '' (x-x 0 )3 '''
y = y0 + (x-x 0 )y'0 + y0 + y0 +........... (2)
2! 3!
The value of the differential coefficients y'0 , y''0 , y'''0 , .......... at x = x 0
can be computed from the equation y' = f(x,y)

Example : 1 : Use Taylor series method to find y(0.1) and y (0.2) from the
equation
y' = y2 + x, y(0) =1
Solution : Given
y'=y 2 + x, y(0) =1
 f(x,y) =y 2 + x, x 0 =0, y0 =1

y'0 =12 + 0=1,


y''=2yy' +1  y''0 =2.1.1+1=3
y'''= 2 (y')2 + 2y y''  y''' =2(1)2 + 2.1.3 = 8
0

y = 4y'y''+2yy' = 6y'y''+ 2yy'''  y0iv  = 6.1.3 + 2.1.8 = 34


 iv 

Thus the Taylor's series solution is


 2 3 4 
y = y0 +  xy'0 + x y''0 + x y'''0 + x yiv  +............ 
 2! 3! 4! 

= 1 + x + 3 x 2 + 4 x 3 + 17 x 4 + 31 x 5 +............
2 3 12 20

 y (0.1) = 1.11647 and y(0.2) = 1.2735


Example 2 : By Taylor’s series method, find the value of y at x = 0.1
and x = 0.2 to five decimal places from
dy =x 2 y-1, y(0) =1
dx
Solution : Here
y = x 2 y-1, y0 =1, x 0 =0
differenting successively and substituting, we get
y'=x 2 y-1  y' = -1 0

y''=2xy + x 2 y'  y''0 = 0


y''' = 2y + 4x y'+ x 2 y''  y''' = 2
0
y iv  = 6y' + 6x y'' + x 2 y'''  y0iv  = -6 and so on.

Thus by Taylor's series method


2 3 4
y=1+x(-1)+ x (0)+ x (2)+ x (-6)+.............
2! 3! 4!
3 4
= 1-x + x - x +....................
3 4

Hence y(0.1) = 0.90033 and y(0.2) = 0.80227.


Exercises : Use Taylor series method to solve the differential equations
numerically correct to three decimal places.

(i) dy = 1 + xy, y(0) =1 at x = 0.1


dx
(ii) dy = 1 , y(4) = 4. Find y at x = 4.1 and 4.2
dx x 2 +y

Euler’s Method :

In Taylor series method, we express a series for y in terms of powers of


x, from which the value of y can be obtained by direct substitution. As
the approximation is poor, we derive Euler method by using Taylor series
method, where the values of y are computed by short steps ahead for equal
intervals h of the independent variable.
dy
Consider the differential equation  f (x, y)
dx
with the initial condition y(x 0 )  y 0 .
If y(x) is the exact solution of the above equation, then the Taylor’s
series for y(x) around x  x 0 is given by
(x  x 0 ) 2 11
y(x)  y 0  (x  x 0 )y 01  y0  . . .
2!

Neglecting second and higher order terms, we get

y(x)  y0  (x  x 0 )y 0 ' .

Denoting x  x 0  h , we get y(x 0  h)  y 0  h y(x 0 ) ' where y(x 0 )'  f (x 0 , y0 ) .


Taking x1  x 0  h , we get y1  y0  h f (x 0 , y 0 ) .

Similarly y 2  y1  h f (x1 , y1 ) .

Proceeding in this way , for x n 1  x n  h , we obtain the general formula


y n 1  y n  h f (x n , y n ) .

Example 1. Using Euler’s method, find an approximate value of y


dy
corresponding to x=1, given that  x  y and y  1 when x  0 .
dx
Solution. Let us take n=10 and h=0.1 . The various calculations are
arranged as follows.

x y x  y  dy dx old y  0.1(dy dx)  new y


0 1 1 1+0.1(1.00)=1.10
0.1 1.1 1.20 1.10+0.1(1.20)=1.22
0.2 1.22 1.42 1.22+0.1(1.42)=1.362
0.3 1.362 1.662 1.362+0.1(1.662)=1.5282
0.4 1.5282 1.9282 1.5282+0.1(1.9282)=1.7210
0.5 1.7210 2.2210 1.7210+0.1(2.2210)=1.9431
0.6 1.9431 2.5431 1.9431+0.1(2.5431)=2.1974
0.7 2.1974 2.8974 2.1974+0.1(2.8974)=2.4871
0.8 2.4871 3.2871 2.4871+0.1(3.2871)=2.8158
0.9 2.8158 3.7158 2.8158+0.1(3.7158)=3.1874
1.0 3.1874
Thus the required approximate value of y=3.1874.

dy y  x
Example 2. Given  with initial condition y  1 at x  0 : find
dx y  x
y for x  1 By Euler’s method.
Solution. We divide the interval (0, 0.1) into five steps. The various
calculations are arranged as follows:

x Y dy/dx=(y-x)/(y+x) Old y+0.02(dy/dx)=new y


0 1 1 1.02
0.02 1.02 0.9615 1.0392
0.04 1.0392 .926 1.0577
0.06 1.0577 0.893 1.0756
0.08 1.0756 0.862 1.0928
0.10 1.0928
Hence the required approximate value of y = 1.0928.

Remark :

The process is very slow and to obtain reasonable accuracy with Euler’s
method, we need to take a smaller value for h. Because of this restriction
on h, the method is unsuitable for practical use a modification of it,
known as modified Euler’s method, which gives more accurate results.

Modified Euler’s method :

Instead of approximating f (x, y) by f (x 0 , y 0 ) , we approximate the integral


h
by means of Trapezoidal rule to obtain y1  y 0  f (x 0 , y 0 )  f (x1 , y1(0) )  .
2
We thus obtain the iteration formula
h
y1(n 1)  y 0   f (x 0 , y0 )  f (x1 , y1(n ) )  , n  0,1, 2,...
2
Where y1(n ) is the nth approximation to y1 , which can be found using
Euler’s formula y1(0)  y 0  hf (x 0 , y 0 ) .

dy
Example 1. Using modified Euler’s method , Solve  x2  y , y(0)  1 .
dx
Choose h= 0.05, Compute y(0.1). Modify the solution twice
in each step.
Solution : x 0  0, y0  1 and f (x 0 , y 0 )  x 0 2  y 0  1

 y1(0)  y 0  h f (x 0 , y 0 )  1.05 .

For x1  0.05, f (x1 , y1(0) )  1.0525


h
 y1(1)  y 0  f (x 0 , y 0 )  f (x1 , y1(0) )   1.0513
2
h
Again modifying,  y1(2)  y 0  f (x 0 , y0 )  f (x1 , y1(1) )   1.0513 .
2

Taking x1  0.05, f (x1 , y1 )  1.0538  y 2 (0)  y1  h f (x1 , y1 )  1.10399 .

h
Then y 2(1)  y1  f (x1 , y1 )  f (x 2 , y 2(0) )   1.10549
2
h
Again modifying y 2 (2)  y1   f (x1 , y1 )  f (x 2 , y 2 (1) )   1.1055 .
2

Hence the required approximate value of y(0.1)=1.1055.

Example 2. Using Modified Euler’s method, find an approximate value


dy
of y when x=0.3, given that  x  y and y  1 when x  0 , taking
dx
h=0.1.

Solution. Given x 0  0, x1  0.1, x 2  0.2, x 3  0.3 and y 0  1 .

Using Euler’s method, y1(0)  y 0  h f (x 0 , y 0 )  1.1 .

Modifying using modified Euler’s method,


h
y1(1)  y0   f (x 0 , y0 )  f (x1 , y1(0) )   1.11 .
2

h
y1(2)  y0   f (x 0 , y 0 )  f (x1 , y1(1) )   1.1105
2

h
y1(3)  y 0   f (x 0 , y 0 )  f (x1 , y1(2) )   1.1105 .
2

y 2 (0)  y1  h f (x1 , y1 )  1.2316

h
y 2 (1)  y1  f (x1 , y1 )  f (x 2 , y 2 (0) )   1.2426
2

h
y 2 (2)  y1   f (x1 , y1 )  f (x 2 , y 2 (1) )   1.2432
2

h
y 2 (3)  y1   f (x1 , y1 )  f (x 2 , y 2 (2) )   1.2432 .
2

y 3(0)  y 2  h f (x 2 , y 2 )  1.3875
h
y3(1)  y 2   f (x 2 , y 2 )  f (x 3 , y3(0) )   1.3997
2

h
y3(2)  y 2  f (x 2 , y 2 )  f (x 3 , y3(1) )   1.4003
2

h
y3(3)  y 2  f (x 2 , y 2 )  f (x 3 , y3(2) )   1.4004 .
2

 The required approximate value of y(0.3)=1.4004.

dy
Example 3 : Solve the following differential equation  log10 (x  y) ,
dx
y(0)  2 at x  0.6 and 0.8 with h  0.2 .

Solution : Given x 0  0, x1  0.2, x 2  0.4, x 3  0.6, x 4  0.8 and y0  2 .

Using Euler’s method, y1(0)  y 0  h f (x 0 , y 0 )  2.0602 .

Modifying using modified Euler’s method,


h
y1(1)  y0  f (x 0 , y 0 )  f (x1 , y1(0) )   2.0655 .
2

h
y1(2)  y 0  f (x 0 , y 0 )  f (x1 , y1(1) )   2.0656
2

y 2 (0)  y1  h f (x1 , y1 )  2.1366

h
y 2 (1)  y1   f (x1 , y1 )  f (x 2 , y 2 (0) )   2.1455
2

h
y 2 (2)  y1   f (x1 , y1 )  f (x 2 , y 2 (1) )   2.1416
2

y 3(0)  y 2  h f (x 2 , y 2 )  2.2226

h
y3(1)  y 2  f (x 2 , y 2 )  f (x 3 , y3(0) )   2.2272
2

h
y3(2)  y 2  f (x 2 , y 2 )  f (x 3 , y 3(1) )   2.2272
2

y 4 (0)  y 3  h f (x 3 , y 3 )  2.3175
h
y 4 (1)  y 3  f (x 3 , y 3 )  f (x 4 , y 4 (0) )   2.3217
2

h
y 4 (2)  y3  f (x 3 , y3 )  f (x 4 , y 4 (1) )   2.3217 .
2

 y(0.6)  2.2272 and y(0.8)  2.3217 approximately.

Note: In Euler method, the interval length h should be kept small and
hence these methods can be applied for tabulating y over a limited range
only.

Exercise

1. Using Euler’s method, find the approximate value of y, when


dy
 x 2  y 2 and y  1 when x  0 , in five steps, taking h=0.2.
dx

dy
2. Given that  2  xy and y=1 when x=0. Find the approximate value
dx
of y at x=2 in steps of 0.2, using Euler’s modified method.

Runge-Kutta Methods

Introduction:

Euler’s method is less efficient in practical problems since it requires ‘h’ to be


small for obtaining reasonable accuracy. The Runge-Kutta methods are
designed to give greater accuracy and they possess the advantage of requiring
only the function value at some selected points on the subinterval. The basic
idea of R-K methods is to approximate the integral by a weighted average of
slopes and approximate slopes at a number of points in the interval [ x i, x i+1]

I. Runge – Kutta Method of Second Order:

𝐝𝐲
Consider the initial value problem = 𝐟(𝐱, 𝐲), 𝐲(𝐱 𝟎 ) = 𝐲𝟎 .
𝐝𝐱

The second order R-K method formula is given by,


𝟏
That is the value of y at x = xi is : 𝐲𝟏 = 𝐲𝟎 + (𝐤 𝟏 + 𝐤 𝟐 ).
𝟐
Where, 𝐤 𝟏 = 𝐡𝐟(𝐱 𝟎 , 𝐲𝟎 )
𝐤 𝟐 = 𝐡𝐟(𝐱 𝟎 + 𝐡, 𝐲𝟎 + 𝐤 𝟏 ).

𝐝𝐲
Example 1 : Given = 𝐲 − 𝐱 where 𝐲(𝟎) = 𝟐, find 𝐲(𝟎. 𝟏) and
𝐝𝐱
𝐲(𝟎. 𝟐)correct to four decimal places.

Solution: With h=0.1, 𝐟(𝐱, 𝐲) = 𝐲 − 𝐱, 𝐱 𝟎 = 𝟎, 𝐲𝟎 = 𝟐


We have R-K method order two formula y = y + (k + k ).
Where 𝐤 𝟏 = 𝐡𝐟(𝐱 𝟎 , 𝐲𝟎 )
𝐤 𝟐 = 𝐡𝐟(𝐱 𝟎 + 𝐡, 𝐲𝟎 + 𝐤 𝟏 ).
We get 𝐤 𝟏 = 𝟎. 𝟐 and 𝐤 𝟐 = 𝟎. 𝟐𝟏
𝟏
𝐲𝟏 = 𝐲(𝟎. 𝟏) = 𝟐 + (𝟎. 𝟐 + 𝟎. 𝟐𝟏) = 𝟐. 𝟐𝟎𝟓𝟎.
𝟐
To determine 𝒚𝟐 = 𝒚(𝟎. 𝟐) we note that 𝒙𝟎 = 𝟎. 𝟏 and 𝒚𝟎 = 𝟐. 𝟐𝟎𝟓𝟎
𝟏
Hence 𝒚𝟐 = 𝒚(𝟎. 𝟐) = 𝟐. 𝟐𝟎𝟓𝟎 + (𝟎. 𝟐𝟏𝟎𝟓 + 𝟎. 𝟐𝟐𝟏𝟓𝟓) = 𝟐. 𝟒𝟐𝟏𝟎.
𝟐

Example 2 : Solve 𝐲(𝟏. 𝟐) given 𝐲 = 𝐱 + 𝐲 + 𝐱𝐲 with y(𝟏) = 𝟏 take


𝐡 = 𝟎. 𝟏

Solution: Given 𝐟(𝐱, 𝐲) = 𝐱 + 𝐲 + 𝐱𝐲, 𝐡 = 𝟎. 𝟏, 𝐱 𝟎 = 𝟏, 𝐲𝟎 = 𝟏


𝟏
We have R-K method order two formula𝐲𝟏 = 𝐲𝟎 + (𝐤 𝟏 + 𝐤 𝟐 ).
𝟐
Where 𝐤 𝟏 = 𝐡𝐟(𝐱 𝟎 , 𝐲𝟎 )
𝐤 𝟐 = 𝐡𝐟(𝐱 𝟎 + 𝐡, 𝐲𝟎 + 𝐤 𝟏 ).
We get 𝐤 𝟏 = 𝟎. 𝟑 and 𝐤 𝟐 = 𝟎. 𝟑𝟖𝟑
𝟏
𝐲𝟏 = 𝐲(𝟏. 𝟏) = 𝟏 + (𝟎. 𝟑 + 𝟎. 𝟑𝟖𝟑) = 𝟏. 𝟑𝟒𝟏𝟓
𝟐
To determine 𝐲𝟐 = 𝐲(𝟏. 𝟐) we note that 𝐱 𝟎 = 𝟏. 𝟏 and 𝐲𝟎 = 𝟏. 𝟑𝟒𝟏𝟓
𝟏
Hence 𝐲𝟐 = 𝐲(𝟏. 𝟐) = 𝟏. 𝟑𝟒𝟏𝟓 + (𝟎. 𝟑𝟗𝟏𝟕 + 𝟎. 𝟓𝟎𝟏𝟑) = 𝟏. 𝟕𝟖𝟖𝟎𝟏.
𝟐

II. Runge-Kutta Method of fourth order:

The most commonly used RK method is a method which uses four slopes and is
called R-K method of fourth order. The method is given by :

𝐝𝐲
Consider the Ordinary Differential Equation = 𝐟(𝐱, 𝐲), 𝐲(𝐱 𝟎 ) = 𝐲𝟎 .
𝐝𝐱
We need to find ‘y’ at 𝐱 𝐧 = 𝐱 𝟎 + 𝐧𝐡. The fourth-order Runge-Kutta
method formula is given by
𝟏
𝐲𝟏 = 𝐲(𝐱 𝟎 + 𝐡) = 𝐲𝟎 + (𝐤 𝟏 + 𝟐𝐤 𝟐 + 𝟐𝐤 𝟑 + 𝐤 𝟒 )
𝟔

Where 𝐤 𝟏 = 𝐡𝐟(𝐱 𝟎 , 𝐲𝟎 )
𝐡 𝐤
𝐤 𝟐 = 𝐡𝐟(𝐱 𝟎 + , 𝐲𝟎 + 𝟏 )
𝟐 𝟐
𝐡 𝐤𝟐
𝐤 𝟑 = 𝐡𝐟(𝐱 𝟎 + , 𝐲𝟎 + )
𝟐 𝟐
𝐤 𝟒 = 𝐡𝐟(𝐱 𝟎 + 𝐡, 𝐲𝟎 + 𝐤 𝟑 ).

𝐝𝐲 𝐲
Example 1 : Given = 𝟑𝐱 + , 𝐲(𝟎) = 𝟏 compute y (0.2) by taking h =
𝐝𝐱 𝟐
0.2 using Runge-Kutta method of fourth order.
Solution:
Given f(x, y) = 3x + , x = 0, y = 1, h = 0.2
k = hf(x , y ) = 0.2f(0,1) = (0.2)(3 × 0 + ) = 0.1
k = hf x + , y + = 0.2f(0.1, 1.05) = 0.165
k = hf x + , y + = (0.2)f(0.1, 1.0825) = 0.16825
k = hf(x + h, y + k ) = 0.2f(0.2, 1.16825) = 0.236825

Therefore 𝑦(0.2) = 𝑦 + (𝑘 + 2𝑘 + 2𝑘 + 𝑘 ) = 1.1672208

Example 2 : Use fourth order R-K method to solve (𝑥 + 𝑦) = 1,


𝑦(0.4) = 1 at x = 0.5, 0.6, 0.7 correct to four decimal places.

Solution:
By data we have f(x, y) = , x = 0.4, y = 1, h = 0.1

k = hf(x , y ) = 0.1f(0.4, 1) = (0.1) = 0.0714


.

k = hf x + , y + = 0.1f(0.45, 1.0357) = 0.0673


k = hf x + , y + = (0.1)f(0.45, 1.03365) = 0.0674
k = hf(x + h, y + k ) = 0.1f(0.5, 1.0674) = 0.0638

Therefore y(0.5) = y + (k + 2k + 2k + k ) = 1.0674.


To compute y(0.6) we use x = 0.5, y = 1.0674.

k = hf(x , y ) = 0.1f(0.5, 1.0674) = 0.0651


k = hf x + , y + = 0.1f(0.55, 1.0999) = 0.0606
k = hf x + , y + = (0.1)f(0.55, 1.0977) = 0.0607
k = hf(x + h, y + k ) = 0.1f(0.6, 1.0674) = 0.05786

Therefore y(0.6) = y + (k + 2k + 2k + k ) = 1.1283.

Example 2 : Use fourth order Runge-Kutta method to solve


= , 𝑦(0) = 1 at x = 0.2 taking h = 0.2.

Solution:
By data we have 𝑓(𝑥, 𝑦) = , 𝑥 = 0, 𝑦 = 1, ℎ = 0.2

𝑘 = ℎ𝑓(𝑥 , 𝑦 ) = 0.2𝑓(0, 1) = (0.2) = 0.2


𝑘 = ℎ𝑓 𝑥 + , 𝑦 + = (0.2)𝑓(0.1, 1.1) = 0.1667
𝑘 = ℎ𝑓 𝑥 + , 𝑦 + = (0.2)𝑓(0.1, 1.0835) = 0.1662
𝑘 = ℎ𝑓(𝑥 + ℎ, 𝑦 + 𝑘 ) = (0.2)𝑓(0.1, 1.1662) = 0.1414

Therefore 𝑦(0.5) = 𝑦 + (𝑘 + 2𝑘 + 2𝑘 + 𝑘 ) = 1.1679

Exercise :

1) Use fourth order Runge-Kutta method to find y(1.1) given that =


𝑥𝑦 , 𝑦(1) = 1

2) Use fourth order Runge-Kutta method to solve + 𝑦 = 2𝑥 𝑎𝑡 𝑥 = 1.1


given that y=3 at x = 1 initially.

You might also like