Bakare Presentation
Bakare Presentation
BY
SEPTEMBER, 2020
CHAPTER ONE: INTRODUCTION
1.1 Background to the study
Euler’s method , which is an explicit method ,can always be used.
However it is a first order method , and the step length j=0,1. . has to be chosen
small in order that the method gives accurate result and is numerical stable.
The first approach is called Euler’s method and serves to illustrate the
concept involved in the advanced it has limited usage because of the
large error that is accumulated as the processes proceeds. However it is
important to study because the error analysis is easier to understand.
Euler’s method accumulates large error as the process proceeds. The
process is known to be very slow and in order to obtain reasonable
accuracy, the value of h needs to be smaller it can be slow that the error
in Euler method is yh( x) y(x) ,the error tends to zero as h , for [ x 0 , b]
fixed . The local truncation error of Euler’s explicitly method is N(h) The
global truncation error is N the total numerical error is the sum of the
global truncation error and the round- off error. The truncation error can
be reduced by using smaller x N ≤b x N +1>b . However, if yn+1=yn+hf(xn,yn) becomes too small
such that round-off errors become significant, the total error might
increase. It
is an essential family of implicit and explicit iterative methods needed for
approximations of solutions of ordinary differential equations which was
developed around 1900 by German Mathematicians C.Runge and M.W.
Kutta. It can used for equations of arbiters order by means of
transformation to a system of first-order equations. The greatest
disadvantage seems to be that it is rather difficult to estimate the error,
and further, the method does not offer any easy checking possibilities.
Using two slopes in the method, we have obtained methods of second
order, which we have as second order Runge-Kutta methods. The method
has one arbitrary parameter, whose value is suitably chosen. The methods
using four evaluations of slopes have two arbitrary parameters. The
values of these parameters are chosen such that the method becomes
simple for computations. One such choice gives the method. All these
methods are of fourth order, that is the truncation error is of order n=0,1,2 ,... .
The method is called the classical Runge-Kutta method of fourth order. If
we use five slopes, we do not get a fifth order method, but only a
fourth order method. It is due to this reason the classical fourth order
Runge-kutta method is preferred for computations . The classical Runge-
Kutta method is of order four uses four points. Runge-Kutta methods give
more accurate solution compare to simpler Euler’s explicitly method. The
accuracy increases with increasing order of Runge-Kutta method. Runge-
Kutta method is one of the most widely used method, and it is particularly
suitable in cases when the computation of higher derivatives is
complicated. It can be used for equations of arbitrary order by means of a
transformation to a system of first-order equations. The greatest
disadvantage seems to be that it is rather difficult to estimate the error,
and further, the method does not offer any easy checking possibilities.
The local truncation error in the Runge-Kutta method of order two is
y 0 =Y 0 . Note that this is smaller by a factor of Δyh than the truncation errors
in Euler’s explicit method . In order word, for the same accuracy, a larger
step size can be used. However, in each step the function Y in the
Runge-Kutta method of order two is computed twice. The local truncation
error in the classical Runge-Kutta method of order four is (x0)=f(x0 ,y0 ) , and the
global truncation error is Y(x1)−Y(x0)=Δy=hY ,this method gives the most accurate
solution compared to the other methods. Is the most accurate formula
available without extending outside the interval ( x 0 ) . While Runge-
Kutta methods give an improvement over Euler’s method in terms of
accuracy, this is achieved by investing additional computation effort;
infact, Runge-Kutta methods require more evaluations of Y(x1)=Y(x0)+hf(x0 ,Y (x0)) than
would seem necessary. The Runge-Kutta method of order four requires
four evaluations per step, where as Euler’s method requires only one
evaluation. Hence if the Runge-Kutta method of order four is to be
superior it should give more accurate answer than Euler’s method with
one-fourth the step size. Similarly, if the Runge-Kutta method of order
four is to be superior to the second-order Runge-Kutta methods which
require two evaluations per step it should give more accuracy with step
y =y+hf(x,y)
size [x1,x2],[x2,x3],. , than a second-order method with step size n+1 n n n .
The most popular one-step method with a constant step size is the fourth
order Runge-Kutta method . This is because the Runge-Kutta method can
achieve the accuracy of a Taylor Series approximation with out the need
for higher derivative calculations. This Runge-Kutta method can be
regarded as the basic form of order one- step methods. However, in terms
of error estimation, the one-step method with an adaptive step size like
the Runge-Kutta Fehlberg method. The Fehlberg Runge-Kutta method is a
method based on the calculation of two Runge-Kutta methods of different
order, by subtracting the results to get an estimate of the error. The one-
step Algorithm method with an adaptive step size automatically adjusts
the step size as a reaction to the calculation truncation errors. Runge-
Kutta Fehiberg method(RKF45) one way to guarantee accuracy in the
solution of an Initial Value Problem is to solve the problem twice using
y =Y
step size n=0,1,2 and 0 0 and compare answer at the mesh point corresponding
to the larger step size. But this requires a significant amount of
computation for the smaller step size and must be repeated if it is
determined that the agreement is not good enough. The Runge-Kutta
Fehlberg method (denoted by RKF45) is one way to try to resolve this
problem. It has a procedure to determine step size Y(xn+1) or x n is being used .
At each step, two different approximations for the solution are made and
compared. If the two answers are in close agreement, the approximation
is accepted. If the two answer do not agree to a specified accuracy, the
step size is reduced. If the answer agree to more significant digits than
required, the step size is increased.
Differential equations are commonly used for mathematical modeling
in science and engineering. Many problems for mathematical physics can
be stated in the form of differential equations. These equations also occur
as reformulations of other mathematical problems such as ordinary
differential equations and partial differential equations.
A differential equation is an equation that relates one or several
functions and its derivatives. Differential equations are used to model
advanced systems, for instance, mechanical and electrical systems from
fields such as biology, social sciences, engineering, economics. Mechanical
systems and electrical systems are two examples of physical system that
change over time. Differential equations are used to describe a continuous
change of physical system mathematically. Partial differential
equations(PDEs) and ordinary differential equations (ODEs) are two
classes of differential equations that are used to model and characterize the
behavior of physical systems. Parabolic PDEs exist in physical problems
such as heat conduction problem for solid bodies. Heat equations describe
how the heat temperature distributes in, for instance, a rode as the time
changes. Wave equations exist to be used to model physical problems such
as physical systems, where wave motions are considered . Numerical
methods are important to use to solve those differential equations whose
exact solutions are not possible to obtain using analytical methods.
Analytical methods such as the method of separation of variables give us
exact solutions of simple PDEs and ODEs, whereas numerical methods
give us approximations of the exact solution
Numerical methods are generally used for solving mathematical
problems that are formulated in science and engineering where it is
difficult or even impossible to obtain exact solutions. Only limited number
of differential equations can be solved analytically. There are many
analytical methods for finding the solution of ordinary differential
equations. Even then there exist a large number of ordinary differential
equations whose solutions cannot be obtained in closed form by using well
known analytical methods, where we have to use the numerical methods to
get the approximate solution of a differential equation under the prescribed
initial conditions. There are many types of practical numerical methods for
solving initial value problems for ordinary differential equations.
Numerical methods are explicit or implicit computed in one step or
multiple steps. An explicit method computes the numerical solution at the
next time point using the previous time point. While an implicit method
evaluates a function using the numerical solution at the next time point
which is solved for.
There are various numerical methods for solving PDEs and ODEs. The
method of lines is an example of a numerical method used to find
numerical solutions of hyperbolic and parabolic PDEs by transforming the
PDEs to a system of first-order ODEs which approximates the original
PDEs. Finite difference methods, finite element method, and finite volume
methods are examples of numerical methods that are used to approximate
the partial derivatives in PDEs. Finite difference methods such as Runge
Kutta methods are essential for finding approximate solutions of initial
value problems of first-order ODEs. High order Runge-Kutta methods are
used to solve ODEs because of their high accuracy and efficiency.
In this thesis, we present two standard numerical methods Euler and
Runge-Kutta for solving initial value problems of ordinary differential
equations.
y
Where
=f ( x , y )
Error Analysis-:
There are two types of errors in numerical solution of ordinary differential
equations. Round-off errors and truncation errors occur when ordinary
differential equations are solved numerically. Rounding errors originate
from the fact that computers can only represent numbers using a fixed and
limited number of significant figures. Thus, such numbers or cannot be
represented exactly in computer memory. The discrepancy introduced by
this limitation is called round-off error. Truncation errors in numerical
analysis arise when approximation are used to estimate some quantity. The
accuracy of the solution will depend on how small we make the step size, h
Example
2
h
Given the initial value problem Y(xn+1)=Y(xn)+h ′ Y , (x n )+
2 ,We would like to use the
Euler method to approximate Y ,using step size equal to xn≤ ¿ x n+1 , the
h2
euler method is So the first we must compute T n=
2
The above steps would be repeated to find Y(xn+1) , Y(xn ) and +∫ f(t,Y (t)dt .
xn+1
xn
hg ( a ) ′Y(xn+1)=Y(xn)+hf(xn,Y(xn) x
yh ( x ) ′ Y(x) Y ( x )− yh ( x )
h=0 .1 ′)h=0.2 h=0 .05
Table 2.1
y
=y y(0 )=1 Y ( x) h yh(xn )
0 1 0 1 1 2
1 2 1 2 1 4
2 4 2 4 1 8
3 8 3 8 1 16
The conclusion of this computation is that x . The exact solution of
differential equation is h , so = Y ( x )− y ( x )
Figure 2.1
Y-Values
60
50
40
Y-Values
30
20
10
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
Table 2.2
the x n+1 =x n +h , and yn+1=y n+f n h is a point in f n=f(xn ,yn) . The results obtained for
equation 1, will generalize in a straight forward way to both systems of
differential equations and higher order equations, provided appropriate
vector and matrix notation is used. The most popular numerical methods
for solving equation 1 are called finite difference methods. Approximate
values are obtained for the solution at a set of grid points
( t f −t 0 )
;
N
and the approximate value at each x0=x(t0 ) is obtained by using some of the
values obtained in the previous steps.
tn
(t f −
N
);
will denote the true solution of equation 1
k1
2 ′
k 2
2
y n + 1 …………..equation 2
f 2
will often be denoted by O ( h ) An equal grid size
5
O(h ) will be used to define the node points,
f f
When we are comparing numerical solutions for various values of f(x,y, , we
will also use the notation y to refer to ) with step size y .
The problem of equation 1 will be solved on a fixed finite interval, which
( n=0,1,2. .. .) dn+1 ′
y( x n ) x n ′′(ξ
n )
1
en=y(x −y ) d +1=y(x +h)−y(x )−hf (x ,y (x ) = h2 y
n n ξn n n n n n 2 (xn,y(yn+1) ………equation 4
By dropping the error term , we obtain the Euler method of
equation 1.
The term
y(yn+h) = x ′′(ξ ) ………………equation 5 n n
3.Numerical Differentiation
4. Numerical Integration
f y =
1
2
y …………equation 6
Consider the simple numerical integration method
a +h
∫ g ( t ) dt = ¿ D …………..equation 7
a
[x0,xend ] f y ¿L [ x 0 , x end ]
y 0.40 1.46410 1.49182 0.2772
0.80 2.14359 2.22554 0.8195
1.20 3.13843 3.32012 0.18169
1.60 4.59497 4.95303 0.358806
2.00 6.72750 7.38906 0.66156
e n+ 1 0.40 1.44000 1.49182 1.5182
0.80 2.07360 2.22554 0.15194
1.20 2.98598 3.32012 0.33413
1.60 4.29982 4.95303 0.65321
2.00 6.19174 7.38906 1.19732
( 1+ hl ) 0.40 1.47746 1.49182 0.01437
0.80 2.18287 2.22554 0.04267
1.20 3.22510 3.32012 0.09502
1.60 4.76494 4.95303 0.18809
2.00 7.03999 7.38906 0.34907
answer e 2 are given at only a few points, rather than at all points
at which they were calculated. Note that the error at each point ¿(1+hL)Dh2+Dh2
Nstep−1
eN Nstep−1 (1+hL)
decreases by about half when steep is halved. The total error ¿∑i=0 (1+hL)i Dh2=
1+hL−1
Dh2
is called the global error, and the last columns of Table 2.3 are
example of global error.
3. Point ( x 2 , y 2)
y 2 = y 1 + f ( x 1, y 1) ( x 2 – x 1)
4. Point ( x 3, y 3) y 3 = y 2 + f ( x 2, y 2)( x 3 – x 2)
Set =
h N step→
For K = 0: (n – 1)
x k + 1 = x k + hf (t k, x k);
x k + 1 = t k + h;
END FOR
Matlab
Function[ t , x ] =myEuler(@ f , x0,t 0,t f, N )
h
=
)
t = [t 0: h : tf ]; % discrete time points between, and including,
x (1) = x 0;
for k = 2 : N
x (k )= x (k −1) + h ¿ feval( f , t (k −1) ,
x (k −1 ¿¿ ;
end ;
k hf t
h
y
ci ,ai
2 = ( n + 2, n + j )
k
=
hf t
h
y
( n + 2, n +
b j ),
3
k 4 = hf (t n +h , y n +k 3)
k1=hf (xn, yn) is again the increment based on the slope at the midpoint, but
now using y and k 2
k2=hf(xn+c2h, yn+a21k1) is the increment based on the slope at the end of the interval,
using y and k 3
The RK4 method is a fourth order method, meaning that the local
truncation error is on the order of O (h5),while the total accumulated
error is on the order of O (h4).
Runge-Kutta ‘s Method
1. Second Order
1
y n + 1 = y n + (k 1 + k 2)
2
where k 1 = hf ( x n , y n)
k 2 = hf ( x n + h , y n+k 1)
2. Fourth order
1
y n +1 = y n + (k + 2 K 2 + 2 K 3 + K 4)
6 1
where k 1 = hf ( x n , y n)
k
2 =
hf x
h
y
( n + 2, n + y)
+ =1+ xy )
h
k hf x y
3= ( n + 2, n
k 4 = hf ( x n + h , y n + k 3)
Example
dy
Given dx = x + y , with initial conditions y (0) = 1. Choose h = 0.1 and find y
(0.1), y (0.2) and y (0.3) using Runge – Kutta’s method of fourth order.
Solution
Putting n = 0 in Runge-kutta’s formular for fourth order we get
1
y1 = y0 + (k + 2k 2 + 2k 3 + k 4)
6 1
where k 1 = hf ( x 0 , y 0) = (0.1)(0 + 1) = 0.1
k
2 =
hf x
( 0
h
y
+ 2, 0 +
x =0 ( . 1 ) 0 . 5 )
=(0.1)(0.05 + 1.05) = 0.11
y 1= y0 +h ( y 1 )0
y 1=1 +0 . 1( 1 )
y 1=1 . 1
( y 1)1=1+ x 1 y 1
¿1 +0 . 1×1 .1
h
¿1 . 11
y 2= y1 +h ( y 1 )1
¿1 . 1+ 0. 1( 1. 11 )
¿1 . 211
1
( y )2=1+ x 2 y 2
¿1 +0 . 2×1 .211
¿1 . 2422
k hf x y
y 3= y2 +h ( y 1 )2
1 . 211+ 0. 1 ( 1. 2422)
¿1 . 33522
( y 1)3=1+ x 3 y 3
¿1 +0 . 3×1 . 33522
= ( + 2, 0 + )
¿1 . 400566
y 4=y 3+ h( y1 )3
¿1 . 33522 +0 . 1( 1 . 400566 )
¿1 . 4752766
( y 1)4 =1+ x 4 y 4
1+( 0 . 4 )×( 1 . 4752766 )
3 0
¿1 . 59011064
y 5= y 4+ h( y1 ) 4
¿1 . 4752766 +( 0. 1 )×( 1 . 59011064 )
¿1 . 634287664
1
putting n = 1 in Runge-Kutta’s formula for fourth order, we get y 2 = y 1 + 6 (
k 1 + 2k 2 + 2k 3 + k 4)
k
=
hf x
h
y
( 1 + 2, 1 +
y0 ) =(0.1)(0.15+1.176384604)= 0.1326384604
3
1
y (0.2) = y 2 = y 1 + (k 1 + 2k 2 + 2k 3 +k 4)
6
1
=1.110341667 +( 6 )(0.1210341667 + 2(0.132085875) + 2(0.1326384604) +
0.1442980127)
1
= 1.110341667 + ( 6 )(0.7947808502)
=1.110341667 + 0.132463475
y (0.2) = y 2 = 1.242805142
n = 2 will give y (0.3) = 1.399711
k 1 = 0.14428, k 2 = 0.156494, k 3 = 0.157105, k 4 = 0.169990
1. Euler Method
Advantages:
Euler’s method is the simplest of all linear multi-step method to
obtain the approximated solution of the specified initial value
problem. It has the one-step techniques, and it can be easily
programmed. Most of the ordinary differential equations can be
solved conjecturally with numerical method and approximated
is
x 1 = x 0 +h
x 1 =0 +0 . 1
x 1 =0 . 1
( y 1 ) 0= 0×1−1 2
¿− 1
CHAPTER FOUR
DISCUSSION AND RESULTS
4.1 NUMERICAL METHODS FOR DIFFERENTIAL EQUATIONS
form ′ …………equation 1
k 1 =hf (x0 , y 0 )=h (y1 ) 0
¿ 0. 1×( x0 2 +x0 ×y0 )
¿ 0. 1×(02 +0×1 )
¿ 0=h(y 1 )0
k2 =hf (x 0 +1 h , y0 +1 k1 )
2 2
¿ h{(x0 +1 h )2 +x0+1 h×y 0+1 k 1 }
2 2 2
¿ 0. 1{(0+0 .5×0 .1 )2 +(0 +0. 5×0. 1 )×(1 +0. 5×0)}
¿ 0. 1{1
400 +0 . 05 ×1}
¿ 0. 00525
k3 =hf (x0 +1 h , y0 +1 k 2 )
2 2
¿ 0. 1{(0+0 .5×0 .1 )2 +(0 +0. 5×0. 1 )×(1 +0. 5×0. 00525 )}
¿ 0. 1{(1
400 )+(0. 05 )×(1 . 002625 )}
¿ 0. 005263125
k 4=hf(x0 +h , y0 +k3 )
¿ h{(x0 +h )2 +(x0 +h)×(y 0+k3 )}
¿ 0. 1{(0+0 .1 )2 +(0 +0 . 1)×(1+0 .005263 )}
k 4=0. 011053
y1 =y 0+(1
6 ){k1+2 k2 +2 k3 +k 4}
y1 =1+(1 )×{0+2×0 .00525+2×0 .00526312 5 +0 .0110526 }
6
¿ 1. 005346
and y are given and we assume that the problem has
x 1= x 0 + h, x 1 =0 +0 . 1= 0. 1
x 2= x 1 + h
0 .1 +0 . 1
x 2= 0. 2
y 1( x) = xy− y 2 , y( 0 )= 1
x 0= 0, y 0= 1, h =0 .1
n =0
k 1 =hf ( x 0 , y 0 ) = h( y 1) 0
¿ h( x 0 × y 0 − y 02 )
Where
¿ 0. 1×( 0 ×1− 1 2 )
1
¿− 0. 1= h( y )0
1 1
k 2 =hf ( x 0 + h , y 0 + k 1)
2 2
1 1
¿ h{ ( x 0 + h) ×( y 0 +1 k 1 )− ( y 0+ k 1 )2 }
2 2 2
¿ 0. 1× {( 0+ 0 .5 ×0 . 1)× ( 1+ 0. 5 ×−0 . 1) −( 1+ 0 .5 ×− 0. 1) 2}
¿− 0. 085 5
1 1
k =hf ( x + h , y + k )
3 0 2 0 2 2
1 2
¿ h{ ( x 0 +1 h )( y 0 +1 k 2 )− ( y 0 + k 2 ) }
2 2 2
¿ 0. 1{ ( 0+ 0 .5× 0 .1 )( 1 +0 . 5×− 0 .085 5 )−( 1 +0 . 5×− 0. 085 5) 2}
¿− 0. 086846506 2 5
k 4= hf ( x 0 + h , y 0 + k 3 )
2
¿ 0. 1× {( x 0 + h) ×( y 0 +k 3) −( y 0 + k 3 ) }
¿ 0. 1× {( 0+ 0 .1 )× (1 −0 . 086846506 2 5) −( 1− 0. 086846506 2 5) 2}
k =− 0 .0742533953 8
4
1
y 1= y 0+ ( ){ k 1 +2 k 2+ 2 k 3+ k 4 }
6
1
y 1= 1+ ( ) ×{ −0 .1 +2 ( −0 .085 5 )+ 2( − 0. 086846506 2 5) +( −0 . 074253395 3 8 ) }
6
y 1= 0 .91350893 20
1
This formula is develop by Euler’s method for small =1+(6){−0.2+×−0.14+2×−0.146−0.908}, the
higher powers y1=0.8562 In equation 2, k1=hf(x1,y1)=h(y )1 are very small dropping all
1
…………..equation 4
Where u is somewhere between k 1=0.04 and k=2hf(x+2h,y+2h(y)+4k,(y)+h). We have here
1111 k 2 1 11
2 0 0 010
1 1 1 1 k
= h2 {( x 0 + h+2)( y 0 + h( y 1 )0 + k 1 )−2(( y 1 )0 + 1 )}
2 2 2 4 h
1 1 1 1 k
k3 = h2 f {x0+ h,y0 + h(y1 )0 + k1 ,( y1 )0 + 2 }
2 2 2 4 h
in 0.035 36 are unknown, and will also change from one step to the
next. So we will look for an upper bound of global error. We will
first assume upper bounds for our unknown, that is we assume
1
P0=( ){0. 4+0. 34 2+0. 35 6}
there exist positive constant D and L so that 3 |P0=0.036 52 ′′| y1=y0+h(y1)+P0 for all
1
| 0.031349184 for all x ∈ Q =3{0.04+2(0.03442)+2(0.035536)+0.031349184} and for all 0.07042039467 . Take the
∈ and |
1+(0. 2)(0)+ 0.036652
0
y1=1. 0367
hk hk
k1=hf (x, y),k2=hf (x+ , y+ 1),k3=hf (x+ , y+ 2),k4=hf(x+h,y+k3)
| | 22 22 using the fact that
1+ y and f (x , y ), y (x 0 )=x 0 we finally reach the conclusion
| y=f(x) |
y the constant (t)
f (t0 ,y 0) y ∞
Where
………..equation 13
2
Comparing the coefficients on h and h in equation 12 and equation 13
1 1
w +w =1 c 2 w 2= , a 21 w 21=
we obtain 1 2 , 2 2 solving these equations, we
1 1
w 2= w 1=1−
obtain a21=c 2 , 2 c2 , 2 c 2 , where c 2 is arbitrary, if is not possible
3
to compare the coefficients of h as there are five terms in equation 12
and three terms in equation 13. Therefore the Runge-Kutta methods using
two slope(the evaluation of f ) is given by
1 1
y n+1= y n +(1− )k 1 + k
2 c2 2 c 2 2 …….equation 14
We note that the method has one arbitrary parameter c 2 .We may choose
any value for c 2 such that 0≤c 2≤1 . Therefore we have an infinite family
of these methods.
If we choose c 2=1 , we obtained the method
1
y n+1= y n + ( k 1 +k 2 )
2 ……equation 15
k 1 =hf ( x n , y n )
k 2 =hf ( x n +h , y n +k 1 ) which is the Huen’s method
1
c2= w 1=0
If we choose 2 , we get the method is given by
y n+1= y n +k 2 …….equation 16
k 1 =hf ( x n , y n )
h 1
k 2 =hf ( x n + , y n + k 1 )
2 2 which is the modified Euler method
Error of the Runge-Kutta method
Subtracting equation 13 from equation 12 we get the truncation error in
the method as
1 c 1
h3 [( − 2 )f xx+2 ff xy +f 2 f yy+ f y (f x + ff y )+. .. . .. ]
T . E= y (x n+1 )− y n+1 = 6 4 6
….equ
ation 17
3
Since the truncation error is of order O(h ) , the method is of the second
order for all values of c 2 . Therefore , equation 14 gives an infinite family
2
,
of second order methods. We may note that for c 2 = 3 the first term inside
the bracket in equation 17 vanishes and we get a method of minimum
truncation error. The method is given by
1
y n+1= y n + ( k 1 +3 k 2 )
4 …….equation 18
k 1 =hf ( x n , y n )
2h 2
k 2 =hf ( x n + , y n + k 1 )
3 3
Therefore, the method of equation 18 is a second order method with a
minimum of a truncation error.
√
y( x )=
π x2 x x2
2 e erf ( √2 ) +e 2 −x .
2
Solution
h
h
, Euler Method
Example 2
2
Given the initial value problem y ′ ( x)=xy− y , y (0)=1 on the interval
0≤x≤1. The exact solution of the given problem is given by
x2
2
2e
y ( x )=
√ 2 π erf (
Solution
x
√2
)+2
O(h)
By Euler ‘s Method
i.e
Euler Method Example 3
Apply Euler’s method to solve the equation y ′ =1+xy for x=0(0. 1)0 .5
given that x=0 , y=1 . The exact solution of the given problem is given by
1
1 x2
y ( x )=( √ π √ 2 erf ( 1 √ 2 x )+1)e 2
2 2
Solution
By Euler Method
yn
0
=0
y ( xn )
er =
1.0
max
1≤n≤steps
( y(xn )− yn ′ )
1.0
0.1 1.1 1.11
0.2 1.211 1.2422
0.3 1.33522 1.400566
0.4 1.4752766 1.59011064
0.5 1.634287664 1.817143832
Solution
x 1=x 0 + h
x 1=0+0 .1
x 1=0 . 1
2
y′= x −2 x+ y
x 0=0 , y 0=0. 5 , h=0. 1
( y ′ )0 =f ( x 0 , y 0 )
2
( y ′ )0 = x 0 −2 x 0 + y 0
= 0−0+0 .5
( y ′ )0 =0 .5
2
f (x 1 , y 1 )=x 1 −2x 1 + y 1
2
= x 1 −2 x 1 + y 0 +h( y ′ )0
from
1
y 1 = y 0 + h ¿ ¿ ) +f ( x , y )¿¿
2 ′ 0 1 1
1
y 1= y 0 + h ¿ ¿ 2
2 ′ )0 +x 1 −2 x 1 + y 0 +h( y ′ )0 ¿¿
1
y 1= y 0+ h ¿ ¿ ) ¿¿
2 ′0
2
= 0.5+(0 .5 )×0.1 {0 . 1 −2(0 .1)+0 . 5+(1+0 . 1)×0.5}
y 1 =0 .543
(y ′ )1=x 21 −2 x 1 + y 1
2
=0 . 1 −2(0. 1)+0. 543
=0 .353
1
y 2= y 1+ h¿¿
2 ′ )1 ¿¿
2
y 2 =0 .543+(0 .5 )×0 . 1×{0 .2 −2(0 . 2)+0 .543+(1+0 .1 )×0 . 353}
y 2 =0 .5716
2
( y ′ )2 =x 2 −2 x 2 + y 2
2
=0 . 2 −2(0 .2 )+0. 5716
= 0.2116
1
y 3= y 2+ h¿¿
2 ′ )2 ¿¿
2
= 0 .5716+(0 .5 )×0. 1 {0 . 3 −2(0 .3 )+0 .5716+(1+0 .1 )×0 . 2116}
=0 . 586318=0 . 5863
2
( y ′ )3 =x 3 −2 x 3 + y 3
2
=0 . 3 −2(0 .3 )+0 .5863
=0 . 0763
1
y 4= y 3 + h¿¿
2 ′ )3 ¿¿
=0. 5863+(0 . 5)×0.1 {0. 4 2 −2(0. 4 )+0 .5863+(1+0 .1)×0 . 0763}
=0. 5878
2
( y ′ )4 =x 4 −2 x 4 + y 4
2
= 0 . 4 −2(0. 4 )+0 . 5878
−0. 0522
1
y 5= y 4 + h¿¿
2 ′ )4 ¿¿
=0 . 5878+(0 . 5)×0 .1 {0. 52 −2(0 .5 )+0 . 5878+(1+0 .1)×(−0 . 0522)}
= 0.5768
2
( y ′ )5 =x 5 −2 x 5 + y 5
2
=0 . 5 −2(0 .5 )+0 .5768
=−0. 1732
Runge Kutta Method Example 1
2
Given the initial value problem y ′ ( x )=x +xy , y (0 )=1 on the interval
0≤x≤1. The exact solution of the given problem is given by
y( x )=
π x2
√x x2
2 e erf ( √2 ) +e 2 −x .
2
Solution
y ( x )=
2e
x2
2
√ 2 π erf (
x
√2
)+2
3
Solution
O(h )
Runge-Kutta First Order Method Example 3
Using Runge-Kutta method, solve the equation h ′ f (x , y ) given that
y = 1 when x=0(0. 2)1.0 , the exact solution of the problem is given by
y( x)=−2+2 x +3 e−x
SOLUTION
f(xn ,yn)
h
h
2
h
h
2
h
n=1,
qh
y
= y
y ( 0 )=1
0
=y1=1+1×1=2
y 2
y3
y4
y 2 = y 1 + hf ( y
)1
=2+1×2=4
y 3 = y 2 +hf ( y
)2
=4+1×4=8
y 4 = y 3 +hf ( y
3
=8+1×8=16
n
yn
xn
f ( xn , yn )
CHAPTER FIVE
5.1 SUMMARY,CONCLUSION AND RECOMMENDATIONS
This chapter is the final chapter of this study. It comprises
summary of the study,conclusion,recommendations for the study
and suggestion for further studies.
5.2 SUMMARY
In this thesis, Euler method and Runge-Kutta method are used
for solving ordinary differential (ODE) in initial problems(IVP) . Finding
more accurate results needs the step size smaller for all methods. From
the figures and the tables we can see the accuracy of the methods for
decreasing the step size h and the graph of the approximate solution
approaches to the graph of the exact solution. The numerical solutions
obtained by the two proposed methods are in good agreement with exact
solutions. Comparing the two methods under investigation, we observed
that the rate of convergence of Euler’s method is O(h) and the rate of
4
convergence of fourth-order Runge-Kutta method is O(h ) . The Euler
method was found to be less accurate due to the inaccurate numerical
results that were obtained from the approximate solution in comparison
to the exact solution.
5.3 CONCLUSION AND RECOMMENDATION
The conclusion drawn from the results of this thesis are follows:
1. The accuracy of improved Euler method is better than the accuracy
of Euler method and the accuracy of Runge-Kutta fourth order
method is better than the Improved Euler method.
2. We have compared to the Runge –Kutta order four method, to the
Runge-Kutta second order four method, the Runge-Kutta second
order four method is a computational time very similar,slightly more
accurate results with a much lower number of discretization steps, but
the additional computational cost per step.
3. Runge-Kutta fourth order method have been developed for numerical
integration of first order ordinary differential equations, they are
almost four-step in nature and they are computationally more
efficient and produced small errors.
4. When we use the Runge-Kutta order four method, by minimizing the
step-size h then the error become decrease and the accuracy
although increase.
5. We use the exact solution in Runge-Kutta methods to compute the
errors.
6. This study shows that Euler’s method, Improved Euler method and
Runge-Kutta fourth order method can generate a solution of second
order ODE.
Exact Values
2.5
2.0
1.5
Exact Values
1.0
0.5
0.0
0 0.2 0.4 0.6 0.8 1 1.2
Exact Values
1.2
1.0
0.8
0.4
0.2
0.0
0 0.2 0.4 0.6 0.8 1 1.2
2.00
1.50
1.00
0.50
0.00
0 0.2 0.4 0.6 0.8 1 1.2
Figure 2.4
2.00
1.50
1.00
0.50
0.00
0 0.2 0.4 0.6 0.8 1 1.2
Figure 2.5
2.50
2.00
1.50
1.00
0.50
0.00
0 0.5 1 1.5 2 2.5
Figure 2.6
2.00
1.50
1.00
0.50
0.00
0 0.2 0.4 0.6 0.8 1 1.2
Figure 2.7
1.0
0.8
0.6
0.4
0.2
0.0
0 0.2 0.4 0.6 0.8 1 1.2
Figure 2.8
6.00
5.00
4.00
3.00
2.00
1.00
0.00
0.0 0.5 1.0 1.5 2.0 2.5
Figure 2.8