You are on page 1of 41

Numerical Solution to Ordinary Differential Equations

Jean Paul Nsabimana,


Department of Mathematics
University of Rwanda
Email: nsapa123@gmail.com

December 16, 2020

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
1 / 41
1 Power Series Solution
Example

2 Euler’s Method
Improved Euler’s Method
Modified Euler’s Method
Example
Exact Solution

3 Runge - Kutta Method


Runge-Kutta method of First order
Runge-Kutta method of Second order
Runge - Kutta Method of the third order
Runge - Kutta Method of fourth order

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
2 / 41
Power Series Solution

Power Series Solution

Consider the differential equation


dy
= y 0 = f (x, y ), (1)
dx
subject to the condition y (x0 ) = y0 .
This is an initial value problem. Now we can expand the solution to
equation (1) i.e y (x) in the neighborhood of x = x0 in power series as

y (x) = A0 + A1 (x − x0 ) + A2 (x − x0 )2 + . . . , (2)

where A0 , A1 , A2 , . . . are constant to be determined such that Equation (2)


satisfies Equation (1) subject to the initial value.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
3 / 41
Power Series Solution

Power Series Solution

To expand y (x) in power series, generally, Taylor’s Theorem or Maclaurin’s


Theorem is used. If the boundary condition x0 (6= 0), then we use Taylor’s
series to expand y (x) about x = x0 and it is

(x − x0 ) 0 (x − x0 )2 00
y (x) = y (x0 ) + y (x0 ) + y (x0 ) + . . . (3)
1! 2!

If the boundary condition is at x0 = 0, then we use Maclaurin’s series to


expand y (x) about x = 0 and it is

x 0 x2 x 3 000
y (x) = y (0) + y (0) + y 00 (0) + !y (0) + . . . (4)
1! 2! 3

The method is best illustrated by the following example.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
4 / 41
Power Series Solution Example

Example

Example
Evaluate the solution to the differential equation y 0 = (1 + x)xy 2 subject to
y (0) = 1 by taking five terms in Maclaurin’s series for x = 0 (0.1) 0.4. Compare
with the exact solution.
Solution: Maclaurin’s series is
x 0 x2 x 3 000 x4
y (x) = y (0) + y (0) + y 00 (0) + !y (0) + y (4) + . . . (5)
1! 2! 3 4!
The given equation is

y 0 (x) = (1 + x)xy 2 , y (0) = 1.

y 0 (x) = (1 + x)xy 2 , y 0 (0) = 0


y 00 (x) = 2xyy 0 + y 2 + 2xy 2 + 2x 2 yy 0 , y 00 (0) = 1

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
5 / 41
Power Series Solution Example

Solution Cont...

000
y (x) = 4yy 0 + 8xyy 0 + 2xy 02 + 2y 2 + 2xyy 00 + 2x 2 yy 00 + 2x 2 y 02
000
y (0) = 2
y (4)
= 2yy 02 + 6y 02 + 6xy 0 y 00 + 6yy 00 + 12yy 0 + 14xyy 00
+ 12yy 02 + 6x 2 y 0 y 00 + 2x 2 yy 00 ,
(4)
y (0) = 6

Putting these values in Equation (5), we get

x x2 x3 x4
y (x) = 1+
(0) + (1) + (2) + (6)
1 2 3! 4!
x2 x3 x4
∴ y (x) = 1+ + + + .... (6)
2 3 4

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
6 / 41
Power Series Solution Example

Solution Cont...

Putting x = 0.1, 0.2, 0.3, 0.4 successively in Equation (6), we get

(0.1)2 (0.1)3 0.1)4


y1 = y (0.1) = 1 + + + = 1.0053583.
2 3 4
(0.2)2 (0.2)3 (o.2)4
y2 = y (0.2) = 1 + + + = 1.0230667.
2 3 4
(0.3)2 (0.3)3 (0.3)4
y3 = y (0.3) = 1 + + + = 1.056025.
2 3 4
(0.4)2 (0.4)3 (0.4)4
y4 = y (0.4) = 1 + + + = 1.1077333.
2 3 4

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
7 / 41
Power Series Solution Example

Solution Cont...

Exact Solution: Given that


dy
= (1 + x)xy = (x + x 2 )y 2 .
dx
It means that
dy
= (x + x 2 )dx by separation of variables
y2
 2
x3

1 x
⇒− = + + c by integration
y 2 3

Using the initial condition y (0) = 1 i.e y = 1 at x = 0, in the above equation, we


get
−1 = c ⇒ c = −1

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
8 / 41
Power Series Solution Example

Solution Cont...

Therefore,

x2 x3
 
1
− = + −1
y 2 3
3x 2 + 2x 3
= −1
6
3x 2 + 2x 3 − 6
=
6
6
∴y = . (7)
6 − 3x 2 − 2x 3

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
Decemberof
16, Rwanda
Equations
2020 Em
9 / 41
Power Series Solution Example

Solution Cont...

Since
6
y = .
6 − 3x 2 − 2x 3
Now putting x = 0.1, 0.2, 0.3, 0.4 successively in Equation 8, we get

y1 = y (0.1) = 1.0053619.
y2 = y (0.2) = 1.0231924.
y3 = y (0.3) = 1.0570825.
y4 = y (0.4) = 1.1127596.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
10 / 41
Power Series Solution Example

Exercise III.1

Using four terms of the Maclaurin’s series, find y at x = 0 (0.1) 0.6


given that 2y 0 = (1 + x)y 2 , y (0) = 1. Compare the results with the
exact solution.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
11 / 41
Euler’s Method

Euler’s Method

Consider the differential equation


dy
= f (x, y ), where y (x0 ) = y0 . (8)
dx

Suppose that we wish to find successively y1 , y2 , y3 , . . . , ym where ym on


the value of y corresponding to x = xm , where
xm = x0 + mh, m = 1, 2, 3, . . . , h being small.
Thus, in the interval x0 to x1 of x, we approximate the curve by the tangent
at the point (x0 , y0 ). Therefore, the equation of the tangent at (x0 , y0 ) is
 
dy
y − y0 = (x − x0 )
dx (x0 , y0 )
= f (x0 , y0 )(x − x0 ). [From the equation (8)]
∴y = y0 + (x − x0 )f (x0 , y0 ).

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
12 / 41
Euler’s Method

Euler’s Method

Hence, the value of y corresponding to x = x1 is

y1 = y0 + (x1 − x0 )f (x0 , y0 )
∴ y1 = y0 + h f (x0 , y0 ). (9)

Similarly, approximating the curve in the next interval [x1 , y1 ] by a line


through (x1 , y1 ) with the slope f (x1 , y1 ), we get

y2 = y1 + h f (x1 , y1 ). (10)

Proceeding on; In general it can be shown that

ym+1 = ym + h f (xm , ym ). (11)

Note: The process is very slow and to obtain it with reasonable accuracy
using Euler Method. We have to use h very small.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
13 / 41
Euler’s Method Improved Euler’s Method

Improved Euler’s Method

Here we consider a line passing through A(x0 , y0 ) whose slope is the


(1)
average of the slopes at A(x0 , y0 ) and P(x1 , y1 ) such that
(1)
y1 = y0 + h f (x0 , y0 ).

Therefore, the equation of the tangent line is given as


1 (1)

y − y0 = (x − x0 ) f (x0 , y0 ) + f (x1 , y1 ) . (12)
2

As we assuming that the line passes through the point (x0 , y0 ) and (x1 , y1 ).
Therefore, the equation is
1 
(1)

y1 = y0 + (x1 − x0 ) f (x0 , y0 ) + f (x1 , y1 )
2
h (1)

or y1 = y0 + f (x0 , y0 ) + f (x1 , y1 ) .
2

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
14 / 41
Euler’s Method Improved Euler’s Method

Improved Euler’s Method

Therefore, we have
h
y1 = y0 + (f (x0 , y0 ) + f [x0 + h, y0 + h f (x0 , y0 )]) . (13)
2

In general, we have the formula


h
ym+1 = ym + (f (xm , ym ) + f [xm + h, ym + h f (xm , ym )]) . (14)
2
Where xm − xm−1 = h.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
15 / 41
Euler’s Method Modified Euler’s Method

Modified Euler’s Method

In this method the curve in the interval [x0 , y0 ], where x1 = x0 + h is


approximated by the line through (x0 , y0 ) with slope
 
h h
f x0 + , y0 + f (x0 , y0 . (15)
2 2

That is, the slope at the middle point whose abscisse is the average of x0
and x0 + h2 . The equation of line L is
  
h h
y − y0 = (x − x0 ) f x0 + , y0 + f (x0 , y0 . (16)
2 2

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
16 / 41
Euler’s Method Modified Euler’s Method

Modified Euler’s Method

Putting x = x1 , we get
  
h h
y1 = y0 + (x1 − x0 ) f x0 + , y0 + f (x0 , y0
2 2
  
h h
∴ y1 = y0 + h f x0 + , y0 + f (x0 , y0 . (17)
2 2

Proceeding in the same way, the general formula can be show that
  
h h
ym+1 = ym + h f xm + , ym + f (xm , ym . (18)
2 2

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
17 / 41
Euler’s Method Example

Example

Solve dy
dx = 1 − y , y (0) = 0 in the range 0 ≤ x ≤ 0.3 using the following
methods by choosing h = 0.1
1 Euler’s Method.
2 Improved Euler’s Method.
3 Modified Euler’s Method by.
Compare the answers with the exact solution.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
18 / 41
Euler’s Method Example

Solution: Euler’s Method

dy
Given that dx = 1 − y, y (0) = 0, h = 0.1.
Now, we have to find out the solutions at x = 0.1, x = 0.2 and x = 0.3.
Euler’s Method: The algorithm is if dy
dx = f (x, y ), y (x0 ) = y0 , then
ym+1 = ym + hf (xm , ym ).
Here f (x, y ) = 1 − y , h = 0.1, x0 = 0 and y (0) = y0 = 0. Hence

ym+1 = ym + (0.1)(1 − ym ) = 0.1 + 0.9ym .

Putting m = 0, 1, 2 successively, we get

y1 = 0.1 + 0.9y0 = 0.1 + 0.9(0) = 0.1


y2 = 0.1 + 0.9y1 = 0.1 + 0.9(0.1) = 0.19
y3 = 0.1 + 0.9y2 = 0.1 + 0.9(0.19) = 0.271.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
19 / 41
Euler’s Method Example

Solution: Improved Euler’s Method

Improved Euler’s Method: Here, the formula is


h (1)

ym+1 = ym + f (xm , ym ) + f [xm+1 , ym+1 )] ,
2
where
(1)
ym+1 = f [xm + h, ym + h f (xm , ym )].

Here, f (x, y ) = 1 − y , therefore f (xm , ym ) = 1 − ym . Hence,


   
(1)
f xm+1 , ym+1 = 1 − ym + hf (xm , ym )

= 1 − ym − h(1 − ym )
 
(1)
∴f xm+1 , ym+1 = (1 − h)(1 − ym )

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
20 / 41
Euler’s Method Example

Solution: Improved Euler’s Method

So
h
ym+1 = ym + [1 − ym + (1 − h)(1 − ym )]
2
h
= ym + [(1 − ym )(1 + 1 − h)]
2
h
⇒ ym+1 = ym + [(2 − h)(1 − ym )] .
2
Here, h = 0.1
ym+1 = ym + 0.095(1 − ym ) = 0.095 + 0.905ym .

Putting m = 0, 1, 2 successively in the above equation, we get


y1 = 0.095 + 0.905y0 = 0.095 + 0.905(0) = 0.095
y2 = 0.095 + 0.905y1 = 0.095 + 0.905(0.095) = 0.180975
y3 = 0.095 + 0.905y2 = 0.095 + 0.905(0.180975) = 0.2587823.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
21 / 41
Euler’s Method Example

Solution: Modified Euler’s Method

Modified Euler’s Method: The formula is


  
h h
ym+1 = ym + h f xm + , ym + f (xm , ym
2 2
  
h
= ym + h 1 − ym + f (xm , ym )
2
 
h
= ym + h 1 − ym − (1 − ym )
2
 
h h
= ym + h 1 − ym − + ym
2 2
 
h h
= ym + h (1 − ) − (1 − )ym
2 2

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
22 / 41
Euler’s Method Example

Solution: Modified Euler’s Method

Since,
 
h
= ym + h 1 − (1 − ym )
2
 
0.1
= ym + 0.1 1 − (1 − ym )
2
∴ ym+1 = 0.095 + 0.905ym .

Which is identical to the equation of the Improved Euler’s Method. Putting


successively m = 0, 1, 2, we get

y1 = 0.095 + 0.905y0 = 0.095 + 0.905(0) = 0.095


y2 = 0.095 + 0.905y1 = 0.095 + 0.905(0.095) = 0.180975
y3 = 0.095 + 0.905y2 = 0.095 + 0.905(0.180975) = 0.2587823.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
23 / 41
Euler’s Method Exact Solution

The exact solution

The exact solution: we have


dy
= 1−y Given differential equation
dx
dy
⇒ = dx by separation of variables
1−y
⇒ − log(1 − y ) + log c = x by integration
x c
⇒e = by separating the variables
1−y
⇒ e x (1 − y ) = c by cross product.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
24 / 41
Euler’s Method Exact Solution

The exact solution

By using the given initial condition, we have y = 0 at x = 0. so c = 1,


therefore

y = 1 − ex .
y1 = y (0.1) = 0.0951625.
y2 = y (0.2) = 0.1812691.
y3 = y (0, 3) = 0.2591817.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
25 / 41
Euler’s Method Exact Solution

Exercise III.2

Given that
dy 2x
=y− , y (0) = 1
dx y
in the range 0 ≤ x ≤ 0.2 using
1 Euler’s Method,
2 Improved Euler’s Method,
3 Modified Euler’s Method
Take h = 0.1.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
26 / 41
Runge - Kutta Method Runge-Kutta method of First order

First order Runge-Kutta method

Motivation: Runge - Kutta methods do not required the calculations of higher


order derivatives and give great accuracy.
We have see that Euler’s method gives

y1 = y + 0 + hf (x0 , y0 ) = y0 + hy00 [y 0 = f (x, y )]. (19)

Now y1 = f (x0 + h. Expanding it by Taylor’s series, we get

h 0 h2 00
y1 = y0 + y + y + ...
1! 0 2! 0

This implies that Euler’s method agrees with Taylor’s series solution up to
term in h.
Hence, Runge-Kutta method of first order is Euler’s method

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
27 / 41
Runge - Kutta Method Runge-Kutta method of Second order

Runge-Kutta method of second order

The improved Euler’s method gives


h (1)

y1 = y0 + f (x0 , y0 ) + f [x0 + h, y1 )] ,
2
(1)
where y1 = f [x0 + h, y0 + h f (x0 , y0 )].
That is
h
y1 = y0 + (f (x0 , y0 ) + f [x0 + h, y0 + hf (x0 , y0 )]) , (20)
2

Now, by Taylor’s series

h2 00 h3 000
y1 = y (x0 + h) = y0 + hy00 + y + y0 + . . . (21)
2! 0 3!

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
28 / 41
Runge - Kutta Method Runge-Kutta method of Second order

Runge-Kutta method of second order

Expanding f ((x0 + h, y0 + hf (x0 , y0 )) by Taylor’s series for a function of


two variables,
 we get 
 
h ∂f ∂

y1 = y0 + 2 f (x0 , y0 ) + f (x0 , y0 ) + h ∂x x0 ,y0 + 1 + hf (x0 , y0 ) ∂y
x0 ,y0
+terms in 2nd
 and higher power  of h 
 
y1 = y0 + 12 2hf (x0 , y0 ) + h2 ∂f ∂

∂x x + f (x0 , y0 ) ∂y + O(h3 )
0 ,y0 x0 ,y0

h2 0
y1 = y0 + hf (x0 , y0 ) + f (x0 , y0 ) + O(h3 )
2
h2 00
= y0 + hf (x0 , y0 ) + y0 + O(h3 )
2

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
29 / 41
Runge - Kutta Method Runge-Kutta method of Second order

Runge-Kutta method of second order

Then,

h2 00
y1 = y0 + hf (x0 , y0 ) + y + O(h3 ). (22)
2 0

Therefore, the Improved Euler’s method is the Runge-Kutta method of


second order.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
30 / 41
Runge - Kutta Method Runge-Kutta method of Second order

Runge-Kutta method of second order

The algorithm to Runge - Kutta method of second order.

k1 = hf (x0 , y0 )
k2 = hf (x0 + h, y0 + k1 )
1
k = (K1 + k2 )
2
∴ y1 = y0 + k.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
31 / 41
Runge - Kutta Method Runge - Kutta Method of the third order

The third order Runge - Kutta Methods

Runge - Kutta method of third order: It is defined by the following equations

k1 = hf (x0 , y0 )
k2 = hf (x0 + h, y0 + k1 )
k3 = hf (x0 + h, y0 + k2 )
h k1
k4 = hf (x0 + , y0 + )
2 2
1
k = (k1 + 4k4 + k3 )
6
∴ y1 = y0 + k.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
32 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Runge - Kutta Method of fourth order

It is most commonly known as Runge - Kutta method and the working


procedure is as follows: Consider the following equation
dy
= f (x, y ), y (x0 ) = y0 .
dx
To compute y1 , we calculate successively

k1 = hf (x0 , y0 )
 
h k1
k2 = hf x0 + , y0 +
2 2
 
h k2
k3 = hf x0 + , y0 +
2 2
k4 = hf (x0 + h, y0 + k3 )
1
k = (k1 + 2k2 + 3k3 + k4 )
6
∴ y1 = y0 + k and x1 = x0 + h.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
33 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Runge - Kutta Method of fourth order

The increment in y in second interval is computed in a similar manner by means


of the formula

k1 = hf (x1 , y1 )
 
h k1
k2 = hf x1 + , y1 +
2 2
 
h k2
k3 = hf x1 + , y1 +
2 2
k4 = hf (x1 + h, y1 + k3 )
1
k = (k1 + 2k2 + 3k3 + k4 )
6
∴ y2 = y1 + k and x2 = x1 + h.

And so on for succeeding intervals.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
34 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Example

Given y 0 = x 2 − y , y (0) = 1, find y (0.1), y (0.2) using


1 Second order Runge - Kutta method
2 Third orde Runge - Kutta method
3 Fourth order Runge - Kutta method

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
35 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Solution:Runge - kutta method of second order

Given y 0 = x 2 − y , x0 = 0, y0 = 1, ∴ f (x0 , y0 ) = −1. Let h = 0.1,

k1 = hf (x0 , y0 ) = 0.1(−1) = −0.1


k2 = hf (x0 + h, y0 + k1 ) = 0.1f (0.1, 0.9) = 0.1[(0.1)2 − 0.9] = −0.089
1 1
k = (K1 + k2 ) = (−0.1 − 0.089) = −0.0945.
2 2
∴ y1 = y0 + k = 1 − 0.0945 = 0.9055.

Taking x1 = 0.1, y1 = 0.9055 in place of x0 , y0 and repeating the process

k1 = hf (x1 , y1 ) = h(x12 − y ) = 0.1[(0.1)2 − 0.9055) = −0.08955


k2 = hf (x1 + h, y1 + k1 ) = hf (0.2, 0.81595) = (0.1)[(0.2)2 − 0.81595)
= −0.077595
1 1
k = (K1 + k2 ) = (−0.08955 − 0.077595) = −0.0835725
2 2
∴ y2 = y1 + k = 0.9055 − 0.0835725 = 0.8219275.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
36 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Solution:Runge - Kutta method of Third order

Here, we have

k1 = hf (x0 , y0 ) = −0.1
k2 = hf (x0 + h, y0 + k1 ) = −0.089
k3 = hf (x0 + h, y0 + k2 ) = −0.0901
h k1
k4 = hf (x0 + , y0 + ) = −0.09475
2 2
1
k = (k1 + 4k4 + k3 ) = −0.9485
6
∴ y1 = y0 + k = 0.90515.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
37 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Solution:Runge - Kutta method of Third order

Taking x1 = 0.1, y1 = 0.90515, h = 0.1 in place of x0 , y0 and repeating the


process, we get

k1 = hf (x1 , y1 ) = −0.089515
k2 = hf (x1 + h, y1 + k1 ) = −0.0775635
k3 = hf (x1 + h, y1 + k2 ) = −0.0787586
h k1
k4 = hf (x1 + , y1 + ) = −0.0837892
2 2
1
k = (k1 + 4k4 + k3 ) = −0.0839051
6
∴ y2 = y1 + k = 0.82124490

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
38 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Solution:Runge - Kutta method of fourth order

Here,

k1 = hf (x0 , y0 ) = −0.1
 
h k1
k2 = hf x0 + , y0 + = −0.09475
2 2
 
h k2
k3 = hf x0 + , y0 + = −0.0550125
2 2
k4 = hf (x0 + h, y0 + k3 ) = −0.0894987
1
k = (k1 + 2k2 + 3k3 + k4 ) = −0.0948372
6
∴ y1 = y0 + k = 0.9051627.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
39 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Solution:Runge - Kutta method of fourth order

Taking x1 = 0.1, y1 = 0.9051627 in place of x0 , y0 and repeating the process,


we get

k1 = hf (x1 , y1 ) = −0.0895162
 
h k1
k2 = hf x1 + , y1 + = −0.0837904
2 2
 
h k2
k3 = hf x1 + , y1 + = −0.0840767
2 2
k4 = hf (x1 + h, y1 + k3 ) = −0.0781085
1
k = (k1 + 2k2 + 3k3 + k4 ) = −0.083893
6
∴ y2 = y1 + k = 0.8212696.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
40 / 41
Runge - Kutta Method Runge - Kutta Method of fourth order

Exercise III.3

Using Runge -Kutta method of fourth order, solve for y (0.1), y (0.2) and y (0.3)
given that
y 0 = xy + y 2 , y (0) = 1.

Jean Paul Nsabimana, Department


Numerical Solution
of Mathematics
to Ordinary
University
Differential
of 2020
December 16, Rwanda
EquationsEm
41 / 41

You might also like