Overview Linear Models Nonlinear Models Summary Chapter 3: Modeling with First-Order Differential Equations 王奕翔 Department of Electrical Engineering National Taiwan University ihwang@ntu.edu.tw September 26, 2013 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Organization of Lectures in Chapter 2 and 3 Separable DE (2-2) (2-1) (2-6) DE (2-3) Exact DE (2-4) (2-5) 王奕翔 DE Lecture 3 Linear Models (3-1) Nonlinear Models (3-2) Overview Linear Models Nonlinear Models Summary What is covered in this lecture We will learn how to model a system by first-order differential equations, solve them by the methods that we have learned, and answer the questions in which we are interested. 解應用題基本步驟: 1 寫下描述系統變化的微分方程式:定義自變數和應變數 2 用學過的方法來解寫下的微分方程式:得到描述系統特性的函數 3 解決一開始待解的問題 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Population Growth Thomas Malthus 人口論 (1798): 人口增加速率正比於人口總數。 1 couple: 1 child per 10 months. 10 couples: 10 children per 10 months. This model can also be extended to other kinds of population, for example, bacteria. Example (培養皿中的細菌數) Initially (t = 0) there are P0 number of bacteria. At time t = 1 hour, there are 2P0 number of bacteria. If the rate of growth is proportional to the total population, find the total population at time t, that is, P(t), and the time at which there are 4P0 number of bacteria. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Population Growth A: First we write down the DE and initial conditions relating P(t) and t: dP = kP, P(0) = P0 , k > 0 dt which can be solved as follows. dP = k dt, P ̸= 0 =⇒ ln |P| = kt + c 兩邊積分 P =⇒ ln P0 = c 代初始值 =⇒ P(t) = P0 ekt , t ≥ 0. To determine k, we plug in the other condition: P(1) = 2P0 = P0 ek =⇒ k = ln 2 =⇒ P(t) = P0 2t . Finally, the time it takes for the population to reach 4P0 is: log2 4 = 2 hours. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Radioactive Decay For radioactive substances, the decay rate is proportional to the dA concurrent total amount A(t). = kA, A(0) = A0 , k < 0. dt Half-life: the time it takes for 1/2 of the atoms in a initial amount to degenerate. Example: the half-life of C-14 is 5730 years. Example (碳14定年) A piece of fossil is found to contain 0.1% of the original amount of C-14. Estimate the age of the fossil given the half-life of C-14 is 5730 years. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Radioactive Decay A: We already know the function A(t): A(t)/A0 = ekt , A(0) = A0 . ln 2 Half-life = 5730 =⇒ 0.5 = exp(5730k) =⇒ k = − 5730 . Now, 0.001 = ekt =⇒ t = − ln 1000 k 王奕翔 = 5730 × 3 × log2 10 ≈ 57104. DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Growth and Decay If the growth/decay rate is proportional to the current total amount/population, we have dX = kX, X(0) = X0 dt With experience, we know immediately that X = ekt . X0 To find k, we need to plug in another condition. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Cooling I. Newton: 升(降)溫的速率與物體和周遭環境的溫差成正比 Example (Cooling of Hot Water) The initial temperature of a bottle of water is 100◦ . At t = 10 minutes, it becomes 40◦ . At t = 20 minutes, it becomes 28◦ . What is the room temperature? A: According to Newton, we have dT = k(T − Tm ), T(0) = 100, k < 0. dt We can solve it by first finding an integrating factor (exercise). Instead, here is a shortcut. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Cooling m) Observe that d(T−T = k(T − Tm ), T(0) − Tm = 100 − Tm . Hence, dt we immediately have T − Tm = ekt . 100 − Tm Plug in the two conditions 40 − Tm 28 − Tm = e10k , = e20k 100 − Tm 100 − Tm ( )2 40 − Tm 28 − Tm =⇒ = 100 − Tm 100 − Tm =⇒ Tm = 25. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 01_ch01_p01-034.qxd 2/10/12 12:53 PM Overview Linear Models Nonlinear Models Page 24 Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Mixture of Two Fluids 24 ● CHAPTER 1 INTRODUCTION TO DIFFERENTIAL EQUATIONS input rate of brine 3 gal/min Example (Mixture of Salt Mixtures The mixing of twoSolutions) salt solutions of differing concentrations gives rise to a first-order differential equation for the amount of salt contained in the mix- Inture. theLetfigure, the saltholds of the incoming us suppose thatconcentration a large mixing tank of initially 300 gallons of brineflow (that is 2 is, water Initially in which a there certain number of salt dissolved). lb/gal. is 50 oflbpounds of salt in has thebeen tank. FindAnother the brine solution is pumped into the large tank at a rate of 3 gallons per minute; the concentration ofsalt salt in inflow the tank as time t →When ∞. the solution in concentration of the in this is 2 pounds per gallon. constant 300 gal the tank is well stirred, it is pumped out at the same rate as the entering solution. See A:Figure Immediately we seethethat the final answer is 2 lb/gal. (Why?) 1.3.2. If A(t) denotes amount of salt (measured in pounds) in the tank at time t, then the rate at which A(t) changes is a net rate: We should dodAthe input calculation if we also want to know how the rate output rate (7)salt $ time. Rin total $ Rout. amount of !" # " concentrationdtchanges with Let# ! the of salt of salt atThe time t be A(t) lb. input rate R in at which salt enters the tank is the product of the inflow concentraoutput rate of brine 3 gal/min FIGURE 1.3.2 Mixing tank tion of salt and the inflow rate of fluid. Note that R in is measured in pounds per Incoming rate of salt: Rin = 2 × 3 = 6 lb/min; minute: concentration concentration) × 3 = Outgoing: Rout = (current of salt in inflow dA dt input rate of brine A 100 input rate of salt A 300 ×3 = =6− , A(0) = 50. R∴ in ! (2 lb/gal) " (3 gal/min) ! (6 lb/min). Now, since the solution is being pumped out of the tank at the same rate that it is pumped in, the number of gallons of brine in the tank at time t is a constant 300 gallons. Hence the concentration of the salt in the tank as well as in the outflow is 王奕翔 DE Lecture 3 A . 100 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Mixture of Two Fluids Solve dA A =6− , A(0) = 50. dt 100 1 Derive Auxiliary DE: Let µ(t) := the integrating factor to be found. } } { { d (µA) dA dµ A dµ dµ µ =µ +A =µ 6− +A = 6µ + − A dt dt dt 100 dt dt 100 2 Solve Auxiliary DE: 3 Solve Original DE: Plug in µ(t) = e 100 and A(0) = 50: t dµ µ = . One solution: µ(t) = e 100 . dt 100 t t −t t e 100 A = 600e 100 − 550 =⇒ A(t) = 600 − 550e 100 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 p01-034.qxd E(t) L 2/10/12 12:53 PM R LRC SeriesC Circuits (a) LRC-series (a) circuit Inductor inductance L: henries (h) di voltage drop across: L dt L R E(t) i CL (a) LRC-series (a) circuit Resistor resistance R: ohms (Ω) Inductordrop across: iR voltage inductance L: henries (h) di voltage drop across: L dt i R i L where the minus sign indic Growth and Decay the possibility of Warming friction at the that might cause aatr Cooling and thehole possibility of friction Itthat is interesting toof note that Mixtures (h) L L: henries there. Now if the tank is such the volume water Series Circuit there. Now if the tank is sui E(t) di R 2case we must express the up voltage L V(t)drop ! Aacross: h, where A (in ft ) is the constant area of thef w w V(t) ! A w h, where A w (in dt A! A(h). SeeSubstituting Problem 14 w! (see Figure 1.3.3), then dV!dt(see AFigure w dh!dt. 1.3.3), then dV! gives C us the desired differential equation the height o gives us the for desired differen Series Circuits Con i (a) LRC-series (a) circuit L ure dh 1.3.4(a),Acontaining an i ! " h AS 12gh . 1.3 DIFFERENTIAL EQUATIONS MATHEMA afterdta switch Awis closed is d Current the derivative notedisby q(t). The letters L, Inductor Resistor It is interesting to note that (10) remains validtoeven when of charge: It is interesting note that itance, respectively, and ar where the minus sign indicates that V is decreasing. Not inductanceR:L:ohms henries resistance (Ω)(h) case weacross: must express the upper surface area ofimpressed the water difriction case we must express the up second law, the voltage drop iR the possibility of at the hole that might cause a r dq voltage drop across: L iA(h). = 1.3. A Problem involtage Exercises w ! A(h). Athat drops in Problem the Fii there. Now See if thedt tank is 14 such volume of loop. water14 w ! the dtSee voltage drops acr V(t) ! A w h, where A w (in ft 2)respective is the constant area of the toSubstituting charge q(t) ii (see Series Figure 1.3.3), then Consider dV!dti(t) ! is A dh!dt. Circuits the single-loop LRC-se wrelated Series Circuits Con R =equation totalresistor, voltage drop: L the desired gives us differential for the height ure 1.3.4(a), containing anE(t) inductor, and capacit ure 1.3.4(a), containing an oi inducto after a switch is closed is denoted i(t); the charge ond 2 after aby switch is closed is d q q ARh dq +asdi =dh LCby +known Capacitor noted by q(t). The letters L,E(t) R,noted and are inducta 2 q(t). The letters L ! ! " 12gh . dt dt C L,L Resistor dtand capacitance farads (f) dt respectively, Aw itance, C:respectively, and are itance, generally constants. Nowar resistance R: ohms (Ω) 1 q voltage drop across: second law, the impressed voltage E(t) on a closed loop second law, the voltage drop across: C iR andremains equating theimpressed sum when to th It is interesting that (10) valid even voltage drops into thenote loop. Figure 1.3.4(b) shows the symb voltage drops in the loop. Fi equation case we must express the upper surface area of the water respective voltage drops across an inductor, a capacitor, respective voltage drops acra Aw ! A(h). See 14 on in Exercises 1.3. i ! dq!d ii i(t) is related to Problem charge q(t) theiscapacitor i(t) related toby charge q(t) C R Overview Inductor Linear Models Nonlinear Models Page 25 inductance Summary resistor inducto Series Circuits inductor Consider the single-loop LRC-se (b) di an inductor, d 2q 王奕翔 DE Lecture 3 ure 1.3.4(a), containing resistor, dq and di capacit and so after multiplying by the factor the equation is cast into the fo Growth and Decay Overview Linear Models Nonlinear Models Summary 250 Cooling and Warming Mixtures Series Circuit d (300 " t)2 A ! 6(300 " t)2. dt [ ] Integrating the last equation gives (300 " t) A ! 2(300 " t) Example: 50LR Series t Circuit 100 FIGURE 3.1.6 Graph of A(t) in Example 6 Example L E R FIGURE 3.1.7 LR-series circuit 2 3 " c. initial condition A(0) ! 50 and solving for A yields the solution A(t (4.95 % 10 7)(300 " t) #2. As Figure 3.1.6 shows, not unexpectedly, the tank over time, that is, A : $ as t : $. Series Circuits For a series circuit containing only a resistor Kirchhoff’s second law states that the sum of the voltage drop acr (L(di!dt)) and the voltage drop across the resistor (iR) is the same a Consider the LR circuit shown on the left, voltage (E(t)) on the circuit. See Figure 3.1.7. where E(t) = 10 the volts, = 10 ohms, L= Thus we obtain linearRdifferential equation for0.5 the current i( henry, and initial current i(0)di = 0. L " Ri ! E(t), Find i(t). dt where L and R are constants known as the inductance and the resistan The current i(t) is also called the response of the system. A: Current i(t) satisfies the following DE: L di 1 di di + Ri = E(t) =⇒ + 10i = 10 =⇒ + 20i = 20 dt 2 dt dt 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Growth and Decay Cooling and Warming Mixtures Series Circuit Example: LR Series Circuit Solve di + 20i = 20, i(0) = 0. dt 1 Derive Auxiliary DE: Let µ(t) := the integrating factor to be found. { } d (µi) di dµ dµ dµ =µ +i = 20µ {1 − i} + i = 20µ + − 20µ i dt dt dt dt dt 2 Solve Auxiliary DE: 3 dµ = 20µ. One solution: µ(t) = e20t . dt Solve Original DE: Plug in µ(t) = e20t and i(0) = 0: ∫ t e20t i − 0 = 20e20τ dτ =⇒ e20t i(t) = e20t − 1 =⇒ i(t) = 1 − e−20t 0 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Reality is not likely to be linear, usually Thomas Malthus 人口論 (1798): 人口增加速率正比於人口總數。 dP = kP dt Points that are missing: Limited resources: population ↑, competition ↑ (nonlinearity kicks in!) Emigration and immigration Death, etc. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Population Dynamics Limited resources: population ↑, competition ↑. =⇒ the constant k may vary with P ! Hence, in general the population dynamics should be governed by dP = Pf(P). dt 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Logsitic Equation dP = Pf(P). dt Intuitively, the function f(P) should be a decreasing function of P. Simplest case: f(P) = a − bP, for a, b > 0. Definition (Logistic Equation) dP = P(a − bP) dt 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Solving Logistic Equation dP = P(a − bP). dt A: We can solve this by separation of variables. Solve 1 a dP = dt, P ̸= 0, P(a − bP) b } { b/a 1/a + dP = dt =⇒ P a − bP 1 1 =⇒ ln |P| − ln |a − bP| = t + c′ a a P = ceat , why we pick 0 < P < a/b? =⇒ a − bP aceat ac = −at =⇒ P(t) = at 1 + bce e + bc Note: if P(0) = ab , P(t) = a b for all t. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Solution Curves of Logistic Equations P The solution is called Logistic Function: P(t) = 92467_03_ch03_p083-115.qxd 2/10/12 2:39 Properties of Logistic Function PM Page 97 P a 2b a b. a/b P0 t 王奕翔 The dashed l point of infle Product Rule: d 2P dt2 t 3.2 (a) a/2b (a) a/2b P0 P(t): increasing function. Population saturation: P(t) → ab as t → ∞; P(t) → 0 as t → −∞. Saddle point: P = a/b ac e−at +bc From calculu tion, but P ! ordi The dashed Pline P ! a !2b a/b shown inpossible Figure 3.2.2 0 " PTo"show a!2 point of inflection of the logistic curve. Thus, as we r Product Rule: P0 down dP at thed d 2P dPa/2b ! P &b % (a &0 bP) " P0 "!a !2 2 dt dt dt d Figure 3.2.2(a P inflection! occ We have t dx!dt ! ! kx(n 2b model for des (b) DEFrom Lecture calculus 3 ing and 2infecte recall that the points where P!dt 2 " # Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Variants of Logistic Equations dP = P(a − bP) ± h dt dP = P(a − bP) + cekP dt dP = P(a − b ln P) dt immigration or emigration 西瓜偎大邊 Gompertz DE Exercise Derive the population saturation point in each of the above models. 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Population Dynamics and Logistic Equation Chemical Reactions Chemical Reactions Chemical A and B react and produce C. 大一普化:反應速率正比於反應物濃度的乘積 Initial concentration: [A] = a, [B] = b. X(t): concentration of C at time t. To produce one unit of C we need λa unit of A and λb unit of B. Then, we have the following DE governing the rate of reaction: dX = k(a − λa X)(b − λb X). dt How to solve? Separation of variables! 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary 1 Overview 2 Linear Models Growth and Decay Cooling and Warming Mixtures Series Circuit 3 Nonlinear Models Population Dynamics and Logistic Equation Chemical Reactions 4 Summary 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Short Recap Growth and decay Series circuit Population dynamics Logistic equation Chemical reaction 王奕翔 DE Lecture 3 Overview Linear Models Nonlinear Models Summary Self-Practice Exercises 3-1: 3, 19, 27, 33, 35, 39, 43, 45 3-2: 5, 7, 9, 11, 15, 19, 21 王奕翔 DE Lecture 3