0% found this document useful (0 votes)
17 views

Lecture Notes ODEs

This document outlines a course on ordinary differential equations (ODEs). The course aims to introduce analytical and numerical methods for determining solutions to ODEs that model practical applications. It will cover first order ODEs, higher order ODEs, Laplace transforms, and numerical solutions. Students will learn techniques for solving separable, linear, exact, and homogeneous ODEs analytically and will study numerical methods like Taylor series, Euler's method, and Runge-Kutta.

Uploaded by

vongai chimbunde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lecture Notes ODEs

This document outlines a course on ordinary differential equations (ODEs). The course aims to introduce analytical and numerical methods for determining solutions to ODEs that model practical applications. It will cover first order ODEs, higher order ODEs, Laplace transforms, and numerical solutions. Students will learn techniques for solving separable, linear, exact, and homogeneous ODEs analytically and will study numerical methods like Taylor series, Euler's method, and Runge-Kutta.

Uploaded by

vongai chimbunde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

MATHEMATICAL METHODS FOR ENGINEERS

SECTION : ORDINARY DIFFERENTIAL EQUATIONS

LECTURER : PROFESSOR S. MUSHAYABASA

DEPARTMENT : MATHEMATICS & COMPUTATIONAL SCIENCES, UZ

Course Outline
Purpose of the course

• To introduce the standard methods and algorithms for determining solutions of


ordinary differential equations (ODEs) analytically and numerically.

Aims of the course

• The course aims at discuss various methods of solving different kinds of mathe-
matical problems which arise from practical applications and can be modelled by
linear or non-linear ODEs.

Objectives (Intended Learning Outcomes)

• To develop a good understanding of the mathematical basis of the various methods


used to determine analytical and numerical solutions of scientific problems which
are modelled using ODEs.

Course Content

ODEs provides a powerful means of summarizing various real world problems. There
are various ways which can be used to solve the proposed models. In nutshell, the
techniques can be either analytic or numeric. It is intended that, on completing the
course, students will be able to apply analytical and numerical methods to problems
which they encounter in academic and beyond. The course consists of four sections
which are as follows:

1
CHAPTER 1: First Order Differential Equations

• Introduction

• Separable first order differential equations

• Linear first order differential equations

• Exact first order differential equations

• Homogeneous first order differential equations

• Bernoulli’s differential equations

CHAPTER 2: Higher Order Differential Equations

• Introduction

• Homogeneous differential equations

• Nonhomogeneous differential equations

CHAPTER 3: Laplace transforms

• Introduction

• Linear transforms

• Inverse transforms

• Applications

CHAPTER 4: Numerical Solutions of Ordinary Differential equations

• Taylor series method

• Euler’s method

• Second order Taylor method

• Runge-Kutta methods.

References

• Burden, Richard L., and Faires, Douglas J.(1993). Numerical Analysis. 5th Ed.
Boston: PWS KENT Publishing Company.

2
• Curtis, Gerald F, and Wheately, Patrick O. (1994). Applied Numerical Analysis
5th Ed. Addison-wesley Publishing Company, Reading.

• T. Akai (1996). Numerical Methods for Engineers .John Wiley & sons

• J.H. Mathews, (1992). Numerical Methods for Mathematics, Science and Engi-
neering, Prentice Hall International Editions.

3
Chapter 1

First Order Differential Equations

1.1 What is an ordinary differential equation?


• An ordinary differential equation (ODE) is a relation between two variables, x, y
and the derivatives y 0 , y 00 , y 000 ......

• Differential equations occur in numerous situations where physical phenomena are


represented by a mathematical model. For example

1. the speed of certain chemical reaction A + B → C can be modelled by the


following ODE
dx
= k(a − x)(b − x), (1.1)
dt
where a and b are the initial amounts of the reactants A and B respectively,
k is a known constant and x is the amount of product C formed at time t;

2. the current i(t) flowing in an R − L (resistor-inductor ) circuit with applied


e.m.f (electromotive force) E(t) can be modelled by the following equation:
di
L + Ri = E(t); (1.2)
dt
where R is the resistance of the circuit and L is the inductance of the circuit.

3. the angular displacement θ(t) at any time t of a rigid body pendulum can be
modelled by the ODE
d2 θ
I + mgh sin θ = 0; (1.3)
dt2
4
where I, m, g and h are constants.

• The order of a differential equation is simply the order of the highest deriva-
tive which occurs in the equation. For example, Equations (1.1) and (1.2) are
First-order differential equations while Equation (1.3) is a second-order differen-
tial equation.

1.2 First order differential equations


• The most general first order differential equation has the form

f (x, y, y 0 ) = 0. (1.4)

• There are various classes of Equation (1.4). Examples are

1. Separable ODEs

2. Linear ODEs

3. Exact ODEs

1.3 Separable differential equations


• The differential equation y 0 = f (x, y) is said to be separable if the right hand side
.i.e f (x, y) can be written as the product of two factors, one containing x only and
another y only, that is, f (x, y) = h(x)g(y).

• Thus the ODE can be presented as follows


dy
= f (x, y) = h(x)g(y), (1.5)
dx

• In such cases we can solve Equation (1.5) by integrating both sides with respect
to x, thereby obtaining the solution in implicit form as follows:
Z Z
dy
= h(x)dx (1.6)
g(y)

Example 1.1. Determine the general solution of the following differential equation:

y 0 = xy (1.7)

5
Solution 1.1. We can write Equation (1.7) as follows
Z Z
dy
= xdx. (1.8)
y

Simplifying Equation (1.8) leads to

2 /2
y = Ae−x (1.9)

where A is a constant.

Example 1.2. Solve the equation

y 0 + y 2 sin x = 0, y(0) = 1 (1.10)

Solution 1.2. • Equation (1.10) is known as the initial value problem (IVP) since
the dependent variable has specified initial conditions (y(0) = 1.)

• To solve Equation (1.10) we can manipulate it as follows

dy
= −y 2 sin x
Z dx Z
dy
= − sin xdx
y2
1
− = cos x + A (1.11)
y

1
• Using the initial conditions one gets A = −2. Thus the solution is y = .
2 − cos x

1.4 Linear differential equations


• A first order differential equation f (x, y, y 0 ) = 0 is said to be linear if it is linear
in both y and y 0

• For example, 2xy 0 − x2 y = sin x is of the linear type but 2xy 0 − xy 2 = sin x is
not of the linear type.

• In general a linear first order ODEs has the form

dy
+ p(x)y = g(x), y(x0 ) = y0 . (1.12)
dx

6
• In order to obtain the solution of (1.12) one has to determine an integrating
factor, say µ(x) such that after multiplying Equation (1.12) with it through out,
that is
" #
dy
µ(x) + p(x)y = µ(x)g(x), (1.13)
dx
we have the relation
" #
dy d
µ(x) + p(x)y = [µ(x)y(x)]. (1.14)
dx dx

• For the relation (1.14) to be satisfied the integrating factor should satisfy
Z
p(x)dx
µ(x) = e . (1.15)

Example 1.3. Determine the general solution of the following differential equa-
tion:
dy
+ 2y = e−x , y(0) = 3/4. (1.16)
dx
Solution 1.3. – One can easily observe that this is not separable.

– With p(x) = 2 and g(x) = e−x we have


Z !
µ(x) = exp 2dx = e2x . (1.17)

– Multiplying (1.16) with the integration factor throughout leads to


dy
e2x + 2ye2x = e−x e2x
dx
d
(ye2x ) = ex
dx
(1.18)

– Integrating (1.18) with respect to x both sides leads to


Z
y(x)e = ex dx
2x

Z !
y(x) = e−2x ex dx + A

y(x) = e−x + Ae−2x . (1.19)

– Using the initial conditions we have A = − 14 . Thus.


!
−x 1 −2x −x 1 −x
y(x) = e − e =e 1− e . (1.20)
4 4

7
1.5 Exact first order differential equations
• A first order differential equation is said to be exact if it is of the form

M (x, y)dx + N (x, y)dy = 0, (1.21)

∂f (x, y) ∂f (x, y)
where M (x, y) = and N (x, y) = , and satisfies the relation
∂x ∂y

∂M (x, y) ∂N (x, y)
= . (1.22)
∂y ∂x

• Among several methods, the intuitive solution of (1.21) is obtained by integrating


both M (x, y) and N (x, y) and involve repeating terms only once.

dy
Example 1.4. Solve 2xy − 9x2 + (2y + x2 + 1) = 0.
dx
Solution 1.4. • First let us write the Equation in the standard form, that is

(2xy − 9x2 )dx + (2y + x2 + 1)dy = 0.

• Test, whether it is exact DE

∂M ∂
= (2xy − 9x2 ) = 2x,
∂y ∂y

∂N ∂
= (2y + x2 + 1) = 2x,
∂x ∂x

• The test has been confirmed we can now solve the exact DE
Z Z
M (x, y)dx = (2xy − 9x2 )dx = x2 y − 3x3 + C1 ,

Z Z
N (x, y)dy = (2y + x2 + 1)dy = y 2 + x2 y + y + C2

• Thus f (x, y) := x2 y − 3x3 + y 2 + y + C.

Example 1.5. Solve (2xy 2 + 4) = 2(3 − x2 y)y 0 y(−1) = 8.

Solution 1.5. • First let us write the Equation in the standard form, that is

(2xy 2 + 4)dx + 2(x2 y − 3)dy = 0.

8
• Test, whether it is exact DE
∂M ∂
= (2xy 2 + 4) = 4xy,
∂y ∂y

∂N ∂
= (2x2 y − 6) = 4xy,
∂x ∂x
• The test has been confirmed we can now solve the exact DE
Z Z
M (x, y)dx = (2xy 2 + 4)dx = x2 y 2 + 4x + C1 ,

Z Z
N (x, y)dy = (2x2 y − 6)dy = x2 y 2 − 6y + C2

• Thus the general solution is x2 y 2 + 4x − 6y = C.

• Using the initial values y(−1) = 3 we have

(−1)2 · 82 + 4(−1) − 6 · 8 = C ⇒ C = 12.

• Therefore the particular solution is x2 y 2 + 4x − 6y = 12.

1.6 Homogeneous first order differential equations


• We often convert complicated first differential equations into simple differential
equations by substitution.

• For example differential equations


!
dy y y
− − sin = 0,
dx x x
! !
x2 y
1 + 2 dx + 1 − dy = 0 (1.23)
y x
y
can be simplified by means of substitution u = .
x
• If a differential equation (DE) has the form of

M (x, y)dx + N (x, y)dy = 0 (1.24)

Then if M (x, y) and N (x, y) are homogeneous function of the same order, then
substitution can be used to solve the DE since it will transform the equation into
a simple form.

9
• If M (x, y) and N (x, y) can be written in the form

M (x, y) = xn · g1 (u),
y
N (x, y) = xn · g2 (u), where, u= . (1.25)
x

• then both members are homogeneous functions of order n.


y
• It follows from the substitution u = ⇒ y = ux that
x
dy = du x + u dx.

x
• In some instance it is preferable to use u = . in such case the test proving that
y
substitution leads to DE with separable variables is

M (x, y) = y n · g1 (u),
y
N (x, y) = y n · g2 (u), where, u= . (1.26)
x

Example 1.6. Solve the differential equation

2xydx + (x2 + y 2 )dy = 0

by substituting u = y/x.

Solution 1.6. • We begin by testing if the DE is really homogeneous.


! !
2
y y
x2 2 dx + x2 1 + 2 dy = 0. (1.27)
x x

• One can easily locate both members M (x, y) and N (x, y), thus

M (x, y) = x2 · g1 (u),
N (x, y) = x2 · g2 (u)

• Now we can apply the substitution and solve the DE


!
y y2
2 dx + 1 + 2 dy = 0
x x
2
2u dx + (1 + u )(du x + u dx) = 0
2u dx + u dx + dx x + u2 x du + u3 dx = 0
dx(3u + u3 ) + du x(1 + u2 ) = 0
1 1 + u2
dx + du = 0 (1.28)
x 3u + u3

10
• Integrating throughout one gets

1
log |x| + log u3 + 3u = C
3

1
log |x| = − log u3 + 3u + C
3

C
x=
(u3
+ 3u)1/3
x u + x3 · 3u = C
3 3

!3 !
y y
x3 + x3 · =C
x x

• Simplifying leads to

y 3 + 3x2 y = C.

dy
Example 1.7. Solve x2 − xy = y 2
dx
Solution 1.7. • Rewriting the equation we have

x2 dy − xydx = y 2 dx
x!2 dy = (y 2 + xy)dx
!
x2 x
y2 2
dy = y 2 1 + dx
y y

• We can observe that the system is homogeneous of degree 2 and the appropriate
substitution is u = x/y ⇒ x = uy ⇒ dx = du y + u dy

• It follows that

u2 dy = (1 + u)dx
u2 dy = (1 + u)(du y + u dy)
u2 dy = du y + u dy + u du y + u2 dy
−udy = du(y + uy)
−udy = du y(1 + u)
1 (1 + u)
− dy = du
y u
− log(y) = log(u) + u + C

11
• Substituting u = x/y one gets
!
x x
log + log(y) = − + C
y y
x
log(x) = − + C
y

x
• Finally we have y = .
C − log(x)

1.7 Bernoulli’s differential equations


• Let us consider the DE

dy
+ p(x)y = f (x) · y n . (1.29)
dx

• Such De reminds us of linear DE except the member y n .

• For n = 1, Equation (1.29) is solvable by separating variables.

• For other n it can be transformed into linear DE by means of substitution

u = y 1−n (1.30)

• If we multiply Equation (1.29) by

(1 − n)y −n (1.31)

then the problematic member y n on the right side will be cancelled.

• Hint Note that the relationship between u = y 1−n and (1 − n)y −n , is by differen-
tiating u with respect to y.

• Multiply Equation (1.29) by (1 − n)y −n leads to

dy
(1 − n)y −n + (1 − n)y −n p(x)y = (1 − n)y −n f (x) · y n
dx
d 1−n
y + (1 − n)y −n p(x)y = (1 − n)f (x)
dx
d
u + (1 − n)y −n p(x)y = (1 − n)f (x). (1.32)
dx

12
Example 1.8. Solve the DE y 0 + xy = xy −3 , y 6= 0.

Solution 1.8. • We have to multiply the DE by y 3 to eliminate y −3 on the right


side.

• Applying the above discussed procedure we have u = y 1−n = y 1−(−3) = y 4 .

• Now let us multiply both sides of DE by u0 = 4y 3

dy
4y 3 + 4y 4 x = 4x
dx
du
+ 4xu = 4x (1.33)
dx

• Clearly we have transformed the problem into a linear DE with the integrating
2
R
4xdx
factor e = e2x

• Thus we have

2 du 2 2
e2x + 4xue2x = 4xe2x
dx Z
d 2x2 2
(ue ) = e2x 4xdx
dx
2 2
ue2x = e2x + C
2
u = 1 + Ce−2x (1.34)

• Substituting for u = y 4 we have

2
y 4 = 1 + Ce−2x . (1.35)

1.8 Modelling with first order differential equations


1. If 1.7% of a substance decomposes in 50 years. (i) What percentage of the sub-
stance will remain after 100 years? (ii) How many years will be required for 10%
to decompose?

Solution 1.9. • Let A(t) be the amount of the substance at time t (in per-
centage), such that at t = 0, we have A(0) = 100. and at t = 50 we have
A(50) = 98.3

13
• Since the amount of the substance decreases with time we have the relation

dA
= −kA (1.36)
dt

where k is a constant.

• Solving (1.36) leads to A(t) = e−kt+c

• Using the initial conditions we have



A(0) = 100 ⇒ 100 = e−k·0+c ⇒ c = 4.6052 
(1.37)
A(50) = 98.3 ⇒ 98.3e−50k+4.6052 ⇒ 3.435 × 10−4 . 

−4 t+4.6052
• Thus, the particular solution is A(t) = e−3.435·10 .

• Using the particular solution we have (i) 96.6% (ii) t = 307 years.

2. A body whose temperature is 180◦ C is immersed into liquid which is kept at a


constant temperature of 60◦ C. In one minute the temperature of the body decreases
to 120◦ C. How long will it take for the body to decrease to 90◦ C?

Solution 1.10. • Let TB be the temperature of the body and TM be the temper-
ature of the medium.

• Then the rate of change temperature of the body can be modelled as follows

dTB
= −k(TB − TM ), (1.38)
dt

where k is a constant.

• Solving (1.38) leads to TB = TM + e−kt+c .

• Using the initial conditions we can solve for k and c



TB (0) = 180◦ C ⇒ c = 4.787 
(1.39)
TB (1) = 120◦ C ⇒ k = 0.693. 

• Thus we have TB = TM + e−0.693t+4.787 and from this function we can find the
time it takes for the body temperature to decrease to 90◦ C (ANS 2 minutes).

14
Tutorial 1.1. Attempt all questions

1. Find the solution of the equation A0 (t) + A(t) − 1 = 0 which satisfies the condition
A(0) = 0.
dv
2. Solve the equation m = −kv − mg with initial condition v(0) = 0 when k = 0.1
dt
and m = 1. (Recall that g = 9.8 meters per second per second.)

3. Let P(t) be the population size for a bacteria colony at time t. The logistic model
is that
dP
= kP (M − P ),
dt
where k > 0 and M > 0 are constants. Solve this equation when k = 1 and
M = 1000 with P (0) = 100.
dy
4. 3y + ex + (3x + cos y) =0
dx
dA
5. Solve the equation = A + 1 with the initial condition A(0) = 5.
dt
dA
6. Solve the equation = A2 + 1 with the initial condition A(0) = 1.
dt
7. Newton’s Law of Cooling states that the rate of change of temperature of a body
submersed in a bath is proportional to the difference of temperature between the
body and the bath. If a kettle of 100 degree water cools to a temperature of 80
degrees in 30 minutes when placed in a room of constant temperature 25, what is
the proportionality constant? How long will it take for the kettle to reach room
temperature?

8. Show that the differential equation


dy tan y − y − 2xy
=
dx sec y − x tan2 y + x2 + 2
2

is an exact equation and solve it.

9. Solve the differential equation



= −a sin θ − bψ

subject to the condition that ψ = 0 when θ = π3 .

15
Chapter 2

Second Order Differential Equations

2.1 Introduction
• The general form of a second-order ODEs is

ay 00 + by 0 + cy = f (x), (2.1)

where the coefficients a, b and c are constants. If f (x) = 0, then equation (2.1) is
called a Homogenous equation otherwise it an Inhomogenous equation.

2.2 Homogeneous second-order differential equations


• A homogeneous second-order differential equation has the form

ay 00 + by 0 + cy = 0. (2.2)

• The solution of Equation ( 2.2) entails finding two linearly independent solutions,
multiply each by a constant and then add them.

• Because of the differential properties of exponential functions let us suppose that


solution of (2.2) has the form y = emx , where m is a constant.

• If y = emx is a solution of (2.2) we have y 0 = memx and y 00 = m2 emx , giving

am2 emx + bmemx + cemx = 0


am2 + bm + c = 0, since emx 6= 0. (2.3)

16
• Th quadratic equation (2.3) is called the auxiliary equation or the characteristic
equation of Equation (2.2) and has the same coefficients as Equation (2.2).

• To complete the solution of such second order differential equations we need to


solve the quadratic equations (2.3).

• Solving (2.3) using the quadratic formula leads to



−b ± b2 − 4ac
m1,2 = . (2.4)
2a

• One can observe that there are 3 possible outcomes based on the output of the
discriminant b2 − 4ac,

b2 − 4ac > 0, (ii) b2 − 4ac < 0, (iii) b2 − 4ac = 0.

1. If b2 − 4ac > 0, the auxiliary equation has two distinct real roots m1 and m2
giving solutions em1 x and em2 x , such that the general solution of (2.2) is

y = Aem1 x + Bem2 x , (2.5)

where A and B are constants.

2. If b2 − 4ac < 0, the auxiliary equation has complex conjuaget roots α ± iβ


giving the solution e(α+iβ)x and e(α−iβ)x . Thus the general solution of (2.2) is

y = eαx (A1 eiβx + B1 e−iβx )


= eαx (A cos βx + B sin βx) (2.6)

where A and B are constants


−b
3. If b2 − 4ac = 0, the auxiliary equation has two equal real roots m1 = m2 = 2a.

general solution of (2.2) is

y = (Ax + B)em1 x (2.7)

Example 2.1. Determine the general solution of the ODE: y 00 + 5y 0 + 6y = 0.

Solution 2.1. – The auxiliary equation for the given ODE has the form

m2 + 5m + 6 = (m + 2)(m + 3) = 0. (2.8)

17
– Thus the general solutions is y(x) = Ae−2x + Be−3x .

Example 2.2. Determine the general solution of the IVP:

y 00 + 11y 0 + 24y = 0, y(0) = 0, y 0 (0) = −7 (2.9)

Solution 2.2. – The auxiliary equation is equivalent to

m2 + 11y 0 + 24y = (m + 8)(m + 3) = 0. (2.10)

– Thus the general solutions is y(x) = Ae−8x + Be−3x .

– From the initial conditions we have



y(0) = 0 ⇒ 0 = A + B, 
(2.11)
y 0 (0) = −7 ⇒ −7 = −8A − 3B. 

7
– Solving Equation (2.11) leads to A = 5
and B = − 57 .

– Thus the solution is y(x) = 57 (e−8x − e−3x ) = 75 e−8x (1 − e5x ).

Exercise 2.1. Solve the following initial value problems

1. y 00 + 3y 0 − 10y = 0 y(0) = 4, y 0 (0) = 2.

2. 3y 00 + 2y 0 − 8y = 0 y(0) = −6, y 0 (0) = −18.

3. 4y 00 − 5y 0 = 0 y(−2) = 0, y 0 (2) = 7.

2.3 Nonhomogeneous second-order differential equa-


tions
• From Equation (2.1) recall that an nonhomogeneous second-order differential equa-
tion has the form

ay 00 + by 0 + cy = f (x). (2.12)

• The solution of Equation (2.12) constitute two parts (i) the complementary func-
tion yc and the particular solution yp , that is y(x) = yc + yp .

• the complementary solution is obtained by setting f (x) = 0, (homogeneous)

18
• The particular solution is obtained by various methods outlined below depending
on the type of the function f (x).

• Case 1: f (x) a polynomial

Example 2.3. Determine the general solution of the ODE:

y 00 + 5y 0 + 6y = 12x + 4. (2.13)

Solution 2.3. – We have already observe that the complementary function is


yc = Ae−2x + Be−3x .

– To determine yp , we can ask ourselves: what function when differentiated


twice and substituted into the left-handside y 00 + 5y 0 + 6y will yield the right-
hand side 12x + 4?

– An obvious candidate function y(x) = ax + b, where a and b are constants.

– Now, y 0 = a, and y 00 = 0, substituting into (2.13) leads to

0 + 5a + 6(ax + b) ≡ 12x + 4
6ax + (5a + 6b) ≡ 12x + 4. (2.14)

– Equating the coefficients we have 6a = 12 and 5a + 6b = 4, leading to a = 2


and b = −1.

– Thus, yp = 2x − 1 and it follows that y(x) = Ae−2x + Be−3x + 2x − 1.

Remark 2.1. Determine the solution of the IVP

y 00 + 3y 0 = 6x, y(0) = 0, y 0 (0) = (0). (2.15)

Solution 2.4. – The auxiliary equation m2 + 3m = m(m + 3) = 0 has roots


m1 = 0 and m2 = −3 leading to yc (x) = A + Be−3x .

– To determine the particular solution one may be tempted to use a linear func-
tion y(x) = Ax + b???

– Observe that with a linear function y 0 = A and y 00 = 0, substituting these into


the ODE leads to

3A ≡ 6x (2.16)

19
– Clearly we can observe that this does not work? Hence, in this case a quadratic
function is appropriate.

– Let us consider y = ax+ bx + c, such that y 0 = 2ax + b and y 00 = 2a giving

2a + 3(2ax + b) ≡ 6x
6ax + (2a + 3b) ≡ 6x (2.17)

– Solving gives a = 1 and b = − 23 .

– Since c cannot be determined we can take c = 0 so that yp = x2 − 23 x.

– However, for this ODE any constant value of c can also work??

– Thus the general solution y = A + Be−3x + x2 − 23 x.

– From the initial conditions we have



y(0) = 0 ⇒ 0 = A + B, 
(2.18)
y 0 (0) = 0 ⇒ 0 = −3B − 32 . 

– Solving gives B = −2/9 and A = 2/9.

– Thus, y = 92 (1 − e−3x ) + x2 − 32 x.

• Case 2: f (x) an exponential

Example 2.4. Determine the solution of the differential equation y 00 + 5y 0 + 6y =


12e2x .

Solution 2.5. – As we have observed earlier the complementary function is


yc = Ae−2x + Be−3x .

– For a particular solution we consider y = ae2x such that y 0 = 2ae2x , and


y 00 = 4ae2x .

– Substituting leads to

20ae2x ≡ 12e2 x, ⇒ 20a = 12, ⇒ a = 3/5. (2.19)

– Thus, yp = 53 e2x .

– Therefore y = Ae−2x + Be−3x + 35 e2x .

20
Remark 2.2. – Determine the solution of the differential equation y 00 + 5y 0 +
6y = 12e−2x .

– As we have observed earlier the complementary function is yc = Ae−2x +


Be−3x .

– However, here one needs to carefully choose the particular function.

– If we choose y = ae−2x it will not work because the general solution has this
component already, therefore a more suitable function is y = axe−2x .

• Case 3: f (x) = a cos cx + b sin cx

Example 2.5. Determine the solution of the differential equation

y 00 + 5y 0 + 6y = 26 cos 2x.

Solution 2.6. – As we have observed earlier the complementary function is


yc = Ae−2x + Be−3x .

– For the particular function we now consider y = a cos 2x + b sin 2x.

– y 0 = −2a sin 2x + 2b cos 2x and y 00 = −4a cos 2x − 4b sin 2x.

– Substituting gives

(−4a cos 2x − 4b sin 2x) + 5(−2a sin 2x + 2b cos 2x) + 6(cos 2x + b sin 2x) ≡ 26 cos 2x.

– Equating coefficients leads to



2a + 10b = 26, 
(2.20)
−10a + 2b = 0 

– Solving gives a = 1/2 and b = 5/2.

– Thus y = Ae−2x + Be−3x + 21 (cos 2x + 5 sin 2x).

• Case 4: f (x) = g(x)emx

– Differential equations such as y 00 +5y 0 +6y = xemx and y 00 +5y 0 +6y = emx sin 3x
can be reduce to cases previously considered by putting y = v(x)emx (i.e.
reformulating the differential equation in terms of a new dependent variable
v) which effectively removes the exponential.

21
Example 2.6. Determine the solution of the differential equation

y 00 − y 0 − 2y = 4e2x sin x. (2.21)

Solution 2.7. – The auxiliary equation is m2 − m − 2 = (m + 1)(m − 2) = 0 ⇒


m = −1, 2.

– To obtain the particular integral we consider y = ve2x so that y = (v 0 + 2v)e2x


and y 00 = (v 00 + 4v 0 + 4v)e2x .

– Substituting into the differential equation (2.21) leads to

v 00 + 3v = 4 sin x. (2.22)

– To determine the particular integral for this equation (2.22) we consider v =


a sin x + b cos x such that v 0 = a cos x − b sin x and v 00 = −a sin x − b cos x so
that

−(a + 3b) sin x − (b − 3a) cos x ≡ 4 sin x

– Thus, a + 3b = −4 and 3a − b = 0, solving gives a = −2/5 and b = −6/5.

– Thus, yp = − 51 (2 sin x + 6 cos x)e2x .

– Therefore the general solution of equation (2.22) is


1
y = Ae−x + Be2x − (2 sin x + 6 cos x)e2x .
5

• Case 5: f (x) is a sum of functions considered in the previous cases.

– It can easily be shown that if y = y1 is a particular integral of the differential


equation ay 00 + by 0 + cy = f1 (x) and y = y2 is a particular integral of the
differential equation ay 00 + by 0 + cy = f2 (x), then y = y1 + y2 is a particular
integral of the differential equation ay 00 +by 0 +cy = f1 (x)+f2 (x). For example,
to find the particular integral for

y 00 − y 0 − 2y = 4 + 6ex + sin 2x, (2.23)

we firstly find the particular integrals for each of these equations

y 00 − y 0 − 2y = 4,

22
y 00 − y 0 − 2y = 6ex ,
y 00 − y 0 − 2y = sin 2x,

separately, and then the particular integral for Equation (2.23) is just the
sum of the three individual particular integrals.

Tutorial 2.1. Attempt All Questions

1. Solve the following initial value problems

(a) y 00 + 3y 0 − 10y = 0 y(0) = 4, y 0 (0) = 2.

(b) 3y 00 + 2y 0 − 8y = 0 y(0) = −6, y 0 (0) = −18.

(c) 4y 00 − 5y 0 = 0 y(−2) = 0, y 0 (2) = 7.

(d) y 00 − 8y 0 + 17y = 0, y(0) = −4, y 0 (0) = −1

(e) 4y 00 + 24y 0 + 37y = 0, y(π) = 1, y 0 (π) = 0

2. Solve the following DE

(a) y 00 − y 0 − 6y = 12x

(b) y 00 + 7y 0 + 12 = 4e2x

(c) y 00 − 2y 0 + 5y = 20 sin 2x

(d) y 00 + 4y = 20 sin 2x

3. Solve the following IVP

(a) y 00 − 2y 0 − 3y = 8e2x y(0) = y 0 (0) = 3.

(b) y 00 − 2y 0 + 5y = 20 sin 2x, y(π) = 1, y 0 (π) = 0

4. A body moves so that its position x(t) at time t is given by

x00 + 2µx0 + m2 x = a sin ωt, (2.24)

where a, µ, m and ω are constants. Determine the general solution if

(a) µ < m,

(b) µ = m,

(c) µ > m.

23
Chapter 3

Laplace transform

3.1 Introduction
The Laplace Transform was first used by and named after Pierre Simon Laplace1 , French
mathematician and astronomer. Basically, a Laplace transform will convert a function
in some domain into a function in another domain, without changing the value of the
function. For example, let’s take this function where a Laplace transform is used to
convert a function of time to a function of frequency. Laplace transforms are invaluable
for any engineer’s mathematical toolbox as they make solving linear ODEs and related
initial value problems, as well as systems of linear ODEs, much easier. Applications
abound : electrical networks, springs, mixing problems, signal processing, and other
areas of engineering and physics.

3.1.1 Why Do We Use Laplace Transform?


We use Laplace transform to convert equations having complex differential equations
to relatively simple equations having polynomials. Since equations having polynomials
are easier to solve, we employ Laplace transform to make calculations easier. A simple
Laplace Transform is conducted while sending signals over any two-way communication
1
PIERRE SIMON MARQUIS DE LAPLACE (1749-1827), great French mathematician, was a pro-
fessor in Paris. He developed the foundation of potential theory and made important contributions to
celestial mechanics, astronomy in general, special functions, and probability theory. Napoleon Bona-
parte was his student for a year.

24
medium (FM/AM stereo, 2-way radio sets, cellular phones). When information is sent
over medium such as cellular phones, they are first converted into time-varying wave,
and then it is super-imposed on the medium. In this way, the information propagates.
Now, at the receiving end, to decipher the information being sent, medium waves time
functions are converted to frequency functions. This is a simple real life application of
Laplace Transform.

3.1.2 Laplace Transform


Definition 3.1. Let f be a function defined for t ≥ 0. Then the integral
Z ∞
L {f (t)} = e−st f (t) dt (3.1)
0

is said to be the Laplace transform of f provided the integral converges.

When the defining integral (3.1) converges, the result is a function of s. We shall use
lowercase letter to denote the function being transformed and the corresponding capital
letter to denote its Laplace transform, for example

L {f (t)} = F (s), L {g(t)} = G(s), L {y(t)} = Y (s).

Original functions depend on x and their transforms on s –keep this in mind!


The Laplace transform is called an integral transform because it transforms (changes)
a function in one space to a function in another space by a process of integration that
involves a kernel. The kernel or kernel function is a function of the variables in the two
spaces and defines the integral transform.

Example 3.1. Evaluate L {1}.


Solution:
Z ∞ Z b
L {1} = st
e (1)dt = lim e−st dt
0 b→∞ 0
b
−e−st −e−sb + 1 1
= lim = lim =
b→∞ s 0 b→∞ s s

provided s > 0. In other words, when s > 0, the exponent −sb is negative and e−sb → 0
as b → ∞. When s < 0, the integral is divergent.

25
3.2 L is a Linear Transform
For a sum of functions we can write
Z ∞ Z ∞ Z ∞
−st −st
e [αf (t) + βg(t)]dt = α e f (t)dt + β e−st g(t)dt,
0 0 0

whenever both integrals converge. Hence, it follows that

L {αf (t) + βg(t)} = αL {f (t)} + βL {g(t)} = αF (s) + βG(s).

Because of this property, L is said to be a linear transform.

Example 3.2. Evaluate L {e−3 }.


Solution: From the definition, we have
Z ∞ Z ∞
L {e } =
−3t −st −3t
e e dt = e−(s+3)t dt
0 0
−(s+3)t ∞
−(e )
=
s+3 0
1
= , s > −3.
s+3
Example 3.3. Evaluate L {f (t)} for

 0, 0≤t<3
f (t) =
 2, t ≥ 3,

Solution: This piece-wise continuous function. Since f is defined in two pieces, L {f (t)}
is expressed as the sum of two integrals
Z ∞
L {f (t)} = e−st f (t)dt
Z0 3 Z ∞
−st
= e (0)dt + e−st (2)dt
0 3

2e−st
= −
s 3
2e−3s
= , s > 0.
s

3.3 Transforms of Some Basic Functions


1
• L {1} = .
s
26
n!
• L {tn } = , n = 1, 2, 3, . . .
sn+1
1
• L {eat } = .
s−a
k
• L {sin kt} = .
+ k2 s2
s
• L {cos kt} = 2 .
s + k2
k
• L {sinh kt} = .
s2 − k 2
s
• L {cosh kt} = 2 .
s − k2

3.4 Inverse Transform


In the proceeding section, we were concerned with the problem of transforming a function
f (t) into another function F (s). We now turn to the problem around, namely, given
F (s), find the function f (t) corresponding to this transform. We say f (t) is the inverse
Laplace transform of F (s) and write

f (t) = L −1 {F (s)}.

3.4.1 Some Inverse Transforms


 
1
• 1=L −1
.
s
 
n!
• t =L
n −1
, n = 1, 2, 3, . . .
sn+1
 
1
• e =L
at −1
.
s−a
 
k
• sin kt = L −1
.
s2 + k 2

3.4.2 L −1 is a Linear Transform


We assume that the inverse Laplace transform is itself a linear transform, that is, for
constants α and β,

L −1 {αF (s) + βG(s)} = αL −1 {F (s)} + βL −1 {G(s)}

27
where F and G are the transforms of some functions f and g.
 
1
Example 3.4. Evaluate L −1
.
s5
Solution: It follows    
1 1 −1 4! 1
L −1
5
= L 5
= t4 .
s 4! s 24
 
3s + 5
Example 3.5. Evaluate L −1 .
s2 + 7
Solution: The given function of s can be written as two expressions by means of term-
wise division
3s + 5 3s 5
2
= 2 + 2 .
s +7 s +7 s +7
From the linearity property of the inverse Laplace transform, we then have
    ( √ )
3s + 5 s 5 7
L −1 2
= 3L −1 2
+ √ L −1 2
s +7 s +7 7 s +7
√ 5 √
= 3 cos 7t + √ sin 7t.
7

3.4.3 Partial Fractions


Partial fractions play an important role in finding inverse Laplace transforms.
 
s+1
Example 3.6. Evaluate L −1
.
s2 (s + 2)3
Solution: Assume

s+1 A B C D E
= + 2+ + +
s2 (s
+ 2) 3 s s s + 2 (s + 2) 2 s + 2)3
1 1 1 1
so that A = − , B = , C = , D = 0 and E = − . Hence
16 8 16 4
   
s+1 1/16 1/8 1/16 1/4
L −1
= L −1
− + 2 + −
s2 (s + 2)3 s s s + 2 (s + 2)3
     
1 −1 1 1 −1 1 1 −1 1 1 −1 2
= − L + L + L { }− L
16 s 8 s2 16 s+2 8 (s + 2)3
1 1 1 1
= − + t + e−2t − t2 e−2t .
16 8 16 8
 
3s − 2
Example 3.7. Evaluate L −1
.
s3 (s2 + 4)

28
3.5 Translation Theorems and Derivatives of a Trans-
form
Definition 3.2 (First Translation Theorem). If F (s) = L {f (t)} and a is any real
number, then
L {eat f (t)} = F (s − a).

Example 3.8. Evaluate (a) L {e5t t3 } (b) L {e−2t cos 4t}.


3! 6
Solution: (a) L {e5t t3 } = L {t3 }s→s−5 = 4 = .
s s→s−5 (s − 5)4
s s+2
(b) L {e−2t cos 4t} = L {cos 4t}s→s+2 = 2 = .
s + 16 s→s+2 (s + 2)2 + 16

3.5.1 Inverse Form of the First Translation Theorem


If f (t) = L −1 {F (s)}, then

L −1 {F (s − a)} = L −1 {F (s)|s→s−a } = eat f (t).


 
s
Example 3.9. Evaluate L −1
.
s2 + 6s + 11
Solution: If s2 + 6s + 11 had real factors, we would use partial fractions. Since this
quadratic term does not factor, we complete the square.
   
s s
L −1
= L −1
s2 + 6s + 11 (s + 3)2 + 2
 
s+3−3
= L −1
(s + 3)2 + 2
 
s+3 3
= L −1

(s + 3)2 + 2 (s + 3)2 + 2
   
s+3 1
= L −1
− 3L −1
(s + 3)2 + 2 (s + 3)2 + 2
  ( √ )
s 3 2
= L −1 − √ L −1
s2 + 2 s→s+3 2 s2 + 2 s→s+3
√ 3 √
= e−3t cos 2t − √ e−3t sin 2t.
2
 
1 1
Example 3.10. Evaluate L −1
+ .
(s − 1)3 s2 + 2s − 8

29
3.6 Transforms of Derivatives, Integrals and Peri-
odic Functions
Our goal is to use the Laplace transform to solve certain  kinds of differential
 2 equa-
dy dy
tions. To that end we need to evaluate quantities such as L and L . For
dt dt2
example, if f 0 is continuous for t ≥ 0, then integration by parts gives
Z ∞ ∞ Z ∞
L {f (t)} =
0 −st 0 −st
e f (t)dt = e f (t) +s e−st f (t)dt
0 0 0
= −f (0) + sL {f (t)},

or
L {f 0 (t)} = sF (s) − f (0).

Similarly
Z ∞ ∞ Z ∞
L {f (t)} =
00 −st 00
e f (t)dt = e −st 0
f (t) +s e−st f 0 (t)dt
0 0 0
0 0
= −f (0) + sL {f (t)}

= s[sF (s) − f (0)] − f 0 (0)

or
L {f 00 (t)} = s2 F (s) − sf (0) − f 0 (0).

Theorem 3.1. If f (t), f 0 (t), . . . , f n−1 (t) are continuous, then

L {f (n) } = sn F (s) − sn−1 f (0) − sn−2 f 0 (0) − · · · − f (n−1) ,

where F (s) = L {f (t)}.

3.7 Applications
Since L {y (n) (t)}, n > 1, depends on y(t) and its n − 1 derivatives evaluated at t = 0,
the Laplace transform is ideally suited to initial valued problems for linear differential
equations with constant coefficients. This kind of differential equation can be reduced
dto an algebraic equation in the transformed function Y (s). To see this, consider the
initial value problem
dn y dn−1 y dy
an n
+ a n−1 n−1
+ · · · + a1 + a0 y = g(t)
dt dt dt
0 (n−1)
y(0) = y0 , y (0) = y1 , . . . , y (0) = yn−1 ,

30
where ai , i = 0, 1, 2, . . . , n and y0 , y1 , . . . , yn−1 are constants. By the linearity property
of the Laplace transform, we can write
 n   n−1 
d y d y
an L n
+ an−1 L + · · · + a0 L {y} = L {g(t)}.
dt dtn−1

Therefore

an [sn Y (s) − sn−1 y(0) − · · · − y (n−1) (0)] + an−1 [sn−1 Y (s) − sn−2 y(0) − · · · y (n−2) (0)]
+ · · · + a0 Y (s) = G(s)

where Y (s) = L {y(t)} and G(s) = {g(t)}. By solving for Y (s), we find y(t) by deter-
mining the inverse transform
y(t) = L −1 {Y (s)}.
dy
Example 3.11. Solve − 3y = e2t , y(0) = 1.
dt
Solution: We first take the transform of each member of the given differential equation,
 
dy
L − 3L {y} = L {e2t }.
dt
 
dy 1
We then use L = sY (s) − y(0) = sY (s) − 1 and L {e2t } = . Solving
dt s−2
1
sY (s) − 1 − 3Y (s) =
s−2

for Y (s) and carrying out partial fraction decomposition, give

s−1 −1 2
Y (s) = = + ,
(s − 2)(s − 3) s−2 s−3

and so    
−1 1 −1 1
y(t) = −L + 2L
s−2 s−3
. Then it follows that
y(t) = −e2t + 2e3t .

Example 3.12. Solve y 00 − 6y 0 + 9y = t2 e3t , y(0) = 2, y 0 (0) = 6.


Solution: L {y 00 } − 6L {y 0 } + 9{y} = L {t2 e3t }

2
s2 Y (s) − sy(0) − y 0 (0) − 6[sY (s) − y(0)] + 9Y (s) = .
(s − 3)3

31
Using the initial conditions and simplifying, give

2
(s2 − 6s + 9)Y (s) = 2s − 6 +
(s − 3)3
2
(s − 3)2 Y (s) = 2(s − 3) +
(s − 3)3
2 2
Y (s) = +
s − 3 (s − 3)5

Thus    
1 2 4!
y(t) = 2L −1
+ L −1 .
s−3 4! (s − 3)5
Recall from the first translation theorem that
( )
4
L −1 = t4 e3t .
s5
s→s−3

Hence, we have
1 4 3t
y(t) = 2e3t + te .
12
Example 3.13. Solve y 00 + 4y 0 + 6y = 1 + e−t , y(0) = 0, y 0 (0) = 0.
Solution: L {y 00 } + 4L {y 0 } + 6L {y} = L {1} + L {e−t }.

1 1
s2 Y (s) − sy(0) − y 0 (0) + 4[sY (s) − y(0)] + 6Y (s) = +
s s+1
2s + 1
(s2 + 4s + 6)Y (s) =
s(s + 1)
2s + 1
Y (s) = .
s(s + 1)(s2 + 4s + 6)

The partial fraction decomposition for Y (s) is

1/6 1/3 −s/2 − 5/3


Y (s) = + + 2 .
s s+1 s + 4s + 6

In preparation for taking the inverse transform, we fix up Y (s) in the following manner,

1/6 1/3 (−1/2)(s + 2) − 2/3 1/6 1/3 1 s+2 2 1


Y (s) = + + 2
= + − − .
s s+1 (s + 2) + 2 s s + 1 2 (s + 2) + 2 3 (s + 2)2 + 2
2

Finally, we obtain
      ( √ )
1 −1 1 1 −1 1 1 −1 s+2 2 2
y(t) = L = L − L − √ L −1
6 s 3 s+1 2 (s + 2)2 + 2 3 2 (s + 2)2 + 2

1 1 −t 1 −2t √ 2 √
= + e − e cos 2t − sin 2t.
6 3 2 3
32
Tutorial 3.1. 1. Find L {f (t)}.
(i) f (t) = et+7 (ii) f (t) = t2 e3t (iii) f (t) = e−2t−5 (iv) f (t) = t cos t (v)
f (t) = te4t .

2. Find the inverse Laplace of the given transform.


1 4s s−1 1 s2 + 1
(i) 3 (ii) 2 (iii) 2 (iv) 2 (v)
s 4s + 1 s +2 s + s − 20 s(s − 1)(s + 1)(s − 2)
6s + 3 1 4 6 1
(vi) 2 (vii) 2 2 (viii) + 5 − .
(s + 1)(s2 + 4) s (s + 4) s s s+8
3. Find the inverse Laplace of the given transform.
1 1 s 2s − 1 5s
(i) 2 (ii) 4
(iii) (iv) (v) .
s − 6s + 10 (s − 1) (s + 1)2 s2 (s+ 1)3 (s − 2)2
4. Suppose a function y(t) has the properties that y(0) = 2 and y 0 (0) = 3. Solve for
the Laplace transform.
(i) y 00 − 2y 0 + y = 0 (ii) y 00 + y = 1.

5. Use the Laplace transform to solve the given differential equation subject to the
indicated initial conditions.
(i) y 00 − 2y 0 = et sinh t, y(0) = 0, y 0 (0) = 0 (ii) y 00 − y 0 = et cos t, y(0) = 0, y 0 (0) =
0
(iii) y 00 +16y = 1, y(0) = 1, y 0 (0) = 2 (iv) y 00 −4y 0 +4y = t3 e2t , y(0) = 0, y 0 (0) = 0
(v) y 00 − 2y 0 + 5y = 1 + t, y(0) = 0, y 0 (0) = 4 (vi) y 00 − 6y 0 + 9y = t, y(0) =
0, y 0 (0) = 1

33
Chapter 4

Numerical solutions of ordinary


differential equations

4.1 Introduction
The analytical methods of solving differential equations are applicable to a limited class
of equations. Quite often, differential equations modelling real world problems, do not
belong to any of these familiar types and as such one is obliged to resort to numerical
methods for a solution.

4.2 Taylor series method


• Consider an initial value problem (IVP)
dy
= f (x, y), y(a) = y0 , x ∈ [a, b]. (4.1)
dx

• We seek to find a solution of equation (4.1) by some numerical methods.

• If we subdivide the interval [a, b] into n subintervals and select mesh points, we
have

xk+1 = xk + h, k = 0, 1, 2, · · · , n − 1

where
b−a
h= , x0 = a, and xn = b.
n
34
• Using Taylor’s theorem, we have

y(xk+1 ) = y(xk + h)
1 2 00 1
= y(xk ) + hy 0 (xk ) + h y (xk ) + · · · + hn y (n) (xk ) + · · · (4.2)
2! n!

• If the step size h is chosen small enough, we may neglect higher order terms of
(4.2), that is,

y(xk+1 ) = y(xk + h)
1 2 00 1
= y(xk ) + hy 0 (xk ) + h y (xk ) + · · · + hn y (n) (xk ) (4.3)
2! n!

• Equation (4.3) is called the Taylor’s formula of order n and it can be used to
compute the numerical solution of the IVP (4.1).

• In equation (4.3), the error is of the order O(hn+1 ).

Example 4.1. Use Taylor’s method of order 2 to solve the following initial value problem

y 0 = y + ex , y(0) = 1, x ∈ [0, 0.003], h = 0.001.

Solution 4.1. • Taylor’s method of order 2 is given by


h2 00
yk+1 = y(xk ) + hy 0 (xk ) + y (xk ).
2

• We know that

y 0 (xk ) = y(xk ) + exk .


y 00 (xk ) = y 0 (xk ) + exk
= [y(xk ) + exk ] + exk
= y(xk ) + 2exk .

• Thus,
1
y(xk+1 ) = y(xk ) + hy[y(xk ) + exk ] + h2 [y(xk ) + 2exk ]
2
 
1 2
= 1 + h + h yk + (h + h2 )exk .
2

35
• For k = 0 we have
 
1
y1 = 1 + 0.001 + (0.001) y0 + (0.001 + (0.001)2 )ex0
2
2
= 1.0010005y0 + 0.001001ex0
= 1.001(1) + 0.001001(1)
= 1.0020015.

• For k = 1 we have

y2 = 1.001y1 + 0.001001ex1
= 1.0010005(1.0020015) + 0.001001e0.001
= 1.004006004001417.

• For k = 2 we have

y3 = 1.0010005y1 + 0.001001ex1
= 1.0060135160117556.

• We can easily show that the analytical solution is

y(x) = ex (1 + x).

• Thus, the error is given by

x Estimate Exact Error


0.001 1.0020015 1.00200150066875 6.66875 × 10−10
0.002 1.004006004001417 1.0040060053366684 1.33525 × 10−9
0.003 1.0060135160117556 1.0060135180168872 2.00513 × 10−9

4.3 Euler’s method


• The Taylor’s method of order 1 is known as the Euler’s method, that is

y(xk + h) = y(xk ) + hy 0 (xk ) (4.4)

36
• Recall that y 0 (x) = f (x, y), thus (4.4) becomes

y(xk + h) = y(xk ) + hf (xk , yk ).

Example 4.2. Use Euler’s method to solve the following initial value problem

y 0 = y + ex , y(0) = 1, x ∈ [0, 0.003], h = 0.001.

Solution 4.2. • f (xk , yk ) = yx + exk so the Euler’s method is

yk+1 = yk + h(yk + exk )


= hexk + (1 + h)yk .

• Thus

x Estimate Exact Error


0.001 1.001 1.00200150066875 1.0015 × 10−3
0.002 1.0030020005001663 1.0040060053366684 1.0040 × 10−3
0.003 1.0050080070051697 1.0060135180168872 1.0055 × 10−3

4.4 Modified Euler’s method


• Consider the initial value problem y 0 = f (x, y), x ∈ [a, b] with y(a) = y0 and
y(b) = yn .

• If we subdivide the interval [a, b] into n subintervals of equal length h and set
b−a
h= , so that xk+1 = xk + h for k = 0, 1, 2, 3, · · · .
n
• Integrating y 0 = f (x, y) over [xk , xk+1 ] we get
Z xk+1 Z xk+1
0
y dx = f (x, y)dx
xk xk

h
y(xk+1 ) − y(xk ) = [f (xk , yk ) + f (xk+1 , yk+1 )]
2

h
= y(xk ) + [f (xk , yk ) + f (xk+1 , yk+1 )]. (4.5)
2

37
• Equation (4.5) is called the modified Euler’s method or the Euler-Cauchy’s method.

• It is also known as the predictor-corrector method.

Example 4.3. Use Euler-Cauchy’s method to solve the following initial value problem

y 0 = −2x − y, y(0) = −1, x ∈ [0, 0.2], h = 0.1.

Solution 4.3. • For k = 0 we have


h
y1 = y0 + [f (x0 , y0 ) + f (x1 , y1 )]
2

• We know that f (xk , yk ) = −2xk − yk so that

f (x0 , y0 ) = −2x0 − y0 ⇒ f (0, −1) = −2(0) − (−1) = 1

• Since we are not aware of y1 for to use on f (x1 , y1 ) we will first use Euler’s method
to find y1 , that is;

yk+1 = yk + hf (xk , yk )
y1 = y0 + hf (x0 , y0 )
= −1 + 0.1(1) = −0.9.

• Now

f (x1 , y1 ) = f (0.1, −0.9) = −2(0.1) − (−0.9) = 0.7

• Thus
0.1
y1 = −1 + [1 + 0.7] = −0.915.
2

• For k = 1 we have
h
y2 = y1 + [f (x1 , y1 ) + f (x2 , y2 )]
2

f (x1 , y1 ) = f (0.1, −0.915) = −2(0.1) − (−0.915) = 0.715


y2 = y1 + hf (x1 , y1 ) = −0.86 + 0.2[−2(0.2) − (−0.86)] = −0.8435.
f (x2 , y2 ) = f (0.2, −0.8435) = −2(0.2) − (−0.8435) = 0.4435.

38
• Thus
0.1
y2 = −0.915 + [0.715 + 0.4435] = −0.857075.
2

• It can easily be verified that the analytical solution is

y(x) = 2(1 − x) − 3e−x

• Thus

x Estimate Exact Error


0.1 -0.915 -0.9145122541078787 4.8774589 × 10−4
0.2 -0.857075 -0.8561922592339456 8.827407 × 10−4

4.5 Runge-Kutta methods

4.5.1 Runge-Kutta method of order 1


• The Taylor’s method of order 1 is also known as the Runge-kutta method of order
1 and is given by

yk+1 = yk + hf (xk , yk ).

4.5.2 Runge-Kutta method of order 2


• It is given by
1
yk+1 = yk + h[k1 + k2 ]
2
where

k1 = f (xk , yk )
k2 = f (xk+1 , yk+1 )
= f (xk + h, yk + hk1 ).

Remark: Here we observe that Runge-Kutta method of order 2 (RK-2) is similar


to the modfied Euler’s method.

39
4.5.3 Runge-Kutta method of order 3
• It is given by
h
yk+1 = yk + [k1 + 4k2 + k3 ]
6
where

k1 = f (x
 k , yk ) 
h h
k2 = f xk + , yk + k1
2 2
k3 = f (xk + h, yk − hk1 + 2hk2 ).

Example 4.4. Use Runge-Kutta’s method of order 3 (RK-3) to solve the following initial
value problem

y 0 = −2x − y, y(0) = 1, x ∈ [0, 0.2], h = 0.1.

Solution 4.4. • We have f (xk , yk ) = −2xk − yk so that

 0 , y0 ) = f (0, −1) 
k1 = f (x = −2(0) − (−1) = 1,
h h
k2 = f x0 + , y0 + k1 = f (0.05, −0.95) = −2(0.05) − (−0.95) = 0.85
2 2
k3 = f (x0 + h, y0 − hk1 + 2hk2 ) = f (0.1, −0.93) = −2(0.1) − (−0.93) = 0.73

• Thus

0.1
y1 = −1 + [1 + 4(0.85) + 0.73] = −0.9145.
6

• For k = 1

 1 , y1 ) = f (0.1, −0.9145)
k1 = f (x  = −2(0.1) − (−0.9145) = 0.7145,
h h
k2 = f x1 + , y1 + k1 = f (0.15, −0.878775) = −2(0.15) − (−0.878775) = 0.578775.
2 2
k3 = f (x1 + h, y1 − hk1 + 2hk2 ) = f (0.2, −0.870195) = −2(0.1) − (−0.93) = 0.470195

• Thus

0.1
y2 = −0.9145 + [0.7145 + 4(0.578775) + 0.470195] = −0.8561700833333333.
6
40
• Therefore

x Estimate Exact Error


0.1 -0.9145 -0.9145122541078787 1.225410 × 10−5
0.2 -0.8561700833333333 -0.8561922592339456 2.2175900 × 10−5

4.5.4 Runge-Kutta method of order 4 (RK-4)


• It is given by
h
yk+1 = yk + [k1 + 2k2 + 2k3 + k4 ]
6
where

k1 = f (x
 k , yk ) 
h h
k2 = f xk + , yk + k1
 2 2 
h h
k3 = f xk + , yk + k2
2 2
k4 = f (xk + h, yk + hk3 ).

Example 4.5. Use Runge-Kutta’s method of order 3 (RK-3) to solve the following initial
value problem

y 0 = −2x − y, y(0) = 1, x ∈ [0, 0.2], h = 0.1.

Solution 4.5. • We have f (xk , yk ) = −2xk − yk so that

 0 , y0 ) = f (0, −1) 
k1 = f (x = −2(0) − (−1) = 1,
h h
k2 = f x0 + , y0 + k1 = f (0.05, 0.95) = 0.85,
 2 2 
h h
k3 = f x0 + , y0 + k2 = f (0.05, −0.9575) = 0.8575,
2 2
k4 = f (x0 + h, y0 + hk3 ) = f (0.1, −0.91425) = 0.71425.

• Thus
0.1
y1 = −1 + [1 + 2(0.85) + 2(0.8575) + 0.71425] = −0.9145125.
6

• Therefore the error is 2.45892 × 10−7 .

41
4.6 Second order differential equations
• Majority of real life problems can be presented as a system of first order differential
equations, that is;

y10 = f1 (x, y1 , y2 , · · · , yp ),
y20 = f2 (x, y1 , y2 , · · · , yp ),
.. .
. = ..
yp0 = fp (x, y1 , y2 , · · · , yp ).

• If a real world problem is modeled as a single higher order differential equation,


it is possible for one to reduce the differential equation to a system of first order
differential equations.

Example 4.6. Reduce the second order equation

y 00 + 3y 0 + 2y = ex , y(0) − 1, y 0 (0) = 2

to a system of first order equations.

Solution 4.6. • Let u = y and v = y 0 so that u0 = y 0 = v and v 0 = y 00

• Thus

u0 = v u(0) = 1
v 0 = −2u − 3v + ex , v(0) = 2

• Once a higher-order system is reduced to a system of first-order equations, we can


then used numerical techniques discussed earlier in this chapter to obtain solutions.

Example 4.7. Consider the initial value problem

y 00 − y = x, x ∈ [0, 1], y(0) = 0, y 0 (0) = 1.

(i) Determine the analytical solution of the differential equation.

(ii) Reduce the above differential equation to a system of first order differential equa-
tions.

42
(iii) Use Euler’s method with h = 0.05 to estimate y(0.1).

(iv) Compute the error of y(0.1) and y 0 (0.1).

Solution 4.7. (i) It can easily be verified that the analytical solution is

y(x) = ex − e−x − x.

(ii) Let u = y and v = y 0 so that u0 = y 0 = v and v 0 = y 00

u0 = v, u(0) = 0
v 0 = u + x, v(0) = 1

(iii) Let f (xn , un , vn ) = vn and g(xn , un , vn ) = un + xn . Thus,

un+1 = un + hf (xn , un , vn )
vn+1 = vn + hg(xn , un , vn )

• For n = 0, we have

u1 = u0 + hf (x0 , u0 , v0 )
= 0 + 0.05f (0, 0, 1)
= 0.05
v1 = v0 + hg(x0 , u0 , v0 )
= 1 + 0.05g(0, 0, 1)
= 1

• For n = 1, we have

u2 = u1 + hf (x1 , u1 , v1 )
= 0.05 + 0.05f (0.05, 0.05, 1)
= 0.05 + 0.05(1) = 0.1
v2 = v1 + hg(x1 , u1 , v1 )
= 1 + 0.05g(0.05, 0.05, 1)
= 1 + 0.05(0.1)
= 1.005.

43
• The analytical solution is y(0.1) = 0.100334.

• Therefore the error is 0.0003335.

• Observe that y 0 (x) = ex + e−x − 1, so that y 0 (0.1) = 1.0100083361116072.

• Hence the error is 5.00834 × 10−3 .

Example 4.8. Consider the initial value problem

y 00 − y = x, x ∈ [0, 1], y(0) = 0, y 0 (0) = 1.

(i) Use RK-4 method with h = 0.05 to estimate y(0.1).

(ii) Compute the error of y(0.1) and y 0 (0.1).

Solution 4.8. • We need to reduce our differential equation to a system of first


order differential equations as done in the previous example. Thus,

u0 = v u(0) = 0
v 0 = u + x, v(0) = 1

• Let

f (xn , un , vn ) = vn
g(xn , un , vn ) = un + xn

• To apply the Rk-4 method we have

h
un+1 = un + [k1 + 2k2 + 2k3 + k4 ]
6

h
vn+1 = vn + [l1 + 2l2 + 2l3 + l4 ]
6

where

k1 = f (xn , un , vn ),

l1 = g(xn , un , vn ),

44
 
h h h
k2 = f xn + , un + k1 , vn + l1 ,
2 2 2
 
h h h
l2 = g xn + , un + k1 , vn + l1 ,
2 2 2
 
h h h
k3 = f xn + , un + k2 , vn + l2 ,
2 2 2
 
h h h
l3 = g xn + , un + k2 , vn + l2 ,
2 2 2

k4 = f (xn + h, un + hk3 , vn + hl3 ) ,

l4 = g (xn + h, un + hk3 , vn + hl3 ) .

• Now

k1 = f (x0 , u0 , v0 ) = f (0, 0, 1) = 1,
l1 = g(x0 , u0 , v0 ) = g(0, 0, 1) = u0 + x0 = 0.

k2 = f (0.025, 0.025, 1) = 1,
l2 = g(0.025, 0.025, 1) = 0.05.

k3 = f (0.025, 0.025, 1.00125) = 1.00125,


l3 = g(0.025, 0.025, 1.00125) = 0.05.

k4 = f (0.05, 0.0500625, 1.0025) = 1.0025,


l4 = g(0.05, 0.025, 1.0025) = 0.05 + 0.0500625 = 0.1000625

• Thus
0.05
u1 = 0 + [1 + 2(1) + 2(1.00125) + 1.0025] = 0.0500417.
6
45
0.05
v1 = 1 + [0 + 2(0.05) + 2(0.05) + 0.1000625] = 1.0025005208333333
6

• Recall that the exact solution is y(0.05) = e0.05 −e−0.05 −0.05 = 0.0500416718753101.

• Therefore the error is 5.20864 × 10−9 .

Tutorial 4.1. Attempt All Questions

1. Consider the initial value problem

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

(a) Determine the analytical solution of the differential equation.

(b) Use the modified Euler’s method to show that


yn (2 + hxn ) + h(2xn + h)
yn+1 ≈ .
2 − h(xn + h)

(c) Estimate the values for y when x = 2.1 and x = 2.2 with h = 0.1.

2. Consider the following IVP

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

(a) Determine the analytical solution of the IVP.

(b) Using the following methods to estimate y(0.2), consider a step size of 0.1

(i) Modified Euler’s method.


(ii) Taylor series of order 4.
(iii)Runge-Kutta fourth order method.

3. Consider the initial value problem

y 00 − 2y 0 − 3y = 8e3x , x ∈ [0, 1], y(0) = y 0 (0) = 3.

(i) Use RK-2 method with h = 0.1 to estimate y(0.2).

(ii) Compute the error of y(0.2) and y 0 (0.2).

END OF THE COURSE GOOD LUCK

46

You might also like