Ordinary Differential Equations
Total Page:16
File Type:pdf, Size:1020Kb
Ordinary Di↵erential Equations Macroeconomic Analysis Recitation 1 Yang Jiao⇤ 1 Introduction We will cover some basics of ordinary di↵erential equations (ODE). Within this class, we deal with di↵erential equations, whose variable of interest takes derivative with respect to ˙ dYt time t.DenoteYt = dt ,whereYt can be a scalar or vector. A general explicit form of ODE is Y˙t = f(Yt,t)(1) 2 First-Order Di↵erential Equations Autonomous equation:y ˙t = f(yt), an equation is autonomous when it depends on • ↵ time only through the variable itself. Example: kt = skt δkt,wheres, ↵ and δ are constants. − c˙t Linear equation:y ˙t = atyt + bt,whereat and bt are taken as given. Example: = • ct 1 (r ⇢), where γ and ⇢ are parameters, while r is a given function of t. γ t − t Homogeneous: set the above linear di↵erential equation b =0.Thisterminologyalso • t applies to high-order di↵erential equations: e.g.y ¨t = gty˙t + htyt. Autonomous equation can be solved (illustrated) graphically, while linear equation admits analytical solution. 2.1 Analytical Solution A homogeneous di↵erential equation y˙t = atyt (2) Divide both sides by yt, y˙t = at (3) yt ⇤Please email me if you find errors or typos to [email protected]. All comments and suggestions are welcome and appreciated. 1 dlog(y ) t = a (4) ) dt t Therefore, t yt = C exp( asds)(5) Z0 where C is determined by boundary condition. A linear di↵erential equation y˙t = atyt + bt (6) Rearrange the above equation as y˙ a y = b (7) t − t t t Multiply both sides by exp( t a ds), we obtain − 0 s t R t t y˙ exp( a ds) a y exp( a ds)=b exp( a ds)(8) t − s − t t − s t − s Z0 Z0 Z0 That is t t d[yt exp( asds)] − 0 = b exp( a ds)(9) dt t − s R Z0 t t u y =exp( a ds)( b exp( a ds)du + C)(10) ) t s u − s Z0 Z0 Z0 where C is pinned down by boundary condition. Example k˙ = sk↵ δk (11) t t − t 1 ↵ Define zt = kt − ,then ↵ z˙ =(1 ↵)k− k˙ (12) t − t t Substitute k˙t,kt byz ˙t,zt,wearriveat z˙ = s(1 ↵) δ(1 ↵)z (13) t − − − t Let at = δ(1 ↵)andbt = s(1 ↵), and use the solution we already get in the linear di↵erential− equation.− − s s z = +(z )exp[ δ(1 ↵)t](14) t δ 0 − δ − − s 1 ↵ s 1 k = +(k − )exp[ δ(1 ↵)t] 1 ↵ (15) ) t {δ 0 − δ − − } − 2 2.2 Graphical Solution An autonomous equation y˙t = f(yt)(16) Solution Steps: Plot f(y)inthespaceof(y, y˙). Put y on the x-axis andy ˙ on the y-axis. • Draw rightward arrows when f>0, and leftward arrows when f<0. • Given an initial point, follow the arrows to track the dynamics of y. • Equilibrium and Stability: Wheny ˙t =0,wehavef(y) = 0. The solutions to f(yt) = 0 are equilibrium points. An equilibrium point y⇤ is said to be stable if f 0(y⇤) < 0 (or equivelently, write it as @y˙ < 0). Intuitively, the arrows around the equilibrium point @y|y⇤ direct to the stable equilibrium point. Or roughly speaking, after a small perturbation, yt will finally go back to the equilibrium point. Examples: b @y˙ y˙ = ay + b,wherea<0. The equilibrium point is y⇤ = .Since = a<0, this • t t − a @y|y⇤ equilibrium point is stable. See Figure 1. (Figures are on the last two pages.) b @y˙ y˙t = ayt + b,wherea>0. The equilibrium point is y⇤ = a .Since@y y⇤ = a>0, this • equilibrium point is unstable. See Figure 2. − | ˙ ↵ Go back to our old friend, kt = skt δkt,with0<↵<1. We have two equilibrium • s 1 @k−˙ @k˙ points: k⇤ =( ) 1 ↵ , k⇤⇤ =0.Then = δ(↵ 1) < 0and =+ .Therefore, δ − @k|k⇤ − @k|k⇤⇤+ 1 k⇤ is stable and k⇤⇤ is unstable. See Figure 3. 2.3 Linearization Suppose we are interested in the dynamics around the equilibrium y⇤. y˙ = f(y ) f(y⇤)+f 0(y⇤)(y y⇤)=f 0(y⇤)(y y⇤)(17) t t ⇡ t − t − Applying it to the above k˙ = sk↵ δk ,weobtain t t − t ↵ 1 k˙ =(↵sk⇤ − δ)(k k⇤)(18) t − t − 3 Systems of Di↵erential Equations 3.1 Analytical Solution Consider the linear system of di↵erential equation Y˙t = AtYt + Bt with At = A, Bt =0. A is a n n matrix with constant elements. ⇥ 3 AsimplecaseiswhenA has n linearly independent eigenvectors v1,v2....vn,withcorre- 1 sponding eigenvalues λ1,λ2,...,λn.ItisequivalenttosayA is diagonalizable D = P − AP , where the diagonal elements of D are λ1,λ2,...,λn and the columns of P are v1,v2....vn. 1 Y˙t = AYt = PDP− Yt (19) 1 1 1 P − Y˙ = P − AY = DP − Y (20) ) t t t 1 Denote Zt = P − Yt,wehave Z˙t = DZt (21) z˙ = λ z ,i=1, 2,...,n (22) ) it i it z = c exp(λ t),i=1, 2,...,n (23) ) it i i Given Zt,weimmediatelygetYt = PZt. One can follow the same steps above to show that Y˙t = AYt + Bt has analytical solution as well. Remark 1. If A is not diagnonalizable (for example, in a two-dimension case, we may only have one linearly independent eigenvector), we can use another decomposition 1 1 T = U − AU,whereT is an upper triangular matrix. Denote Wt = U − Yt,wehaveW˙ t = 1 TWt + U − Bt,thensolvewit by the order of wnt,wn 1,t,...,w1t,wherewit is the ith element − of Wt. Remark 2. It is possible that eigenvalues are complex numbers, and eigenvectors are complex vectors thus we obtain complex solutions. However, we want real solutions instead of complex solutions. Apply the following observation: if pt + iqt is a solution to Y˙t = AYt (p iq should also be a solution), where p and q are real vectors, then p and q are also t − t t t t t the solutions. This is because Y˙t =˙pt + iq˙t = A(pt + iqt)=Apt + iAqt,thenwearriveat p˙t = Apt andq ˙t = Aqt. 3.2 Graphical Solution (Phase Diagram) Here we focus on two dimensions of system of di↵erential equations. That is we have two variables y1 and y2 of interest. y˙1t = f(y1t,y2t)(24) y˙2t = g(y1t,y2t)(25) Solution Steps: In the space (y ,y ), draw the lines ofy ˙ =0andy ˙ =0respectively.Orequivalently • 1 2 1t 2t to say, draw both f(y1,y2)=0andg(y1,y2)=0 Draw rightward arrows wheny ˙ > 0, and leftward arrows wheny ˙ < 0 • 1t 1t Draw upward arrows wheny ˙ > 0, and downward arrows wheny ˙ < 0 • 2t 2t The intersections ofy ˙1t =0andy ˙2t =0areequilibriumpoints.Thesepointscanbe • stable, unstable or saddle path stable. 4 Given an initial point, follow the direction of arrows to track the dynamics of (y ,y ) • 1t 2t Remark. In macroeconomics,we usually have initial values of state varibles (instead of all the varibles) and a transversality condition to uniquely determine the initial point and thus the whole dynamics. For example, given y10 ( y1t is a state variable), we will pick up y20 (y2t is a control variable). After picking up y20, we follow arrows and we need to ensure that we will reach an equilibrium point which satisfies the transversality condition. Example 1 Consider the following system of di↵erential equations of ct and kt. k˙ = k↵ δk c (26) t t − t − t 1 ↵ 1 c˙ = (↵k − δ ⇢)c (27) t γ t − − t Boundary condition: initial state k0 and transversality condition limt + λtkt =0.Youwill ! 1 see what transversality condition is in class, and it basically guarantees that the economy will not explode or converge to a non-sense point (no-ponzi scheme). Note we will have a unique saddle path. See Figure 4. Example 2 Now we turn to a two dimension linear case Y˙t = AYt,whereYt =(y1t,y2t)0 and A is a 2 by 2 matrix with constant elements. We first write out the analytical solutions (see the above Section 3.1 for how to solve it.). Suppose the eigenvalues of matrix A are λ1 and λ2. If λ1 = λ2 and the two linearly independent eigenvectors are v1,v2,thesolutionisof • the form:6 λ1t λ2t Yt = C1v1e + C2v2e (28) If λ = λ (must be a real number) and we have two linearly independent eigenvectors • 1 2 v1,v2 ,thesolutionisoftheform: λ1t λ1t Yt = C1v1e + C2v2e (29) If λ = λ (must be a real number) and we only have one linearly independent eigen- • 1 2 vector v1,thesolutionisoftheform: λ1t λ1t λ1t Yt = C1v1e + C2(v1te + v2e )(30) where v is the solution of (A λ I)v = v 2 − 1 2 1 Constants C1 and C2 are determined by boundary conditions. Eigenvalues and Stability (Example 2) If the eigenvalues are both positive real numbers, the equilibrium is unstable. See • Figure 5. If the eigenvalues are both negative real numbers, the equilibrium is stable. See Figure • 6. 5 If the real parts of the eigenvalues are of opposite sign (it also implies that there is • no complex part), the equilibrium is saddle path stable. Note this case is of special interest in this class. See Figure 7. If the eigenvalues are both complex numbers and the real parts are both positive, the • system is unstable and oscillating. See Figure 8. If the eigenvalues are both complex numbers and the real parts are both negative, the • system converges to the steady state in an oscillating manner.