Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Differential Equations

CSSS2763 : LN05
Fall 2021

Section 2.6:
A Numerical Method

1
Euler’s Method
Consider the first order IVP:
𝑑𝑦
= 𝑓 𝑥, 𝑦 , 𝑦 𝑥0 = 𝑦0
𝑑𝑥
One way of approximating the solution of the IVP is to use
tangent lines. Using the point (𝑥0 , 𝑦0 ) and the slope 𝑓(𝑥0 , 𝑦0 ),
we can approximate the solution 𝑦1 = 𝑦(𝑥1 ) at 𝑥 = 𝑥1 within
a small neighbourhood of 𝑥0 as
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ), where ℎ = 𝑥1 − 𝑥0 .

Using the same idea, we can define 𝑦2 , 𝑦3 , 𝑦4 ∙∙∙ recursively by the general formula
𝑦2 = 𝑦1 + ℎ𝑓 𝑥1 , 𝑦1
𝑦3 = 𝑦2 + ℎ𝑓 𝑥2 , 𝑦2

𝑦𝑛+1 = 𝑦𝑛 + ℎ𝑓 𝑥𝑛 , 𝑦𝑛 , where 𝑥𝑛 = 𝑥0 + 𝑛ℎ, 𝑛 = 0, 1, 2, ⋯
3

Exercise 1: Page 80
Consider the IVP: 𝑦 ′ = 2𝑥 − 3𝑦 + 1, 𝑦 1 = 5.
Use Euler’s method to obtain an approximation of 𝑦(1.2) using ℎ = 0.1 and ℎ = 0.05

Solution:
Using Euler’s method with 𝑓 𝑥, 𝑦 = 2𝑥 − 3𝑦 + 1
𝑦𝑛+1 = 𝑦𝑛 + ℎ 2𝑥𝑛 − 3𝑦𝑛 + 1 , 𝑥𝑛 = 1 + 𝑛ℎ. Similarly, using the Euler’s method with ℎ
Then, for ℎ = 0.1 = 0.05 we need 4 iterations to find 𝑦(1.2).
𝑥0 = 1.0, 𝑦0 = 5
𝑥1 = 1.1, 𝑦1 = 𝑦0 + ℎ 2𝑥0 − 3𝑦0 + 1 = 3.8
ℎ 𝑛 𝑥𝑛 𝑦𝑛
𝑥2 = 1.2, 𝑦2 = 𝑦1 + ℎ 2𝑥1 − 3𝑦1 + 1 = 2.98
0 1.00 5.0000
ℎ 𝑛 𝑥𝑛 𝑦𝑛 1 1.05 4.4000
0 1.0 5.00 0.05 2 1.10 3.8950
0.1 1 1.1 3.80 3 1.15 3.4708
2 1.2 2.98 4 1.20 3.1151
4

2
Example 1: Page 77
Consider the IVP: 𝑦 ′ = 0.1 𝑦 + 0.4𝑥 2 , 𝑦 2 = 4.
Use Euler’s method to obtain an approximation of 𝑦(2.5) using first ℎ = 0.1 and ℎ = 0.05
Solution: ℎ 𝑛 𝑥𝑛 𝑦𝑛
Using Euler’s method with 𝑓 𝑥, 𝑦 = 0.1 𝑦 + 0.4𝑥 2 0 2.00 4.0000
𝑦𝑛+1 = 𝑦𝑛 + ℎ 0.1 𝑦𝑛 + 0.4 𝑥𝑛 2 , 𝑥𝑛 = 𝑥0 + 𝑛ℎ. 1 2.05 4.0900
2 2.10 4.1842
3 2.15 4.2826
ℎ 𝑛 𝑥𝑛 𝑦𝑛 4 2.20 4.3854
0 2.0 4.0000 0.05 5 2.25 4.4927
1 2.1 4.1800 6 2.30 4.6045
2 2.2 4.3768 7 2.35 4.7210
0.1
3 2.3 4.5914 8 2.40 4.8423
4 2.4 4.8244 9 2.45 4.9686
5 2.5 5.0768 10 2.50 5.0997
5

Online Euler’s Method Calculator


Several webpages that provide online calculators for Solving IVPs using Euler’s method.

https://www.emathhelp.net/calculators/differential-equations/euler-method-calculator/

3
Section 3.1:
Linear Models

Growth and Decay


Consider the IVP:
𝑑𝑃
= 𝑘𝑃, 𝑃 0 = 𝑃0
𝑑𝑡
where, 𝑃(𝑡) is the population size at time 𝑡 and 𝑘 is a constant of proportionality. This IVP
serves as a model for diverse phenomena involving either growth or decay.
Method of solution:
• The DE is both separable and linear.
• The explicit solution of the IVP is: 𝑃(𝑡) = 𝑐𝑒 𝑘𝑡 , where 𝑐 is an arbitrary constant.
• Two conditions (at least) will be given to find the constants 𝑐 and 𝑘.
• Using the initial condition 𝑃 0 = 𝑃0 implies 𝑐 = 𝑃0 .
• The final solution of the IVP is:
𝑃 𝑡 = 𝑃0 𝑒 𝑘𝑡

4
Example 1: Page 85
A culture initially has 𝑃0 number of bacteria. At 𝑡 = 1 hour the number of bacteria is measured
3
to be 𝑃0 . If the rate of growth is proportional to the number of bacteria 𝑃(𝑡) present at time 𝑡,
2
determine the time necessary for the number of bacteria to triple.
Solution:
𝑑𝑃 3
DE: = 𝑘𝑃, Conditions: 𝑃 0 = 𝑃0 , 𝑃 1 = 𝑃
𝑑𝑡 2 0
𝑑𝑃
The standard form of the linear equation is: − 𝑘𝑃 = 0
𝑑𝑥

The integration factor is: 𝜇 𝑡 = 𝑒 ‫ ׬‬−𝑘𝑑𝑡 = 𝑒 −𝑘𝑡


By multiplying the standard equation by 𝜇 𝑡 , we have
𝑑
𝜇 𝑡 𝑃 =0 ⇒ 𝜇 𝑡 𝑃=𝑐 ⇒ 𝑒 −𝑘𝑡 𝑃 = 𝑐 ⇒ 𝑃 = 𝑐𝑒 𝑘𝑡
𝑑𝑡
Using the initial condition 𝑃 0 = 𝑃0 , by setting 𝑡 = 0 and 𝑃 = 𝑃0 implies 𝑐 = 𝑃0
The explicit solution of the IVP is: 𝑃 = 𝑃0 𝑒 𝑘𝑡 9

Example 1: Page 85 (Continued…)



Determine the time necessary for the number of bacteria to triple.
Solution: Continued …
3
Now apply 𝑃 1 = 𝑃0 , then
2
3 3 3
𝑃 = 𝑃0 𝑒𝑘(1) ⇒ = 𝑒𝑘 ⇒ ln = 𝑘 ⇒ 𝑘 = 0.4055.
2 0 2 2
Now the solution is:
𝑃 = 𝑃0 𝑒 0.4055𝑡
Determine the time necessary for the number of bacteria to triple.
Put 𝑃 𝑡 = 3𝑃0 and solve for 𝑡.
3𝑃0 = 𝑃0 𝑒 0.4055𝑡 ⇒ 3 = 𝑒 0.4055𝑡 ⇒ ln 3 = 0.4055𝑡
ln 3
⇒𝑡= = 2.71 hour.
0.4055

10

10

5
Newton’s Law of Cooling/Warming
Newton’s empirical law of cooling/warming:
𝑑𝑇
= 𝑘(𝑇 − 𝑇𝑚 ), 𝑃 0 = 𝑃0
𝑑𝑡
where 𝑘 is a constant of proportionality, 𝑇(𝑡) is the temperature of the object for 𝑡 > 0, and 𝑇𝑚
is the ambient temperature (the temperature of the medium around the object).
Method of solution:
• The DE is both separable and linear.
• The explicit solution of the IVP is: 𝑇 𝑡 = 𝑇𝑚 + 𝑐𝑒 𝑘𝑡 , where 𝑐 is an arbitrary constant.
• Two conditions (at least) will be given to find the constants 𝑐 and 𝑘.
• Using the initial condition 𝑇 0 = 𝑇0 implies 𝑐 = 𝑇0 − 𝑇𝑚 .
• The final solution of the IVP is:
𝑇 𝑡 = 𝑇𝑚 + (𝑇0 − 𝑇𝑚 )𝑒 𝑘𝑡

11

11

Example 4: Page 88
When a cake is removed from an oven, its temperature is measured at 150𝑜 C. Three minutes
later its temperature is 90𝑜 C. How long will it take for the cake to cool off to a room
temperature of 20𝑜 C?
Solution:
𝑑𝑇
DE: = 𝑘 𝑇 − 𝑇𝑚 , 𝑇𝑚 = 20 Conditions: 𝑇 0 = 150, 𝑇 3 = 90.
𝑑𝑡
If we separate the variables, we get

𝑑𝑇 𝑑𝑇
= 𝑘𝑑𝑡 ⇒ න = න 𝑘𝑑𝑡 ⇒ ln |𝑇 − 20| = 𝑘𝑡 + 𝑐
𝑇 − 20 𝑇 − 20
⇒ 𝑇 𝑡 − 20 = 𝑒 𝑘𝑡+𝑐 ⇒ 𝑇 𝑡 = 20 + 𝑐1 𝑒 𝑘𝑡 , where 𝑐1 = ±𝑒 𝑐
Now let’s use the given conditions. Since 𝑇 0 = 150, that implies
150 = 20 + 𝑐1 𝑒 0 ⇒ 𝑐1 = 130
Now the solution becomes 𝑇 𝑡 = 20 + 130𝑒 𝑘𝑡 .
12

12

6
Example 1: Page 85 (Continued…)

Determine the time necessary for the number of bacteria to triple.
Solution: Continued …
Since 𝑇 3 = 90 (when 𝑡 = 3, 𝑇 = 90) that implies
70 70
90 = 20 + 130𝑒 3𝑘 ⇒ = 𝑒 3𝑘 ⇒ ln = 3𝑘 ⇒ 𝑘 = −0.206
130 130
Now the solution becomes
𝑇 𝑡 = 20 + 130𝑒 −0.206𝑡 .
How long will it take for the cake to cool off to a room temperature of 20𝑜 C ?
Put 𝑇 𝑡 = 20 and solve for 𝑡, we have
20 = 20 + 130𝑒 −0.206𝑡 ⇒ 0 = 𝑒 −0.206𝑡 ⇒ 𝑡 → ∞.
Note that, for 𝑡 = 30, we have 𝑇 𝑡 = 20 + 130𝑒 −0.206(30) = 20.27𝑜 .
It means the cake will be approximately at the room temperature in about one-half hour.
13

13

Exercise 1: Page 91
The population of a community is known to increase at a rate proportional to the number of
people present at time 𝑡. If an initial population 𝑃0 has doubled in 5 years, how long will it take
to triple? To quadruple?
Solution:
𝑑𝑃
DE: = 𝑘𝑃, Conditions: 𝑃 0 = 𝑃0 , 𝑃 5 = 2𝑃0
𝑑𝑡
𝑑𝑃
The standard form of the linear equation is: − 𝑘𝑃 = 0
𝑑𝑥

The integration factor is: 𝜇 𝑡 = 𝑒 ‫ ׬‬−𝑘𝑑𝑡 = 𝑒 −𝑘𝑡


By multiplying the standard equation by 𝜇 𝑡 , we have
𝑑
𝜇 𝑡 𝑃 =0 ⇒ 𝜇 𝑡 𝑃=𝑐 ⇒ 𝑒 −𝑘𝑡 𝑃 = 𝑐 ⇒ 𝑃 = 𝑐𝑒 𝑘𝑡
𝑑𝑡
Using the initial condition 𝑃 0 = 𝑃0 , by setting 𝑡 = 0 and 𝑃 = 𝑃0 implies 𝑐 = 𝑃0
The explicit solution of the IVP is: 𝑃 = 𝑃0 𝑒 𝑘𝑡
14

14

7
Exercise 1: Page 91 (Continued…)

how long will it take to triple? To quadruple?
Solution: Continued …
Now apply 𝑃 5 = 2𝑃0 , then
2𝑃0 = 𝑃0 𝑒𝑘(5) ⇒ 2 = 𝑒 5𝑘 ⇒ ln 2 = 5𝑘 ⇒ 𝑘 = 0.1386.
Now the solution is:
𝑃 = 𝑃0 𝑒 0.1386𝑡
How long will it take to triple? To quadruple?
Put 𝑃 𝑡 = 3𝑃0 and solve for 𝑡.
3𝑃0 = 𝑃0 𝑒 0.1386𝑡 ⇒ 3 = 𝑒 0.1386𝑡 ⇒ ln 3 = 0.1386𝑡 ⇒ 𝑡 = 7.9 years
Put 𝑃 𝑡 = 4𝑃0 and solve for 𝑡.
4𝑃0 = 𝑃0 𝑒 0.1386𝑡 ⇒ 4 = 𝑒 0.1386𝑡 ⇒ ln 4 = 0.1386𝑡 ⇒ 𝑡 = 10 years

15

15

Exercise 14: Page 92


A thermometer is taken from an inside room to the outside, where the air temperature is
− 15𝑜 C. After 1 minute the thermometer reads 13𝑜 C, and after 5 minutes it reads −1𝑜 C. What
is the initial temperature of the inside room?
Solution:
𝑑𝑇
DE: = 𝑘 𝑇 − 𝑇𝑚 , 𝑇𝑚 = −15 Conditions: 𝑇 1 = 13, 𝑇 5 = −1.
𝑑𝑡
If we separate the variables, we get

𝑑𝑇 𝑑𝑇
= 𝑘𝑑𝑡 ⇒ න = න 𝑘𝑑𝑡 ⇒ ln |𝑇 + 15| = 𝑘𝑡 + 𝑐
𝑇 − 𝑇𝑚 𝑇 + 15
⇒ 𝑇 𝑡 + 15 = 𝑒 𝑘𝑡+𝑐 ⇒ 𝑇 𝑡 = −15 + 𝑐1 𝑒 𝑘𝑡 , where 𝑐1 = ±𝑒 𝑐
Now let’s use the given conditions. Since 𝑇 1 = 13, that implies
13 = −15 + 𝑐1 𝑒 𝑘 ⇒ 28 = 𝑐1 𝑒 𝑘 (1)

16

16

8
Exercise 14: Page 92 (Continued…)

What is the initial temperature of the inside room?
Solution: Continued …
Since 𝑇 5 = −1 that implies
−1 = −15 + 𝑐1 𝑒 5𝑘 ⇒ 14 = 𝑐1 𝑒 5𝑘 (2)
Using Eq. (1) and Eq. (2)
1
2 = 𝑒 𝑘−5𝑘 = e−4k ⇒ 𝑘 = − ln 2 = −0.173 ⇒ 𝑐1 = 33.298.
4
Now the solution becomes
𝑇 𝑡 = −15 + 33.298𝑒 −0.173𝑡 .
What is the initial temperature of the inside room?
At 𝑡 = 0
𝑇0 = 𝑇 0 = −15 + 33.298𝑒 0 = 18.298 ≈ 18𝑜 C
17

17

Section 3.2:
Nonlinear Models

18

18

9
Logistic Equation
Consider the IVP:
𝑑𝑃
= 𝑃 𝑎 − 𝑏𝑃 , 𝑎 > 0, 𝑏 > 0.
𝑑𝑡
• where, 𝑃(𝑡) is the human population at time 𝑡. This equation known as the logistic equation,
and its solution is called the logistic function.
Method of solution:
• The DE is a nonlinear equation but separable.
• Two conditions (at least) will be given to find the solution of the IVP.

19

19

Example 1: Page 99
Suppose a student carrying a flu virus returns to an isolated college campus of 1000 students. If
it is assumed that the rate at which the virus spreads is proportional not only to the number 𝑥
of infected students but also to the number of students not infected, determine the number of
infected students after 6 days if it is further observed that after 4 days 𝑥 4 = 50.
Solution:
If no one leaves the campus throughout the duration of the disease, we must solve the IVP:
𝑑𝑥
= 𝑘𝑥 1000 − 𝑥 , 𝑥 0 =1
𝑑𝑡
By writing the equation separable form
𝑑𝑥
= 𝑘𝑑𝑡
𝑥 1000 − 𝑥
Decomposing the left-hand side into partial fractions:

1 𝐴 𝐵 𝐴 1000 − 𝑥 + 𝐵𝑥
= + =
𝑥 1000 − 𝑥 𝑥 1000 − 𝑥 𝑥(1000 − 𝑥) 20

20

10
Example 1: Page 99 (Continue…)

Determine the number of infected students after 6 days.
Solution: Continue …
1 = 𝐴 1000 − 𝑥 + 𝐵𝑥.
Set 𝑥 = 1000 ⇒ B = 1/1000 and set 𝑥 = 0 ⇒ A = 1/1000.
Thus, the equation becomes
𝑑𝑥 𝑑𝑥 1 1
+ = 𝑘𝑑𝑡 ⇒
ln 𝑥 − ln 1000 − 𝑥 = 𝑘𝑡 + 𝑐
1000𝑥 1000 1000 − 𝑥 1000 1000
𝑥
⇒ ln 𝑥 − ln 1000 − 𝑥 = 1000𝑘𝑡 + 1000𝑐 ⇒ ln = 1000𝑘𝑡 + 1000𝑐
1000 − x
1 1
Using 𝑥(0) = 1 gives: ln = 1000𝑐 ⇒ 1000𝑐 = ln = −6.9068.
999 999
50 1 50
Using 𝑥(4) = 50 gives: ln = 4000𝑘 − 6.9068 ⇒ 1000𝑘 = ln + 6.9068 = 0.9906
950 4 950

21

21

Example 1: Page 99 (Continue…)



Determine the number of infected students after 6 days.
Solution: Continue …
Thus, the solution becomes
𝑥 𝑥
ln = 0.9906𝑡 − 6.9068 ⇒ = 𝑒 0.9906𝑡−6.9068 = 0.001𝑒 0.9906𝑡
1000 − x 1000 − 𝑥
⇒ 𝑥 = 𝑒 0.9906𝑡 − 0.001𝑥𝑒 0.9906𝑡 ⇒ 𝑥 + 0.001𝑥𝑒 0.9906𝑡 = 𝑒 0.9906𝑡
⇒ 𝑥 1 + 0.001𝑒 0.9906𝑡 = 𝑒 0.9906𝑡
The general solution is:
𝑒 0.9906𝑡 1
𝑥= 0.9906𝑡
= −0.9906𝑡
1 + 0.001𝑒 𝑒 + 0.001
Determine the number of infected students after 6 days!
1
𝑥 6 = = 276 Students.
𝑒 −0.9906(6) + 0.001 22

22

11

You might also like