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

Math 23 Module 6

Uploaded by

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

Math 23 Module 6

Uploaded by

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

Advanced Mathematics

Module 6: Ordinary
Differential Equations

Prepared by:

ENGR. MICHAEL ERNIE F. RODRIGUEZ


Instructor, Department of Electrical Engineering
College of Engineering, Architecture and Technology
Palawan State University
Module 6
ORDINARY DIFFERENTIAL EQUATIONS

Overview
In this module, we will discuss the one-step methods for solving initial-value problems. One-step
methods permit the calculation of 𝑦𝑖+1 , given the differential equation and 𝑦𝑖 . The one-step methods
belong to what are called Runge-Kutta techniques. Although the module might have been organized
around this theoretical notion, we have opted for a more graphical, intuitive approach to introduce the
methods. Thus, we begin the module with Euler’s method, which has a very straightforward graphical
interpretation. Then, we use visually oriented arguments to develop two improved versions of Euler’s
method—the Heun and the midpoint techniques. After this introduction, we formally develop the
concept of Runge-Kutta (or RK) approaches and demonstrate how the foregoing techniques are
actually first- and second-order RK methods.

Learning Outcomes
At the end of this module, you should be able to:
1. Apply one-step methods for solving initial-value ordinary differential equations.

6.1 INTRODUCTION

Mathematical Background
A solution of an ordinary differential equation is a specific function of the independent variable and
parameters that satisfies the original differential equation. To illustrate this concept, let us start with a
given function
𝑦 = −0.5𝑥 4 + 4𝑥 3 − 10𝑥 2 + 8.5𝑥 + 1 (6.1)
which is a fourth-order polynomial (Fig. 6.1a). Now, if we differentiate Eq. (6.1), we obtain an ODE:
𝑑𝑦
= −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5 (6.2)
𝑑𝑥
This equation also describes the behavior of the polynomial, but in a manner different from Eq. (6.1).
Rather than explicitly representing the values of 𝑦 for each value of 𝑥, Eq. (6.2) gives the rate of
change of 𝑦 with respect to 𝑥 (that is, the slope) at every value of 𝑥. Figure 6.1 shows both the function
and the derivative plotted versus 𝑥. Notice how the zero values of the derivatives correspond to the
point at which the original function is flat—that is, has a zero slope. Also, the maximum absolute
values of the derivatives are at the ends of the interval where the slopes of the function are greatest.
Although, as just demonstrated, we can determine a differential equation given the original
function, the object here is to determine the original function given the differential equation. The
original function then represents the solution. For the present case, we can determine this solution
analytically by integrating Eq. (6.2):
𝑦 = ∫(−2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5) 𝑑𝑥
Applying the integration rule
𝑛
𝑢𝑛+1
∫ 𝑢 𝑑𝑢 = +𝐶 𝑛 ≠ −1
𝑛+1
to each term of the equation gives the solution
𝑦 = −0.5𝑥 4 + 4𝑥 3 − 10𝑥 2 + 8.5𝑥 + 𝐶 (6.3)

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 1


Figure 6.1 Plots of (a) 𝑦 versus 𝑥 and (b) 𝑑𝑦/𝑑𝑥 versus 𝑥
for the Function 𝑦 = −0.54 + 4𝑥 3 − 10𝑥 2 + 8.5𝑥 + 1

which is identical to the original function with one notable exception. In the course of differentiating
and then integrating, we lost the constant value of 1 in the original equation and gained the value 𝐶.
This 𝐶 is called a constant of integration. The fact that such an arbitrary constant appears indicates
that the solution is not unique. In fact, it is but one of an infinite number of possible functions
(corresponding to an infinite number of possible values of 𝐶) that satisfy the differential equation. For
example, Fig. 6.2 shows six possible functions that satisfy Eq. (6.3).

Figure 6.2 Six Possible Solutions for the Integral of −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 2


Therefore, to specify the solution completely, a differential equation is usually accompanied by
auxiliary conditions. For first-order ODEs, a type of auxiliary condition called an initial value is required
to determine the constant and obtain a unique solution. For example, Eq. (6.2) could be accompanied
by the initial condition that at 𝑥 = 0, 𝑦 = 1. These values could be substituted into Eq. (6.3):
1 = −0.5(0)4 + 4(0)3 − 10(0)2 + 8.5(0) + 𝐶 (6.4)
to determine 𝐶 = 1. Therefore, the unique solution that satisfies both the differential equation and the
specified initial condition is obtained by substituting 𝐶 = 1 into Eq. (6.3) to yield
𝑦 = −0.5𝑥 4 + 4𝑥 3 − 10𝑥 2 + 8.5𝑥 + 1 (6.5)
Thus, we have “pinned down’’ Eq. (6.3) by forcing it to pass through the initial condition, and in so
doing, we have developed a unique solution to the ODE and have come full circle to the original
function [Eq. (6.1)].
When dealing with an nth-order differential equation, 𝑛 conditions are required to obtain a unique
solution. If all conditions are specified at the same value of the independent variable (for example, at
𝑥 or 𝑡 = 0), then the problem is called an initial-value problem.

Runge-Kutta Methods
This module is devoted to solving ordinary differential equations of the form
𝑑𝑦
= 𝑓(𝑥, 𝑦)
𝑑𝑥
having the general form
New value = old value + slope × step size
or, in mathematical terms,
𝑦𝑖+1 = 𝑦𝑖 + 𝜙ℎ (6.6)
According to this equation, the slope estimate of 𝜙 is used to extrapolate from an old value 𝑦𝑖 to a
new value 𝑦𝑖+1 over a distance ℎ (Fig. 6.3). This formula can be applied step by step to compute out
into the future and, hence, trace out the trajectory of the solution.

Figure 6.3 Graphical Depiction of a One-Step Method

All one-step methods can be expressed in this general form, with the only difference being the
manner in which the slope is estimated. The simplest approach is to use the differential equation to
estimate the slope in the form of the first derivative at 𝑥𝑖 . In other words, the slope at the beginning

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 3


of the interval is taken as an approximation of the average slope over the whole interval. This
approach, called Euler’s method, is discussed in the first part of this module. This is followed by other
one-step methods that employ alternative slope estimates that result in more accurate predictions.
All these techniques are generally called Runge-Kutta methods.

6.2 EULER’S METHOD


The first derivative provides a direct estimate of the slope at 𝑥𝑖 (Fig. 6.4):
𝜙 = 𝑓(𝑥𝑖 , 𝑦𝑖 )
where 𝑓(𝑥𝑖 , 𝑦𝑖 ) is the differential equation evaluated at 𝑥𝑖 and 𝑦𝑖 . This estimate can be substituted
into Eq. (6.6):
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖 )ℎ (6.7)
This formula is referred to as Euler’s (or the Euler-Cauchy or the point-slope) method. A new
value of 𝑦 is predicted using the slope (equal to the first derivative at the original value of 𝑥) to
extrapolate linearly over the step size ℎ (Fig. 6.4).

Figure 6.4 Euler’s Method

Example 6.1
Use Euler’s method to integrate Eq. (6.2):
𝑑𝑦
= −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 4 with a step size of 0.5. The initial condition at 𝑥 = 0 is 𝑦 = 1. Recall that the exact
solution is given by Eq. (6.5):
𝑦 = −0.5𝑥 4 + 4𝑥 3 − 10𝑥 2 + 8.5𝑥 + 1

Solution
1st Step:
Equation (6.7) can be used to implement Euler’s method:
𝑦(0.5) = 𝑦(0) + 𝑓(0,1)0.5
where 𝑦(0) = 1 and the slope estimate at 𝑥 = 0 is
𝑓(0,1) = −2(0)3 + 12(0)2 − 20(0) + 8.5 = 8.5
Therefore,
𝑦(0.5) = 1 + (8.5)0.5 = 5.25
Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 4
The true solution at 𝑥 = 0.5 is
𝑦 = −0.5(0.5)4 + 4(0.5)3 − 10(0.5)2 + 8.5(0.5) + 1 = 3.21875
2nd Step:
Equation (6.7) can be used to implement Euler’s method:
𝑦(1) = 𝑦(0.5) + 𝑓(0.5,5.25)0.5
The slope estimate at 𝑥 = 0.5 is
𝑓(0.5,5.25) = −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5 = 1.25
Therefore,
𝑦(1) = 5.25 + (1.25)0.5 = 5.875
The true solution at 𝑥 = 0.5 is
𝑦 = −0.5(1)4 + 4(1)3 − 10(1)2 + 8.5(1) + 1 = 3
The computation is repeated, and the results are compiled in Table 6.1 and Fig. 6.5.

Table 6.1 Comparison of True Value and Approximate Value Using Euler’s Method
𝑥 𝑦true 𝑦Euler
0.0 1.00000 1.00000
0.5 3.21875 5.25000
1.0 3.00000 5.87500
1.5 2.21875 5.12500
2.0 2.00000 4.50000
2.5 2.71875 4.75000
3.0 4.00000 5.87500
3.5 4.71875 7.12500
4.0 3.00000 7.00000

Figure 6.5 Comparison of the True Solution with a Numerical Solution Using Euler’s Method

6.3 IMPROVEMENTS OF THE EULER’S METHOD


A fundamental source of error in Euler’s method is that the derivative at the beginning of the interval
is assumed to apply across the entire interval. Two simple modifications are available to help
circumvent this shortcoming. As will be demonstrated in Sec. 6.4, both modifications actually belong
to a larger class of solution techniques called Runge-Kutta methods. However, because they have a

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 5


very straightforward graphical interpretation, we will present them prior to their formal derivation as
Runge-Kutta methods.

Heun’s Method
One method to improve the estimate of the slope involves the determination of two derivatives for the
interval—one at the initial point and another at the end point. The two derivatives are then averaged
to obtain an improved estimate of the slope for the entire interval. This approach, called Heun’s
method, is depicted graphically in Fig. 6.6.

Figure 6.6 Graphical Depiction of Heun’s Method. (a) Predictor and (b) Corrector

Recall that in Euler’s method, the slope at the beginning of an interval


𝑦𝑖 ′ = 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.8)
is used to extrapolate linearly to 𝑦𝑖+1 :
0
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖 )ℎ (6.9)
0
For the standard Euler method, we would stop at this point. However, in Heun’s method, the 𝑦𝑖+1
calculated in Eq. (6.9) is not the final answer, but an intermediate prediction. This is why we have
distinguished it with a superscript 0. Equation (6.9) is called a predictor equation. It provides an
estimate of 𝑦𝑖+1 that allows the calculation of an estimated slope at the end of the interval:
′ 0
𝑦𝑖+1 = 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 ) (6.10)
Thus, the two slopes [Eqs. (6.8) and (6.10)] can be combined to obtain an average slope for the
interval:
𝑦𝑖′ + 𝑦𝑖+1
′ 0
𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )
𝑦̅′ = =
2 2
This average slope is then used to extrapolate linearly from 𝑦𝑖 to 𝑦𝑖+1 using Euler’s method:

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 6


0
𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )
𝑦𝑖+1 = 𝑦𝑖 + ℎ
2
which is called a corrector equation.
The Heun method is a predictor-corrector approach. As derived above, it can be expressed
concisely as
0
Predictor (Fig. 6.6a): 𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖 )ℎ (6.11)
0
𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )
Corrector (Fig. 6.6b): 𝑦𝑖+1 = 𝑦𝑖 + ℎ (6.12)
2
Note that the Eq. (6.12) has 𝑦𝑖+1 on both sides of equal sign, it can be applied in an iterative
fashion. That is, an old estimate can be used repeatedly to provide an improved estimate of 𝑦𝑖+1 .

Example 6.2
Use Heun’s method to integrate Eq. (6.2):
𝑑𝑦
= −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 4 with a step size of 0.5. The initial condition at 𝑥 = 0 is 𝑦 = 1.

Solution
1st Step:
According to Euler’s method:
𝑦(0.5) = 𝑦(0) + 𝑓(0,1)0.5
where 𝑦(0) = 1 and the slope estimate at 𝑥 = 0 is
𝑓(0,1) = −2(0)3 + 12(0)2 − 20(0) + 8.5 = 8.5
Therefore,
𝑦(0.5) = 1 + (8.5)0.5 = 5.25
The slope estimate at 𝑥 = 0.5 is
𝑓(0.5,5.25) = −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5 = 1.25
Therefore,
8.5 + 1.25
𝑦 ′ (0.5) = = 4.875
2
𝑦(0.5) = 1 + (4.875)0.5 = 3.4375
nd
2 Step:
According to Euler’s method:
𝑦(1) = 𝑦(0.5) + 𝑓(0.5,5.25)0.5
The slope estimate at 𝑥 = 0.5 is
𝑓(0.5,5.25) = −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5 = 1.25
Therefore,
𝑦(1) = 5.25 + (1.25)0.5 = 5.875
The slope estimate at 𝑥 = 1 is
𝑓(1,5.875) = −2(1)3 + 12(1)2 − 20(1) + 8.5 = −1.5
Therefore,
1.25 + (−1.5)
𝑦 ′ (1) = = −0.125
2
𝑦(1) = 3.4375 + (−0.125)0.5 = 3.375
The computation is repeated, and the results are compiled in Table 6.2 and Fig. 6.6.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 7


Table 6.2 Comparison of True Value and Approximate Value Using Heun’s Method
𝑥 𝑦true 𝑦Heun
0.0 1.00000 1.00000
0.5 3.21875 3.43750
1.0 3.00000 3.37500
1.5 2.21875 2.68750
2.0 2.00000 2.50000
2.5 2.71875 3.18750
3.0 4.00000 4.37500
3.5 4.71875 4.93750
4.0 3.00000 3.00000

Figure 6.7 Comparison of the True Solution with a


Numerical Solution Using Euler’s and Heun’s Methods

Midpoint (or Improved Polygon) Method


Figure 6.8 illustrates another simple modification of Euler’s method. Called the midpoint method (or
the improved polygon or the modified Euler), this technique uses Euler’s method to predict a value of
𝑦 at the midpoint of the interval (Fig. 6.8a):

𝑦𝑖+1⁄2 = 𝑦𝑖 + 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.13)
2
Then, this predicted value is used to calculate a slope at the midpoint:

𝑦𝑖+1 ⁄2 = 𝑓(𝑥𝑖+1⁄2 , 𝑦𝑖+1⁄2 ) (6.14)
which is assumed to represent a valid approximation of the average slope for the entire interval. This
slope is then used to extrapolate linearly from 𝑥𝑖 to 𝑥𝑖+1 (Fig. 6.8b):
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑥𝑖+1⁄2 , 𝑦𝑖+1⁄2 )ℎ (6.15)
Observe that because 𝑦𝑖+1 is not on both sides, the corrector [Eq. (6.15)] cannot be applied iteratively
to improve the solution.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 8


Figure 6.8 Graphical Depiction of the Midpoint Method. (a) Eq. (6.13) and (b) Eq. (6.15)

The midpoint method is superior to Euler’s method because it utilizes a slope estimate at the
midpoint of the prediction interval.

6.4 SECOND-ORDER RUNGE-KUTTA METHODS


The Runge-Kutta (RK) methods does not require the calculation of higher derivatives. The general
form of the RK method is given by
𝑦𝑖+1 = 𝑦𝑖 + 𝜙(𝑥𝑖 , 𝑦𝑖 , ℎ)ℎ (6.16)
where 𝜙(𝑥𝑖 , 𝑦𝑖 , ℎ) is called an increment function. For second-order RK methods, the increment
function can be written in general form as
𝜙 = 𝑎1 𝑘1 + 𝑎2 𝑘2 (6.17)
Therefore, the second-order version of Eq. (6.16) is
𝑦𝑖+1 = 𝑦𝑖 + (𝑎1 𝑘1 + 𝑎2 𝑘2 )ℎ (6.18)
where
𝑘1 = 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.18a)
𝑘2 = 𝑓(𝑥𝑖 + 𝑝1 ℎ, 𝑦𝑖 + 𝑞11 𝑘1 ℎ) (6.18b)
The values for 𝑎1 , 𝑎2 , 𝑝1 , and 𝑞11 are evaluated by setting Eq. (6.18) equal to a Taylor series
expansion to the second-order term. By doing this, we derive three equations to evaluate the four
unknown constants. The three equations are
𝑎1 + 𝑎2 = 1 (6.19)
1
𝑎2 𝑝1 = (6.20)
2
1
𝑎2 𝑞11 = (6.21)
2

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 9


Because we have three equations with four unknowns, we must assume a value of one of the
unknowns to determine the other three. Suppose that we specify a value for 𝑎2 . Then Eqs. (6.19)
through (6.21) can be solved simultaneously for
𝑎1 = 1 − 𝑎2 (6.22)
1
𝑝1 = 𝑞11 = (6.23)
2𝑎2
Because we can choose an infinite number of values for 𝑎2 , there are an infinite number of second-
order RK methods. Every version would yield exactly the same results if the solution to the ODE were
quadratic, linear, or a constant. However, they yield different results when (as is typically the case)
the solution is more complicated. We present three of the most commonly used and preferred
versions:

Heun Method with a Single Corrector (a2 = 1/2)


If 𝑎2 is assumed to be 1/2, Eqs. (6.22) and (6.23) can be solved for 𝑎1 = 1/2 and 𝑝1 = 𝑞11 = 1. These
parameters, when substituted into Eq. (6.18), yield
1 1
𝑦𝑖+1 = 𝑦𝑖 + ( 𝑘1 + 𝑘2 ) ℎ (6.24)
2 2
where
𝑘1 = 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.24a)
𝑘2 = 𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 ℎ) (6.24b)
Note that 𝑘1 is the slope at the beginning of the interval and 𝑘2 is the slope at the end of the interval.
Consequently, this second-order Runge-Kutta method is actually Heun’s technique without iteration.

Midpoint Method (a2 = 1)


If 𝑎2 is assumed to be 1, then 𝑎1 = 0, and 𝑝1 = 𝑞11 = 1/2, and Eq. (6.18) becomes
𝑦𝑖+1 = 𝑦𝑖 + 𝑘2 ℎ (6.25)
where
𝑘1 = 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.25a)
1 1
𝑘2 = 𝑓 (𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 ℎ) (6.25b)
2 2
This is the midpoint method.

Ralston’s Method (a2 = 2/3)


Ralston (1962) and Ralston and Rabinowitz (1978) determined that choosing 𝑎2 = 2/3 provides a
minimum bound on the truncation error for the second-order RK algorithms. For this version, 𝑎1 =
1/3 and 𝑝1 = 𝑞11 = 3/4 and yields
1 2
𝑦𝑖+1 = 𝑦𝑖 + ( 𝑘1 + 𝑘2 ) ℎ (6.26)
3 3
where
𝑘1 = 𝑓(𝑥𝑖 , 𝑦𝑖 ) (6.26a)
3 3
𝑘2 = 𝑓 (𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 ℎ) (6.26b)
4 4

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 10


Example 6.3
Use the midpoint method [Eq. (6.25)] and Ralston’s method [Eq. (6.26)] to integrate Eq. (6.2):
𝑑𝑦
= −2𝑥 3 + 12𝑥 2 − 20𝑥 + 8.5
𝑑𝑥
from 𝑥 = 0 to 𝑥 = 4 with a step size of 0.5. The initial condition at 𝑥 = 0 is 𝑦 = 1. Compare the results
with the values obtained using another second-order RK algorithm, that is, the Heun method without
corrector iteration (Table 6.2).

Solution
Using Midpoint Method,
1st Step:
Compute for 𝑘1 and 𝑘2 ,
𝑘1 = −2(0)3 + 12(0)2 − 20(0) + 8.5 = 8.5
𝑘2 = −2(0.25)3 + 12(0.25)2 − 20(0.25) + 8.5 = 4.21875
Therefore,
𝑦(0.5) = 1 + 4.21875(0.5) = 3.109375
nd
2 Step:
Compute for 𝑘1 and 𝑘2 ,
𝑘1 = −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5 = 1.25
𝑘2 = −2(0.75)3 + 12(0.75)2 − 20(0.75) + 8.5 = −0.59375
Therefore,
𝑦(1) = 3.109375 + (−0.59375)(0.5) = 2.8125
The computation is repeated, and the results are summarized in Table 6.3 and Fig. 6.9.

Using Ralston’s Method,


1st Step:
Compute for 𝑘1 and 𝑘2 ,
𝑘1 = −2(0)3 + 12(0)2 − 20(0) + 8.5 = 8.5
𝑘2 = −2(0.375)3 + 12(0.375)2 − 20(0.375) + 8.5 = 2.58203125
The average slope is
1 2
𝜙 = (8.5) + (2.58203125) = 4.5546875
3 3
Therefore,
𝑦(0.5) = 1 + 4.5546875(0.5) = 3.277344
nd
2 Step:
Compute for 𝑘1 and 𝑘2 ,
𝑘1 = −2(0.5)3 + 12(0.5)2 − 20(0.5) + 8.5 = 1.25
𝑘2 = −2(0.875)3 + 12(0.875)2 − 20(0.875) + 8.5 = −1.15234375
The average slope is
1 2
𝜙 = (1.25) + (−1.15234375) = −0.3515625
3 3
Therefore,
𝑦(1) = 3.277344 + (−0.3515625)(0.5) = 3.101563
The computation is repeated, and the results are summarized in Table 6.3 and Fig. 6.9. Notice how
all the second-order RK methods are superior to Euler’s method.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 11


Table 6.3 Comparison of True Value and Approximate Value
Using Three Versions of Second-Order RK Methods
𝑥 𝑦true 𝑦Heun 𝑦Midpoint 𝑦Ralston
0.0 1.00000 1.00000 1.00000 1.00000
0.5 3.21875 3.43750 3.109375 3.277344
1.0 3.00000 3.37500 2.81250 3.101563
1.5 2.21875 2.68750 1.984375 2.347656
2.0 2.00000 2.50000 1.75 2.140625
2.5 2.71875 3.18750 2.484375 2.855469
3.0 4.00000 4.37500 3.81250 4.117188
3.5 4.71875 4.93750 4.609375 4.800781
4.0 3.00000 3.00000 3 3.031250

Figure 6.9 Comparison of the True Solution with Numerical Solutions


Using Three Second-Order RK Methods and Euler’s Method

EXERCISE SET

Answer the following problems using the specified method.

1. Solve the following initial value problem over the interval from 𝑡 = 0 to 2 where 𝑦(0) = 1. Display
all your results on the same graph.
𝑑𝑦
= 𝑦𝑡 2 − 1.1𝑦
𝑑𝑡
(a) Analytically.
(b) Euler’s method with ℎ = 0.5 and 0.25.
(c) Midpoint method with ℎ = 0.5.
(d) Ralston’s method with ℎ = 0.5.
2. Solve the following problem over the interval 𝑥 = 0 to 1 using a step size of 0.25 where 𝑦(0) = 1.
Display all your results on the same graph.
𝑑𝑦
= (1 + 4𝑥)√𝑦
𝑑𝑥

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 12


(a) Analytically.
(b) Euler’s method.
(c) Heun’s method without iteration
(d) Ralston’s method
3. Solve from 𝑡 = 0 to 3 with ℎ = 0.1 using (a) Heun (without corrector) and (b) Ralston’s second-
order RK method:
𝑑𝑦
= 𝑦 sin3(𝑡) 𝑦(0) = 1
𝑑𝑡
4. Solve the following problem numerically from 𝑡 = 0 to 3 with ℎ = 0.5:
𝑑𝑦
= −2𝑦 + 𝑡 2 𝑦(0) = 1
𝑑𝑡
Using
(a) Euler’s method.
(b) Heun’s method without iteration.
(c) Midpoint method.
(d) Ralston’s method.
5. Given
𝑑𝑦
= 30(cos 𝑡 − 𝑦) + 3 sin 𝑡
𝑑𝑡
If 𝑦(0) = 1, obtain a solution from 𝑡 = 0 to 4 using a step size of 0.4 by applying
(a) Euler’s method.
(b) Heun’s method without iteration.
(c) Midpoint method.
(d) Ralston’s method.
6. Solve the following problem numerically from 𝑥 = 0 to 4 with ℎ = 1:
𝑑𝑦
= 40𝑒 0.8𝑥 − 0.5𝑦 𝑦(0) = 2
𝑑𝑥
Using
(a) Analytically
(b) Euler’s method.
(c) Heun’s method without iteration.
(d) Midpoint method.
(e) Ralston’s method.
7. If water is drained from a vertical cylindrical tank by opening a valve at the base, the water will
flow fast when the tank is full and slow down as it continues to drain. As it turns out, the rate at
which the water level drops is:
𝑑𝑦
= −𝑘√𝑦
𝑑𝑡
where 𝑘 is a constant depending on the shape of the hole and the cross-sectional area of the tank
and drain hole. The depth of the water 𝑦 is measured in meters and the time 𝑡 in minutes. If 𝑘 =
0.06, determine how long it takes the tank to drain if the fluid level is initially 3 m. Solve by applying
Euler’s equation and writing a computer program or using Excel. Use a step of 0.5 minutes.
8. The rate of heat flow (conduction) between two points on a cylinder heated at one end is given
by
𝑑𝑄 𝑑𝑇
= 𝜆𝐴
𝑑𝑡 𝑑𝑥

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 13


where 𝜆 = a constant, 𝐴 = the cylinder’s cross-sectional area, 𝑄 = heat flow, 𝑇 = temperature,
𝑡 = time, and 𝑥 = distance from the heated end. Because the equation involves two derivatives,
we will simplify this equation by letting
𝑑𝑇 100(𝐿 − 𝑥)(20 − 𝑡)
=
𝑑𝑥 100 − 𝑥𝑡
where 𝐿 is the length of the rod. Combine the two equations and compute the heat flow for 𝑡 = 0
to 25 s. The initial condition is 𝑄(0) = 0 and the parameters are 𝜆 = 0.5 cal ⋅ cm/s, 𝐴 = 12 cm2,
𝐿 = 20 cm, and 𝑥 = 2.5 cm. Plot your results.
9. For a simple RL circuit, Kirchhoff’s voltage requires that (if Ohm’s law holds)
𝑑𝑖
𝐿 + 𝑅𝑖 = 0
𝑑𝑡
where 𝑖 = current, 𝐿 = inductance, and 𝑅 = resistance. Solve for 𝑖, if 𝐿 = 1, 𝑅 = 1.5, and 𝑖(0) =
0.5. Solve this problem analytically and with a numerical method. Present your results graphically.
10. Population-growth dynamics are important in a variety of planning studies for areas such as
transportation and water-resource engineering. One of the simplest models of such growth
incorporates the assumption that the rate of change of the population 𝑝 is proportional to the
existing population at any time 𝑡:
𝑑𝑝
= 𝐺𝑝
𝑑𝑡
where 𝐺 = a growth rate (per year). This model makes intuitive sense because the greater the
population, the greater the number of potential parents. At time 𝑡 = 0, an island has a population
of 6000 people. If 𝐺 = 0.075 per year, employ Heun’s method (without iteration) to predict the
population at 𝑡 = 20 years, using a step size of 0.5 year. Plot 𝑝 versus 𝑡 on standard and semilog
graph paper. Determine the slope of the line on the semilog plot. Discuss your results.

SUPPLEMENTARY READING
Read Chapter 28: Case Studies for Ordinary Differential Equations on the book Numerical
Methods for Engineers (7th ed.) by Chapra and Canale. The purpose of this supplementary reading
is to solve some ordinary differential equations using the numerical methods presented in this module.
The equations originate from practical engineering applications. Many of the applications
result in nonlinear differential equations which cannot be solved using analytic techniques. Therefore,
numerical methods are usually required. Thus, the techniques for the numerical solution of ordinary
differential equations are fundamental capabilities that characterize good engineering practice.

REFERENCES
1. Chapra, S. C., Canale, R. P. (2015). Numerical Methods for Engineers (7th ed.). The McGraw-Hill
Companies, Inc.
2. Chapra, S. C. (2018). Applied Numerical Methods with MATLAB® for Engineers and Scientists
(4th ed.). The McGraw-Hill Companies, Inc.

Math 23 – Advanced Mathematics Engr. Michael Ernie F. Rodriguez | Page 14

You might also like