0% found this document useful (0 votes)
31 views19 pages

Unit 3

The document discusses numerical methods for solving ordinary differential equations. It introduces the initial value problem and defines basic concepts like order, degree, and linearity of differential equations. It then describes the Taylor series method and Euler's method for obtaining numerical solutions to initial value problems for first-order ordinary differential equations.

Uploaded by

Riswana Nowshad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views19 pages

Unit 3

The document discusses numerical methods for solving ordinary differential equations. It introduces the initial value problem and defines basic concepts like order, degree, and linearity of differential equations. It then describes the Taylor series method and Euler's method for obtaining numerical solutions to initial value problems for first-order ordinary differential equations.

Uploaded by

Riswana Nowshad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Differentiation,

Integration and
Differential Equations
UNIT 3 NUMERICAL SOLUTION OF
ORDINARY DIFFERENTIAL
EQUATIONS
Structure Page Nos.
3.0 Introduction 42
3.1 Objectives 42
3.2 Basic Concepts 42
3.3 Taylor Series Method 49
3.4 Euler’s Method 52
3.5 Summary 56
3.6 Solutions/Answers 57

3.0 INTRODUCTION
In the previous two units, you have seen how a complicated or tabulated function can
be replaced by an approximating polynomial so that the fundamental operations of
calculus viz., differentiation and integration can be performed more easily. In this
unit we shall solve a differential equation, that is, we shall find the unknown function
which satisfies a combination of the independent variable, dependent variable and its
derivatives. In physics, engineering, chemistry and many other disciplines it has
become necessary to build mathematical models to represent complicated processes.
Differential equations are one of the most important mathematical tools used in
modeling problems in the engineering and physical sciences. As it is not always
possible to obtain the analytical solution of differential equations recourse must
necessarily be made to numerical methods for solving differential equations. In this
unit, we shall introduce two such methods namely, Euler’s method and Taylor series
method to obtain numerical solution of ordinary differential equations (ODEs). To
begin with, we shall recall few basic concepts from the theory of differential equations
which we shall be referring to quite often.

3.1 OBJECTIVES
After studying this unit you should be able to:

• identify the initial value problem (IVP) for the first order ordinary differential
equations;
• state the difference between the single step and multi-step methods of finding
solution of IVP;
• obtain the solution of the initial value problems by using single-step methods
viz., Taylor series method and Euler’s method.

3.2 BASIC CONCEPTS


In this section we shall state a few definitions from the theory of differential equations
and define some concepts involved in the numerical solution of differential equations.

Definition: An equation involving one or more unknown function (dependent


variables) and its derivatives with respect to one or more known functions
(independent variables) is called differential equation.
For example,
42
dy Numerical Solution of
x = 2y (1) Ordinary Differential
dx Equations

∂z ∂z
x +y −z=0 (2)
∂x ∂y
are differential equations.

Differential equations of the form (1), involving derivatives w.r.t. a single independent
variable are called ordinary differential equations (ODEs) whereas, those involving
derivatives w.r.t. two or more independent variables are partial differential
equations (PDEs). Eqn. (2) is an example of PDE.

Definition: The order of a differential equation is the order of the highest order
derivative appearing in the equation and its degree is the highest exponent of the
highest order derivative after the equation has been rationalized i.e., after it has been
expressed in the form free from radicals and any fractional power of the derivatives or
negative power. For example equation

2 3
 d3y  2
  + 2 d y − dy + x 2  dy  = 0 (3)
 dx 3  dx 2 dx  dx 
 

is of third order and second degree. Equation

dy a
y= x +
dx dy / dx

is of first order and second degree as it can be written in the form

2
dy  dy 
y = x  + a (4)
dx  dx 

Definition: When the dependent variable and its derivatives occur in the first degree
only and not as higher powers or products, the equation is said to be linear, otherwise
it is nonlinear.

d2y dy
Equation 2
+ y = x 2 is a linear ODE, whereas (x+y)2 = 1 is a nonlinear ODE.
dx dx

2
∂2z  ∂2z 
∂2z
Similarly, + −   = 0, is a nonlinear PDE.
∂x 2 ∂y 2  ∂x ∂y 

In this unit we shall be concerned only with the ODEs.

The general form of a linear ODE of order n can be expressed in the form

L[y] ≡ a0 (t) y(n) (t) + a1 (t) y(n-1) (t) + …..+ an-1 (t) y′ (t) + an (t) y (t) = r(t) (5)

where r(t), ai (t), i = 0,1, 2, ……………., n are known functions of t and

dn d n −1 d
L = a0(t) n
+ a1 (t) n −1
+ ……………+an-1 (t) + an (t),
dt dt dt

is the linear differential operator. The general nonlinear ODE of order n can be
written as
43
Differentiation, F(t, y, y′, y′′, ……………, y(n)) = 0 (6)
Integration and
Differential Equations
or, y(n) = f (t, y, y′, y′′,…………, y(n-1)). (7)

Eqn. (7) is called a canonical representation of Eqn. (6). In such a form, the highest
order derivatives is expressed in terms of lower order derivatives and the independent
variable.

The general solution of an nth order ODE contains n arbitrary constants. In order to
determine these arbitrary constants, we require n conditions. If all these conditions
are given at one point, then these conditions are known as initial conditions and the
differential equation together with the initial conditions is called an initial value
problem (IVP). The nth order IVP alongwith associates initial conditions can be
written as

y(n) (t) = f (t, y, y′, y′′, ………., y(n-1))


y(p) (t0) = y (0p ) , p = 0, 1, 2, …….., n-1. (8)

We are required to find the solution y(t) for t > to

If the n conditions are prescribed at more than one point then these conditions are
known as boundary conditions. These conditions are prescribed usually at two
points, say t0 and ta and we are required to find the solution y(t) between to <t<ta .The
differential equation together with the boundary conditions is then known as a
boundary value problem (BVP).

As may be seen below, the nth order IVP (8) is equivalent to solving following system
of n first order equations:

Setting y = y 1,

Similarly setting y'i −1 = yi, we may write

y′ = y′1= y2 y1(t0) = y0
y′2 = y3 y2(t0) = y′0
…………. ……………
y′n-1 = yn yn-1 (t0) = y (0n − 2)

y′n = f(t, y1,y2, ………., yn) yn (t0) = y (0n −1) ;

In vector notation, this system can be written as a single equation as

dy
= f (t, y), y (t0) = α (9)
dx

where y = (y1, y2 ……….., yn)T, f(t,y) = (y2, y3, ………., f(t, y1, ……., yn))T

α (y0, y′0, …….., y (0n −1) )T.

Hence, it is sufficient to study numerical methods for the solution of the first order
IVP.
y′ = f(t, y), y(t0) = y0 (10)

The vector form of these methods can then be used to solve Eqn. (9). Before
attempting to obtain numerical solutions to Eqn, (10), we must make sure that the

44
problem has a unique solution. The following theorem ensures the existence and Numerical Solution of
Ordinary Differential
uniqueness of the solution to IVP (10). Equations

Theorem 1: If f(t, y) satisfies the conditions

i) f(t, y) is a real function


ii) f(t, y) is bounded and continuous for t ε [t0,b], y ε ] - ∞, ∞ [
iii) there exists a constant L such that for any t ε [t0, b] and for any two numbers y1
and y2
 f (t, y1) – f (t, y2)  ≤ L  y1 –y2 

then for any y0, the IVP (10) has a unique solution. This condition is called the
Lipschitz condition and L is called the Lipschitz constant.

We assume the existence and uniqueness of the solution and also that f(t,y) has
continuous partial derivatives w.r.t. t and y of as high order as we desire.

Let us assume that [t0, b] be an interval over which the solution of the IVP (10) is
required. If we subdivide the interval [t0, b] into n subintervals using a step size
tn − to 
h=   , where tn = b, we obtain the mesh points or grid points t0, t1, t2, ….., tn
 n 
as shown in Fig. 1.

h h

t0 t1 t2 tk tn-1 tn = b
Fig. 1

We can then write tk = t0 + kh, k = 0, 1, ….., n. A numerical method for the solution
of the IVP (10), will produce approximate values yk at the grid points tk in a step by
step manner i.e. values of y1, y2, …. etc in unit order.

Remember that the approximate values yk may contain the truncation and round-off
errors. We shall now discuss the construction of numerical methods and related basic
concepts with reference to a simple ODE.

dy
= λy, tε [a b] (11)
dt

y (t0) = y0,

where λ in a constant.

Let the domain [a, b] be subdivided into N intervals and

let the grid points be defined by,

tj = t0 + jh, j = 0, 1, ………….., N

where t0 = a and tN = t0 + Nh = b.

Separating the variables and integrating, we find that the exact solution of Eqn. (11) is

y(t) = y(t0) eλ(t-t0) . (12)


y(t0) eλ(t-t0)
45
Differentiation, In order to obtain a relation between the solutions at
Integration and two successive permits, t = tn and tn+1 in Eqn. (12), we use,
Differential Equations

y(tn) = y(t0) e λ ( t n − t 0 )
and

−t 0 )
y(tn+1) = y(t0) e λ ( t n +1 .

Dividing we get

y( t n +1 ) e λt n +1 − tn )
= λt = e λ ( t n +1 .
y( t n ) e n

Hence we have,

y(tn+1) = eλh y (tn), n = 0, 1, ….., N-1. (13)

Eqn. (13) gives the required relation between y (tn) and y(tn+1).

Setting n = 0, 1, 2, ……, N-1, successively, we can find y(t1), y(t2),…….., y(tN) from
the given value y(t0).

An approximate method or a numerical method can be obtained by approximating eλh


in Eqn. (13). For example, we may use the following polynomial approximations,

eλh = 1 + λh + 0 (λh2 ) (14)


2 2
λ h
eλh = 1 + λh + + 0 (λh3) (15)
2
λ2 h 2 λ3 h 3
eλh = 1 +λh + + + 0 ( λh4) (16)
2 6

and so on.

Let us retain (p + 1) terms in the expansion of eλh and denote the approximation to eλh
by E(λh). The numerical method for obtaining the approximate values yn of the exact
solution y(tn) can then be written as

yn+1 = E(λh) yn, n = 0, 1, ………, N-1 (17)

The truncation error (TE) of the method is defined by

TE = y (tn+1) – yn+1.

Since (p +1) terms are retained in the expansion of eλh, we have


TE = 1 + λh + ......... +
(λh ) + (λh ) p p +1  
e θλh  − 1 + λh + ....... +
(λ h ) p 

 p! (p+1)!  
  p! 

=
(λh )p +1 e θλh , 0<θ<1
(p + 1) !

The TE is of order p+1 and the numerical method is called of order p.

The concept of stability is very important in a numerical method.

46
We say that a numerical method is stable if the error at any stage, i.e. yn –y(tn) = εn Numerical Solution of
Ordinary Differential
remains bounded as n → ∞.Let us examine the stability of the numerical method Equations
(17). Putting yn+1 = y (tn+1) + εn+1 and yn = y(tn) + εn in Eqn. (17), we get

y(tn+1) + εn+1 = E(λh) [y(tn) + εn]

εn+1 = E(λh) [y(tn) + εn] – y (tn+1)

which on using eqn. (13) becomes

εn+1 = E(λh) [y(tn) + εn] - eλhy(tn)

∴ εn+1 = [E(λh) - eλh] y(tn) + E(λh) εn (18)

We note from Eqn. (18) that the error at tn+1 consists of two parts. The first part
E(λh) -eλh is the local truncation error and can be made as small as we like by
suitably determining Eλh. The second part E(λh) εn is the propagation error
from the previous step tn to tn+1and will not grow if E(λh) < 1. If E(λh) < 1,
then as n → ∞ the propagation error tends to zero and method is said to be absolutely
stable. Further, a numerical method is said to be relatively stable if
E(λh) ≤ eλh, λ >0.

The polynomial approximations (14), (15) and (16) always give relatively stable
methods. Let us now find when the methods yn+1 = E(λh) yn are absolutely stable
where E(λh) is given by (14) (15) or (16).

These methods are given by

First order: yn+1 = (1 + λh) yn

 λ2 h 2 
Second order: yn+1 = 1 + λh +  y n and
 2 

 λ2 h 2 λ3 h 3 
Third order: yn+1 = 1 + λh + + y n
 2 6 

Let us examine the conditions for absolute stability in various methods:

First order: 1 + λh ≤ 1


or -1≤ 1 + λh ≤ 1
or -2≤ λh ≤ 0
λ2 h 2
Second order:  1 + λh + ≤1
2

λ2 h 2
or – 1 ≤ 1 + λh + ≤1
2

The right inequality gives

 λh 
λh 1 + ≤ 0
 2 
λh
i.e., λh ≤ 0 and 1 + ≥ 0.
2

The second condition gives –2 ≤ λh. Hence the right inequality gives –2 ≤ λh ≤ 0.
47
Differentiation, The left inequality gives
Integration and
Differential Equations
λ2 h 2
2 + λh + ≥ 0.
2

For –2 ≤ λh ≤ 0, this equation is always satisfied. Hence the stability condition is


-2 ≤ λh ≤0.

λ2 h 2 λ3 h 3
Third order: 1 + λh + + ≤ 1
2 6
Using the right and left inequalities, we get

─ 2.5 ≤ λh ≤ 0.

These intervals for λh are known as stability intervals.

Numerical methods for finding the solution of IVP given by Eqn. (10) may be broadly
classified as,

i) Singlestep methods
ii) Multistep methods

Singlestep methods enable us to find yn+1, an approximation to y(tn+1), in terms of


yn, and y′n.

Multistep methods enable us to find yn+1, an approximation to y(tn+1), in terms of


yi, y′i , i = n, n-1, ……n-m+1 i.e. values of y and y′ at previous m points. Such
methods are called m-step multistep methods.

In this course we shall be discussing about the singlestep methods only.

A singlestep method for the solution of the IVP


y′ = f(t, y), y(t0) = y0, t ε (t0, b)
is a recurrence relation of the form
yn+1 = yn + h φ (tn, yn, h) (19)

where φ (tn, yn, h) is known as the increment function.

If yn+1 can be determined from Eqn. (19) by evaluating the right hand side, then the
singlestep method is known as an explicit method, otherwise it is known as an
implicit method. The local truncation error of the method (19) is defined by

TE = y ( t n +1 ) -y(tn) - h φ (tn, yn, h) . (20)

The largest integer p such that

h-1 TE = O (hp) (21)


is called the order of the singlestep method.

Let us now take up an example to understand how the singlestep method works.

Example 1: find the solution of the IVP y′ = λy, y(0) = 1 in 0 < t ≤ 0.5, using the first
order method

yn+1= (1 + λh) yn with h = 0.1 and λ = ± 1.

48
0.5 0.5 Numerical Solution of
Solution: Here the number of intervals are N = = =5 Ordinary Differential
h 0.1 Equations
We have y0 = 1
y1 = (1 + λh) y0 = (1 + λh) = (1 + 0.1λ)
y2 = (1 + λh) y1 = (1 + λh)2 = (1 + 0.1λ)2
---------------------------------------------------

y5 = (1 + λh)5 = (1 + 0.1λ)5

The exact solution is y(t) = eλt.


We now give in Table 1 the values of yn for λ = ± 1 together with exact values.

Table 1
Solution of y′ = λy, y(0) = 1, 0 ≤ t ≤ 0.5 with h = 01.
λ=1 λ = ─1
t First Order Exact First Order Exact
method Solution method Solution
0 1 1 1 1
0.1 1.1 1.10517 0.9 0.90484
0.2 1.21000 1.22140 0.81 0.81873
0.3 1.33100 1.34986 0.729 0.74082
0.4 1.46410 1.49182 0.6561 0.67032
0.5 1.61051 1.64872 0.59049 0.60653

Similarly you can obtain the solution using the second order method and compare the
results obtained in the two cases.

Ex 1) Find the solution of the IVP


y′ = λy, y(0) = 1
in 0 ≤ t ≤ 0.5 using the second order method
 λ2 h 2 
yn+1 = 1 + λh + y with h = 0.1 and λ = 1.
 n
 2 

We are now prepared to consider numerical methods for integrating differential


equations. The first method we discuss is the Taylor series method. It is not strictly a
numerical method, but it is the most fundamental method to which every numerical
method must compare.

3.3 TAYLOR SERIES METHOD


Let us consider the IVP given by Eqn. (10), i.e.,

y′ = f(t,y), y(t0) = y0, t ε [t0, b]

The function f may be linear or nonlinear, but we assume that f is sufficiently


differentiable w.r.t. both t and y.

The Taylor series expansion of y(t) about any point tk is given by

(t − t k )2 (t − t k )p
y(t) = y(tk) + (t-tk) y′ (tk) + y ′′ ( t k ) + ....... + y ( p ) ( t k ) +……. (22)
2! p!

Substituting t = tk+1 in Eqn. (22), we have


49
Differentiation, h 2 y ′′( t k ) h p y (p) ( t k )
Integration and y(tk+1) = y(tk) + hy′ (tk) + + ........ + + ..... (23)
Differential Equations 2! p!

where tk+1 = tk + h. Neglecting the terms of order hp+1 and higher order terms, we have
the approximation
h2 h p (p)
yk+1 = yk + hy′k + y ′k′ + ..... + y (24)
2! p! k
= yk + h φ (tk, yk, h)
h h p −1 ( p )
where φ (tk, yk, h) = y′k + y ′k′ + ..... + y
2! p! k

This is called the Taylor Series method of order p. The truncation error of the method
is given by

TE = y (tk+1) – y(tk ) - hφ (tk,y(tk), h) (25)

h p +1 ( p +1)
= y ( t k + θh ), 0 < θ < 1
(p + 1) !

when p = 1, we get from Eqn. (24)


yk+1 = yk + hy′k (26)

which is the Taylor series method of order one.

To apply (24), we must know y(tk), y′(tk), y′′(tk)………., y(p) (tk).

However, y(tk) is known to us and if f is sufficiently differentiable, then higher order


derivatives can be obtained by calculating the total derivative of the given differential
equation w.r.t. t, keeping in mind that y is itself a function of t. Thus we obtain for the
first few derivatives as:

y′ = f(t,y)
y′′ = ft + f fy
y′′′ = ftt +2 f fty + f2 fyy + fy (ft + ffy) etc.

∂ 2f
where ft = ∂f / ∂t , f tt = ∂ 2 f / ∂t 2 , fty = etc.
∂t 2 y

The number of terms to be included in the method depends on the accuracy


requirements.

Let p = 2. Then the Taylor Series method of O(h2) is


h 2 y ′k′
yk+1 = yk + hy′k + (27)
2

h3
with the TE = y′′′ (α) , t n < α < t n +1
6

The Taylor series method of O(h3), (p = 3) is

h 2 y ′k′ h3
yk+1 = yk + hy′k + + y ′k′′ (28)
2 6
h 4 ( IV)
with the TE = y (α ) , t k ≤ α ≤ t k +1
24

50
Let us consider the following examples. Numerical Solution of
Ordinary Differential
Equations
Example 2: Using the third order Taylor series method find the solution of the
differential equation.

xy′ = x-y, y = 2 at x = 2, taking h =1.

Solution: We have the derivatives and their values at x=2, y=2 as follows:

y(2) = 2 is given. Further, xy′ = x-y can be written as


y
y′ = 1 -
x
2
y′ (2) = 1 - = 0.
2

Differentiating w.r.t. x, we get

y′ y
y′′ = 0 - +
x x2

0 2 1
y′′ (2) = - + = .
2 4 2

y 2
y′ = 1- =1- =1 −1
k 2
Similarly,

y′′ 2y′ 2y
y′′′ = − + − , y′′′ (2) = − 3 / 4
x x 2 x3

1 2× 0 2 x 2
y′′′ (2) = − + −
4 4 8

3
=
4

Using taylor series method of O(h3) given by Eqn. (28), we obtain


(.1) 2 (.1) 3
y(2 + .1) = y(2) + 01 x y′ (2) + y′′(2) + y′′′(2)
2 6
or
1
y( 2.1) = 2 + .1 x 0 + .005 x .5 + .001 x × (− .75)
6

= 2+0.0025-0.000125 = 2.002375.

Example 3: Solve the equation x2y′ = 1 –xy –x2y2, y(1) = -1 from x=1 to x=2 by
using Taylor series method of O(h2) with h = 1/3 and ¼ and find the actual error at
x=2 if the exact solution is y = -1/x.
1 y
Solution: From the given equation, we have y′ = 2
− − y2
x x
Differentiating it w.r.t. x, we get

−2 y′ y
y ′′ = 3
− + − 2 yy ′
x x x2

Using the second order method (27),


51
Differentiation, h2
Integration and yk+1 = yk +hy′k + y ′′k
Differential Equations 2

We have the following results


1
h= , y(1) = -1, y′(1) = 1, y′′(1) = -2.
3
4
x1 = , y(x1) = ─ 0.7778, y′(x1) = 0.5409, y′′(x1) = ─ 0.8455.
3
5
x2 = , y(x2) = ─ 0.6445, y′(x2) = 0.3313, y′′(x2) = ─ 0.4358.
3

x3 = 2, y(x3) = ─ 0.5583 = y(2)


1
h=
4
5
x1 = , y(x1) = ─ 0.8125, y′(x1) = 0.6298, y′′(x1) = ─ 1.0244.
4
3
x2 = , y(x2) = ─ 0.6871, y′(x2) = 0.4304, y′′(x2) = ─ 0.5934.
2
7
x3 = , y(x3) = -0.5980, y′(x3) = 0.3106, y′′(x3) = ─ 0.3745.
4
x4 = 2, y(x4) = -0.5321 = y(2)

Since the exact value is y(2) =─0.5, we have the actual errors as

1
e1 = 0.0583 with h =
3
1
e2 = 0.0321 with h =
4
Note that error is small when the step size h is small.
You may now try the following exercise.

Write the Taylor series method of order four and solve the IVPs E2) and E3).

E2) y′ = x – y2, y(0) = 1. Find y(0.1) taking h = 0.1.

E3) y′ = x2 + y2, y(0) = 0.5. Find y(0.4) taking h = 0.2.

E4) Using second order Taylor series method solve the IVP
y
y′ = 3x + , y(0) = 1. Find y(0.6) taking h = 0.2 and h = 0.1.
2

Find the actual error at x = 0.6 if the exact solution is y = -6x –12.

Notice that though the Taylor series method of order p give us results of desired
accuracy in a few number of steps, it requires evaluation of the higher order
derivatives and becomes tedious to apply if the various derivatives are complicated.
Also, it is difficult to determine the error in such cases. We now consider a method,
called Euler’s method which can be regarded as Taylor series method of order one
and avoids these difficulties.

3.4 EULER’S METHOD


Let the given IVP be

y′ = f(t, y), y(t0) = y0.


52
Let [t0, b] be the interval over which the solution of the given IVP is to be Numerical Solution of
Ordinary Differential
determined. Let h be the steplength. Then the nodal points are defined by tk = t0 + kh, Equations
k = 0, 1, 2, …………., N with tN = t0 +Nh = b.

h h

t0 t1 t2 tk tN = b

Fig. 1

The exact solution y(t) at t = tk+1 can be written by Taylor series as

h  2 
y(tk + h) = y(tk) + hy′ (tk) +   y ′′( t k ) + ..... (29)
 2 

Neglecting the term of O(h2) and higher order terms, we get

yk+1 = yk + hy′k (30)

h  2 
with TE =   y ′′ (α), t k < α < t k +1 (31)
 2 

From the given IVP, y′ (tk) = f(tk, yk) = fk

We can rewrite Eqn. (30) as

yk+1 = yk + h fk

for k = 0, 1, …….., N-1. (32)

Eqn. (32) is known as the Euler’s method and it calculates successively the solution at
the nodal points tk, k = 1, ………, N.

Since the truncation error (31) is of order h2, Euler’s method is of first order. It is also
called an O(h) method.

Let us now see the geometrical representation of the Euler’s method.

Geometrical Interpretation
dy
Let y(t) be the solution of the given IVP. Integrating = (t, y) from tk to tk+1, we get
dt

t k +1
t k +1 dy

tk dt
dt = ∫ f (t, y) dt = y(t
tk
k +1 ) − y( t k ). (33)

We know that geometrically f(t, y) represents the slope of the curve y(t). Let us
approximate the slope of the curve between tk and tk+1 by the slope at tk only. If we
approximate y(tk+1) and y(tk) by yk+1 and yk respectively, then we have
t k +1

yk+1 – yk = f(tk, yk) ∫


tk
dt (34)

= (tk+1 – tk) f(tk, yk)


= hf (tk, yk)
53
Differentiation, ∴ yk+1 = yk + hf (tk, yk), k = 0, 1, 2, …., N-1.
Integration and
Differential Equations
Thus in Euler’s method the actual curve is approximated by a sequence of the
segments and the area under the curve is approximated by the area of the quadrilateral.

Let us now consider the following examples.

Example 4: Use Euler method to find the solution of y′ = t + y, given y(0) = 1.


Find the solution on [0, 0.8] with h = 0.2.

Solution: We have
yn+1 = yn + hfn
y(0.2) ≈ y1 = y0 + (0.2) f0
= 1 + (0.2) [0 + 1] = 1.2

y(0.4) ≈ y2 = y1 + (0.2) f1
= 1.2 + (0.2) [0.2 + 1.2]
= 1.48

y(0.6) ≈ y3 = y2 + (0.2) f2
= 1.48 + (0.2) [0.4 + 1.48]
= 1.856

y(0.8) ≈ y4 = y3 + (0.2) f3
= 1.856 + (0.2) [0.6 + 1.856]
= 2.3472

Example 5: Solve the differential equation y′ = t+y, y(0) = 1. t ε [ 0, 1] by Euler’s


method using h = 0.1. If the exact value is y(1) = 3.436564, find the exact error.

Solution: Euler’s method is

yn+1 = yn + hy′n

For the given problem, we have


yn+1 = yn + h [tn + yn]
(1 + h) yn + htn.
h = 0.1, y(0) = 1,
y1 = y0 = (1+0.1) + (0.1) (0) = 1.1
y2 = (1.1) (1.1) + (0.1) (0.1) = 1.22, y3 = 1.362
y4 = 1.5282, y5 = 1.72102, y6 = 1.943122,
y7 = 2.197434, y8 = 2.487178, y9 = 2.815895
y10 = 3.187485 ≈ y(1)
exact error = 3.436564-3.187485 = .249079

Example 6: Using the Euler’s method tabulate the solution of the IVP

y′ = -2ty2, y(0) =1

in the interval [0,1] taking h = 0.2, 0.1.


Solution: Euler’s method gives

yk+1= yk + h fk where tk = -2tk y 2k


= yk –2h tk y 2k .

Starting with t0 = 0, y0 = 1, we obtain the following table of values for h = 0.2.


54
Table 2: h = 0.2 Numerical Solution of
T y(t) Ordinary Differential
Equations
0.2 0.92
0.4
0.6 0.78458
0.8 0.63684
1.0 0.50706

Thus y(1.0) = 0.50706 with h = 0.2


Similarly, starting with t0 = 0, y0 = 1, we obtain the following table of values for h =
0.1.
Table 3: h = 0.1
t y(t) T y(t)
0.1 1.0 0.6 0.75715
0.2 0.98 0.7 0.68835
0.3 0.94158 0.8 0.62202
0.4 0.88839 0.9 0.56011
0.5 0.82525 1.0 0.50364

y(1.0) = 0.50364 with h = 0.1.

Remark: Since the Euler’s method is of O(h), it requires h to be very small to obtain
the desired accuracy. Hence, very often, the number of steps to be carried out becomes
very large. In such cases, we need higher order methods to obtain the required
accuracy in a limited number of steps.

Euler’s method constructs yk ≈ y(tk) for each k = 1, 2, …., N,


where
yk+1 = yk + hf(tk, yk).

This equation is called the difference equation associated with Euler’s method. A
difference equation of order N is a relation involving yn, yn+1, ……, yn+N. Some simple
difference equations are

y n +1 − y n = 1 

y n +1 − y n = n  (35)
y n +1 − (n + 1) y n = 0

where n is an integer.

A difference equation is said to be linear if the unknown function y n + k (k = 0, 1,


……., N) appear linearly in the difference equation. The general form of a linear non-
homogeneous difference equation of order N is
yn+N + aN-1 yn+N-1 +………..+a0 yn = b (36)

where the coefficients aN-1, aN-2, …………, a0 and b may be functions of n but not of y.
All the Eqns. (35) are linear. It is easy to solve the difference Eqn. (36), when the
coefficients are constant or a linear or a quadratic function of n.
The general solution of Eqn. (36) can be written in the form

yn = yn(c) + y (np )

where yn (c) is the complementary solution of the homogenous equation associated


with Eqn. (36) and yn(p) is a particular solution of Eqn. (36). To obtain the
complementary solution of the homogeneous equations, we start with a solution in the

55
Differentiation, form yn = βn and substitute it in the given equation. This gives us a polynomial of
Integration and
degree N. We assume that its roots β1, β2,…………,βN are all real and distinct.
Differential Equations

Therefore, the general solution of the given problem is


5
yk = C (1+3h)k -
3

Using the condition y(0) = 1, we obtain C = 8/3.

Thus
8 5
yk = (1 + 3h ) k − .
3 3

Eqn. (41) gives the formula for obtaining yk ∀ k.

8 5
y6 = y(0.6) = (1 + 3 × 0.1) 6 −
3 3

= 11.204824.

Now Euler’s method is

yk+1 = (1 + 3h) yk + 5h

and we get for h = 0.1

y1 = 1.8, y2 = 2.84, y3 = 4.192, y4 = 5.9496, y5 = 8.23448, y6 = 11.204824.

You may now try the following exercises

Solve the following IVPs using Euler’s method

E5) y′ = 1 –2xy, y(0.2) = 0.1948. Find y(0.4) with h = 0.2

1
E6) y′ = , y(4) = 4. Find y(4.1) taking h = 0.1
x − 4y '
2

y−x
E7) y′ = , y(0) = 1. Find y(0.1) with h = 0.1
y + x'

E8) y′ = 1 + y2, y(0) = 1. Find y(0.6) taking h = 0.2 and h = 0.1

E9) Use Euler’s method to solve numerically the initial value problem y′ = t + y,
y(0) = 1 with h = 0.2, 0.1 and 0.05 in the interval [0.06].

3.5 SUMMARY
In this unit, we have covered the following

1) y′ = f(t, y), y (t0) = y0, tε [t0, b] is the initial value problem (IVP) for the first
order ordinary differential equation.
2) Singlestep methods for finding the solution of IVP enables us to find
yn+1, if yn, y′n and h are known.
3) Multistep method for IVP enables as to find yn+1, if yi, y′i, i = n, n-1, …..,
n-m+1 and h are known and are called m-step multistep methods.

56
4) Taylor series method of order p for the solution of the IVP Numerical Solution of
Ordinary Differential
is given by Equations
yk+1 = yk + h φ [ tk, yk, h]
h h p −1 ( p )
where φ [ tk, yk, h] = y′k + y ′k′ + ........... + y and t k = t 0 + kh , k = 0, 1, 2,
2! p! k
…………..N-1, tN = b. The error of approximation is given by
h p +1 ( p +1)
TE = y (tk + θh), 0 < θ < 1.
(p + 1) !

5) Euler’s method is the Taylor series method of order one. The steps involved in
solving the IVP given by (10) by Euler’s method are as follows:

Step 1: Evaluate f(t0, y0)


Step 2: Find y1 = y0 + h f(t0, y0)
Step 3: If t0 < b, change t0 to t0 + h and y0 to y1 and repeat steps 1 and 2
Step 4 : If t0 = b, write the value of y1.

3.6 SOLUTIONS/ANSWERS
E1) We have y0 = 1, λ = 1, h = 0.1

 (0.1) 2 
y1 = 1 + 0.1 + 
 2 
 

y2 = (1.105)2
----------------
y5 = (1.105)5
Table giving the values of yn together with exact values is

Table 4
t Second order method Exact solution
0 1 1
0.1 1.105 1.10517
0.2 1.22103 1.22140
0.3 1.34923 1.34986
0.4 1.49090 1.49182
0.5 1.64745 1.64872

E2) Taylor series method of 0(h4) to solve y′ = x-y2, y(0) = 1 is

h2 h3 h 4 iv
yn+1 = yn + hy′n + y ′n′ + y ′n′′ + yn
2 6 24
y′ = x – y2 y′ (0) = -1
y′′ = 1-2xy′ y′′ (0) = 3
y′′′ = -2xy′′ - 2(y′)2 y′′′(0) = -8
yiv = -2yy′′ - 6y′ y′′ yiv (0) = 34

Substituting
(0.1) 2 (0.1) 3 (0.1) 4
y(0.1) = 1 –(0.1) (-1) + (3) + (−8) + (34)
2 6 24
= 0.9138083

E3) Taylor series method

y′ = x2 + y2, y(0) = 0.5, y′ (0) = 0.25, y′(0.2) = 0.35175


57
Differentiation, y′′ = 2x + 2yy′ y′′ (0) = 0.25, y′′ (0.2) = 0.79280
Integration and
y′′′ = 2 + 2yy′′ + 2(y′)2 y′′′(0) = 2.375, y′′′ (0.2) = 3.13278
Differential Equations
yiv = 2yy′′′ + 6y′ y′′ yiv (0) = 2.75, yiv (0.2) = 5.17158

E4) Second order Taylor’s method is


h2
yn+1 = yn + hy′n + y ′n′ .
2
h = 0.2
y(0) = 1. y′(0) = 0.5, y′′(0) = 3.25
y(0.2) = 1.165, y′(0.2) = 1.1825, y′′(0.2) = 3.59125
y(0.4) = 1.47333, y′(0.4) = L93667, y′′(0.4) = 3.96833
y(0.6) = 1.94003

h = 0.1
y(0.1) = 1.06625, y′(0.1) = 0.83313, y′′(0.1) = 3.41656
y(0.2) = 1.16665, y′(0.2) = 1.18332, y′′(0.2) = 3.59167
y(0.3) = 1.46457, y′(0.3) = 1.63228, y′′(0.3) = 3.81614
y(0.4) = 1.64688, y′′(0.4) = 2.02344, y′′(0.4) = 4.01172
y(0.5) = 1.86928, y′(0.5) = 2.43464, y′′(0.5) = 4.21732
y(0.6) = 2.13383

E5) Euler’s method is yk+1 = yk + hfk = yk + h (1-2xk yk)


y(0.4) = 0.1948 + (0.2) (1-2 x 0.2 x 0.1948)
= 0.379216.

1
E6) y′ = 2
, y(4) = 4, y′(4) = 0.05
x +y
y(4.1) = y(4) + hy′(4)
= 4+ (0.1) (0.05) = 4.005.

E7) Euler’s method y′ = (y-x) / (y + x), y(0) = 1, y′(0) = 1


y(0.1) = 1 + (0.1) (1) = 1.1

E8) Euler’s method is


yk+1 = h + yk + hy 2k

Starting with t0 = 0 and y0 = 1, we have the following tables of values


Table 5: h = 0.2
T Y(t)
0.2 1.4
0.4 1.992
0.6 2.986

∴ y(0.6) = 2.9856

Table 6: h = 0.1
T Y(t)
0.1 1.2
0.2 1.444
0.3 1.7525
0.4 2.1596
0.5 2.7260
0.6 3.5691

∴ y(0.6) = 3.5691

58
E9) yk+1 = yk + h (tk + yk) = (1 + h) yk + htk Numerical Solution of
Ordinary Differential
Equations
Starting with t0 = 0, y0 = 1, we obtain the following of values.

Table 7: h = 0.2
T Y(t)
0.2 1.2
0.4 1.48
0.6 1.856

∴ y(0.6) = 1.856 with h = 0.2

Table 8: h = 0.1
t y(t)
0.1 1.1
0.2 1.22
0.3 1.362
0.4 1.5282
0.5 1.72102
0.6 1.943122

∴y(0.6) = 1.943122 with h = 0.1

Table 9: h = 0.05
t y(t) T y(t)
0.05 1.05 0.35 1.46420
0.10 1.105 0.40 1.55491
0.15 1.16525 0.45 1.65266
0.20 1.23101 0.50 1.75779
0.25 1.30256 0.55 1.87068
0.30 1.38019 0.60 1.99171
∴ y(0.6) = 1.99171 with h = 0.05.

59
Differentiation,
Integration and
Differential Equations

60

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy