Numerical Methods II
Numerical Methods II
y = f(x,y), y(x0 ) = y0
.. (1)
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
(ii)
y'''0 , .......... at x = x0
= 3 + 2 .(ii)
= 2 + 2( )2 (iii)
Given y(0)=1. So putting x=0 and y=1 we get from (i) (0) = 1
Putting x=0 and y=1 and (0) = 1 from (ii) we get (0) = 3 + 2(1)(1) = 5
Similarly, we get (0) = 12 from (iii).
Substituting these values in the above Taylor series expansion (2),we get
=1++
2
2!
(5) +
3
3!
(12) +.. .
(0.1)2
2!
(5) +
(0.1)3
3!
3 Decimal places.
Example 2.
Use Taylor series method to find y(0.1) and y (0.2) from the
2
2
2
2!
(1) +
4
8
6
48
3
3!
(0) +
4
4!
(3) +
5
5!
(0) +
6
6!
(15) +.. .
= 2 + 3 , y(0)=1 at x=0.1
ii)
Eulers 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.
Consider the differential equation
with the initial condition
If
dy
f (x, y)
dx
y(x 0 ) y0 .
y(x) is the exact solution of the above equation, then the Taylors
(x x 0 )2 11
y0 . . .
2!
Denoting
y(x 0 )' f (x 0 , y0 ) .
Taking x1 x 0 h , we get y1 y0 h f (x 0 , y0 ) .
Similarly
y2 y1 h f (x1 , y1 ) .
Solution. (, ) = + 2 .
+1 = + ( , ) = + 0.1( + 2) Let us take n=10 and h=0.1.
The various calculations are arranged as follows.
+ 2 =
1+0.1(3)=1.3
1.1 1.3
3.7
1.3+0.1(3.7)=1.67
1.2 1.67
4.54
1.67+0.1(4.54)=2.12
1.3 2.12
5.54
2.67
1.4 2.67
6.74
3.34
1.5 3.34
8.18
4.16
1.6 4.16
9.92
5.15
1.7 5.15
12
6.35
1.8 6.35
14.5
7.80
1.9 7.8
17.5
9.55
2.0 9.55
h
f (x 0 , y 0 ) f (x1, y1(n) ) , n 0,1, 2,...
2
y1(0) y0 hf (x 0 , y0 ) .
= + ,y(0)=1
(0)
= 0 + {(0 , 0 ) + (1 , 1 )}
2
=1+
0.2
2
(1)
(0)
= 1 + {(1 , 1 ) + (2 , 2 )}
= 1.2295 +
0.2
2
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 Eulers method, find the approximate value of y, when x=0.2 by
taking step length h=0.1. Given that
2. Solve the equation
= (1 + ),
= 1 ,
(0) = 1
length h=0.05.
Runge-Kutta Methods
Introduction:
Eulers 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 RK methods is to approximate the integral by a weighted average of slopes and
approximate slopes at a number of points in the interval [ xi, x i+1]
I. Runge Kutta Method of Second Order:
= (, ), ( ) = .
Where,
= ( , )
= ( + , + ).
Example 1. Apply RK method of order two to find the value of y when x=0.2,
given that
Solution. Here (, ) = +
k1= hf(x0,y0)=0.2
k 2 = hf(x0 + h, y0 + k1 ) = 0.2(0.2,1.2) = 0.2(1.4) = 0.28
1
= (, ), ( ) = .
We need to find y at
method formula is given by
= ( + ) = + ( + + + )
Where
= ( , )
= ( + , +
= ( + , +
)
)
= ( + , + ).
Example 1. Using 4th order Runge Kutta method , solve = + 2 with
y(0)=1 at x= 0.2 in steps of length h=0.1
Solution. Here (, ) = + 2
= ( + ) = + ( + + + ) we get
we get
y2 = y(0.4)= 0.2027074+1/6(0.208218 +2 (0.2188272 +2(0.21948319) +
0.235649) ) =0.42279.
Exercise :
= , (0) = 2
= 3 + 2, (0) = 0