Numerical
Numerical
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
To find : y at x = 1.
Interval : h = 0.2
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
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
1
dx 1
Here integrating function is e
Pdx 1
e x
e log x e log x
x
1 1
y 1 dx c
x x
y
log x c
x
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
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
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.
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 y1n at x1 in step I become the initial conditions for step II i.e at x0 , y0.
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 31 3
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.153 3.5 1 3 3.5 1.1625
2
0.05
1.1625 0.05 31.1625 3.5375 1 3 3.5375 1.1634
2
0.05
1.1634 0.05 31.634 3.5402 1 3 3.5402 1.1635
2
0.05
1.1635 0.05 31.635 3.5405 1 3 3.5405 1.1635
2
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 31.3405 4.1215 1.1635 3.5405 4.1215 1.3551
2
0.05
1.3551 0.1 31.3551 4.1653 1.1635 3.5405 4.1653 1.3561
2
0.05
1.3561 0.1 31.3561 4.1683 1.1635 3.5405 4.1683 1.3562
2
0.05
1.3562 0.1 31.3562 4.1686 1.1635 3.5405 4.1686 1.3562
2
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
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
1e 30
0e 30 e 30 c c
10
3 9 9
x 1 10 3 x
Hence y e
3 9 9
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 , y0 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
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 12 0. 4
h k 0.2 0. 4
k 2 hf x0 , y0 1 0.2 1 2 0.21.12.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.12.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 20.4840 20.4932 0.5984
6
= 0.4921 .
y y0 k 2 0.4921 2.4921
h k 0.2 0.5981
k 2 hf x0 , y0 1 0.2 1.2 2.4921 0.21.32.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.32.8550 0.7423
2 2 2 2
1
Now k k1 2k2 2k3 k4
6
1
= 0.5981 20.7257 20.7423 0.9056
6
= 0.7400 .
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
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
1
Now k k1 2k 2 2k3 k 4
6
1
= 0.1 20.11525 20.11686 0.13474
6
= 0.1165
y y0 k 1 0.1165 1.1165
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
1
Now k k1 2k 2 2k3 k 4
6
1
= 0.13466 20.15514 20.15758 0.18233
6
= 0.1571.
Therefore y = y0 + k = 1.1165 + 0.1571 = 1.2736.
dy
3x y 2 , x 0 1, y 0 1.2 at x 1.1 Ans: 1.7271
dx
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
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