You are on page 1of 10

SOLUTION OF DIFFERENTIAL EQUATIONS

The central concern of this chapter is approximating the solution to an initial value problem for a
differential equation.
INITIAL VALUE PROBLEM
Definition: A solution to an initial value problem (I.V.P)
y = f (t , y ) with y (t0 ) = y0

...................................(1)

on an interval t0 , b is a differentiable function y = y (t ) such that


y (t0 ) = y0

and

y(t ) = f (t , y (t ))

for all t t0 , b

........................(2)

Notice that the solution curve y = y (t ) must pass through the initial point ( t0 , y0 )

EULERS METHOD
Eulers method is one of the simplest and also earliest technique developed for the solution of the
ordinary differential equations.
Derivation of Method
Eulers method can be derived in several ways, the derivation is based on Taylors series expansion is
considered here. Assume that y (t ) , y(t ) and y(t ) are continuous and Taylors theorem to expand
y (t ) about t = t0 . For each value of t , there exist a value c1 that lies between t0 and t so that

y ( t ) = y ( t 0 ) + ( t t 0 ) y ( t 0 ) +
When y(t0 ) = f (t0 , y (t0 ))
y (t1 ) .

( t t0 ) 2
2!

.....................(3)

and h = t1 t0 are substituted in (3) , the result is an expression for

y (t1 ) = y (t0 ) + ( t1 t0 ) y(t0 ) +


= y (t0 ) + hf (t0 , y (t0 )) +

y(c1 )

( t1 t0 ) 2
2!

y(c1 )

h2
y(c1 ).....................(4)
2!

If the step size h is chosen small enough , then we neglect the second order term (involving h2 ) and
get
y1 = y0 + hf (t0 , y0 ) ......................(5)
The process is repeated and generates a sequence of points that approximate the solution curve
y = y (t ) . The general step for Euler method is

yk +1 = yk + hf (t k , yk )

for k = 0, 1, 2,..., M 1

......................(6)

where t k +1 = t k + h
EXAMPLE : Use Eulers method to solve approximately the initial value problem

y = 1 +
Using the step size h = 0.5

y
t

over [1, 2.5] with y (1) = 1

1.5

2.5

t0

t1

t2

t3

yk +1 = yk + hf (t k , yk ) and y = f (t , y ) = 1 +

y
t

1
y1 = y0 + hf (t0 , y0 ) = 1 + 0.5 1 + = 2
1
y1 = 2 = y (1.5)
2

y2 = y1 + hf (t1 , y1 ) = 2 + 0.5 1 +
= 3.1666667
1.5
y2 = 3.1666667 = y (2)
3.1666667
y3 = y2 + hf (t 2 , y2 ) = 3.1666667 + 0.5 1 +
= 4.45833333
2

y3 = 4.45833333 = y (2.5)

Exact solution : y (t ) = t ( 1 + ln t )

= yex yapp

Approx. Solution

Exact solution

1.0

1.00000000

1.00000000

1.5

2.00000000

2.10819766

0.108198

2.0

3.16666667

3.38629436

0.219628

2.5

4.45833333

4.79072683

0.332393

EXERCISE
Use Eulers method to solve approximately the I.V.P

t
, 0t 3
y
Using the step size h=0.5
y =

, y (0) = 1

Exact Solution: y (t ) = t 2 + 1

and find the error for each time step.

HEUNS METHOD
Consider I.V.P
y = f (t , y ) over [a , b]

with y ( t0 ) = y0

...................................(1)

Use fundamental theorem of calculus to obtain the solution point (t1 , y1 ) , that is integrate y(t ) over
t0 , t1 .

t1

f (t , y (t )) dt =

t0

t1
t0

y(t ) dt = y (t1 ) y (t0 ) .........................(2)

From (2)

y (t1 ) = y (t0 ) +

t1

f (t , y (t )) dt .........................(3)

t0

Use Trapezoidal rule for (3), then

h
y (t1 ) = y (t0 ) + f (t0 , y (t0 ) + f (t1 , y (t1 ))) .........................(4)
2
where

y (t1 ) = y0 + hf (t0 , y0 )

then

h
y (t1 ) = y (t0 ) + f (t0 , y (t0 ) + f (t1 , y0 + hf (t0 , y0 ) )) ...................(5)
2
which is called Heuns Method.
The general step for Heuns Method is

pk +1 = yk + hf (t k , yk )
...............................(6)
h
yk +1 = yk + f (t k , yk ) + f (t k +1 , pk +1 )
2
Example: Use Heuns method to solve I.V.P
t y
on [0, 3] with y (0) = 1
2
where h = 1
y =

y0 = 1 and f (t , y ) =

t0

t1

t2

t3

t y
2

0 1
p1 = y0 + hf (t0 , y0 ) = 1 + 1
= 0.5
2

h
1 1 1 0.5
y1 = y0 + f (t0 , y0 ) + f (t1 , p1 ) = 1 + +
= 0.875
2
2 2 2

y1 = 0.875

1 0.875
p2 = y1 + hf (t1 , y1 ) = 0.875 + 1
= 0.9375
2

1 1 0.875 2 0.0.9375
h
y2 = y1 + [ f (t1 , y1 ) + f (t 2 , p2 ) ] = 0.875 +
+
= 1.171875
2
2
2
2

y2 = 1.171875

2 1.171875
p3 = y2 + hf (t 2 , y2 ) = 1.171875 + 1
= 1.5859375
2

1 2 1.171875 3 1.5859375
h
y3 = y2 + f (t 2 , y2 ) + f (t 3 , p3 ) = 1.171875 +
+
= 1.732422
2
2
2
2

y3 = 1.732422
t

Exact:

y (t ) = 3e 2 2 + t
y (3) =

3
3e 2

2 + 3 = 1.66939048

Error : = yex yapp = 1.66939048 1.732422 = 0.063

Exercise : Use Heuns method to find approximations to the initial value problem
y = y t , y (0) = 1.5

on

[ 0, 0.5]

where h = 0.25

Exercise : Given the following initial value problem

y = 2ty 2 , y (0) = 1
to approximate y(0.3), use Euler formula and the following given formula

h
h

y ( t + h ) = y (t ) + hf t + , y (t ) + f (t , y )
2
2

with h=0.1 and compare the result from above two formulas with exact solution given by
y=

1
1 t2

RUNGE KUTTA METHODS


FOURTH ORDER RUNGE KUTTA METHOD (RK4)
The fourth order Runge Kutta method (RK4) simulates the accuracy of the Taylor series of order
N=4. The method is based on computing yk +1 as follows
yk +1 = yk + w1k1 + w2 k2 + w3 k3 + w4 k4

.....................(1)

where, k1 , k2 , k3 and k4 have the form


k1 = hf (t k , yk )
k2 = hf (t k + a1h, yk + b1k1 )
k3 = hf (t k + a2 h, yk + b2 k1 + b3 k2 )

.........................(2)

k4 = hf (t k + a3 h, yk + b4 k1 + b5 k2 + b6 k3 )
where,
1
1
, a2 =
, a3 = 1
2
2
1
1
b1 =
, b2 = 0 , b3 =
, b4 = 0 , b5 = 0 , b6 = 1
2
2
1
1
1
1
w1 =
and w4 =
, w2 =
, w3 =
6
3
3
6
a1 =

..............(3)

then,

1
1
1
1
yk +1 = yk + k1 + k2 + k3 + k4
6
3
3
6
1
= yk + k1 + 2k2 + 2k3 + k4 .........................(4)
6
and
k1 = hf (t k , yk )
k
h
, yk + 1 )
2
2
k2
h
k3 = hf (t k + , yk + )
2
2
k4 = hf (t k + h, yk + k3 )
k2 = hf (t k +

.........................(5)

Example: Use the RK4 method solve the I.V.P

t y
on [0, 3] with y (0) = 1
2
where h = 1
y =

y0 = 1 and f (t , y ) =

t0

t1

t2

t3

t y
2

1
y1 = y0 + k1 + 2k2 + 2k3 + k4
6
01
= 0.5
k1 = hf (t0 , y0 ) = 1 f (0, 1) =
2
k
0.5 0.75
h
0.5
k2 = hf (t0 + , y0 + 1 ) = 1 f (0 + 0.5, 1 +
= 0.125
) = f (0.5, 0.75) =
2
2
2
2
k
h
0.5 0.9375
0.125
, y0 + 2 ) = 1 f (0 + 0.5, 1 +
= 0.21875
) = f (0.5, 0.9375) =
2
2
2
2
1 0.78125
k4 = hf (t0 + h, y0 + k3 ) = 1 f (0 + 1, 1 + (0.21875)) = f (1, 0.78125) =
= 0.109375
2
k3 = hf (t0 +

y1 = 1 +

1
[ 0.5 + 2(0.125) + 2(0.21875) + 0.109375] = 0.8203125
6

y1 = 0.8203125
exercise , find y2 and y3

SECOND ORDER RUNGE KUTTA METHOD (RK2)


Second order version Runge Kutta method is
yk +1 = yk + h ( a1k1 + a2 k2 )

......................(1)

where,
k1 = f (t k , yk )
k2 = f (t k + p1h, yk + q11k1h)
where, a1 + a2 = 1,

a2 p1 =

..................(2)

1
,
2

a2q11 =

1
...................(3)
2

We have three equations and four unknowns , we must assume a value of one of the unknowns to
determine the other three. Suppose that we specify a value for a2 . Then equation (3) can be solved
simultaneously for
a1 = 1 a2 ,

p1 = q11 =

1
2a2

We can choose an infinite number of values for a2 , we present three of the most commonly used.
1. HEUNS METHOD ( a2 =
yk + 1 = yk +

1
) Single corrector
2

h
( k1 + k2 )
2

where,
k1 = f (t k , yk )
k2 = f (t k + h, yk + k1h)
2. THE MIDPOINT METHOD ( a2 = 1)
1
then,
a1 = 0, p1 = q11 =
2

yk + 1 = yk + k 2 h
where,
k1 = f (t k , yk )
k2 = f (tk +

1
h
, yk + k1h)
2
2

ROLSTONS METHOD ( a2 =

if a2 =

2
1
, a1 =
and
3
3

2
)
3

p1 = q11 =

3
4

2
1
yk +1 = yk + h k1 + k2
3
3
where,
k1 = f (t k , yk )
3
3
k2 = f (t k + h, yk + k1h)
4
4

Example(E.Q) : Find the value of the solution at the point x=0.4 of


y = 1 + t y 2 , y ( 0) = 1
defined over the interval [0,1] with h=0.2 using the second order Runge Kutta formula

2
1
yk +1 = yk + h k1 + k2
3
3
where,
k1 = f (t k , yk )
3
3
k2 = f (t k + h, yk + k1h)
4
4
Solution
0

t0

0.2

0.4

t1

t2

t5

2
2
1
1
y1 = y0 + h k1 + k2 = 1 + 0.2 k1 + k2
3
3
3
3
where,
k1 = f (t0 , y0 ) = f (0, 1) = 1 + 0 1 = 0
3
3
k2 = f (t0 + 0.2, y0 + 0(0.2)) = f (0.15, 1) = 1 + 0.15 1 = 0.15
4
4
2
1

y (0.2) = y1 = 1 + 0.2 0 + 0.15 = 1.02


3
3

y (0.2) = y1 = 1.02
9

2
2
1
1
y2 = y1 + h k1 + k2 = 1.02 + 0.2 k1 + k2
3
3
3
3
where,
k1 = f (t1 , y1 ) = f (0.2, 1.02) = 1 + 0.2 1.022 = 0.159
3
3
k2 = f (t1 + 0.2, y1 + (0.159)(0.2)) = f (0.35, 1.043) = 1 + 0.35 1.0432 = 0.26
4
4
2
1

y (0.2) = y1 = 1.02 + 0.2 0.159 + 0.26 = 1.06531


3
3

y (0.4) = y2 = 1.06531

10

You might also like