Cmputatinal mdeling techniques Lecture 2: Mdeling change. In Petre Department f IT, Åb Akademi http://users.ab.fi/ipetre/cmpmd/
Cntent f the lecture Basic paradigm f mdeling change Examples Linear dynamical systems analytic slutin Affine dynamical systems analytic slutin Equilibrium pints, types f equilibrium pssibly strange behavir fr nnlinear dynamical systems Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 2
Mdeling change Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 3
Mdeling change Basic paradigm: Future value = present value + change Change = future value present value Discrete time difference equatin change takes place in discrete time intervals (e.g., the depsiting f interest in an accunt) in this lecture Cntinuus time differential equatin change takes place cntinuusly (e.g., the psitin f a mving car) in a later lecture in this curse Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 4
Mdeling change with difference equatins Fr a sequence f numbers a 1,a 2,,a n, their differences are: a 0 =a 1 -a 0 a 1 =a 2 -a 1 a 2 =a 3 -a 2 a n =a n+1 -a n Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Figure 1.5, page 4 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 5
A few examples Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 6
Example: savings depsit A savings depsit A savings depsit initially wrth 1000 eur Interest rate f 1% per mnth Calculate the value grwth f the certificate Dente by a n the value f the depsit n mnths after the first depsit a 0 =1000 The value at time n+1 as a functin f the value at time n: a n =a n+1 -a n =0.01a n a n+1 =1.01a n, fr all n 0 Slutin: a n =a 0 1.01 n Nte We have an infinite set f algebraic equatins This is called a (discrete) dynamical system The change may depend n several previus terms and/r external terms Hw abut if yu withdraw 50 eur each mnth? a n+1 -a n =0.01a n -50 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 7
Example: mrtgage Mrtgaging a hme Get a mrtgage f 80.000 eur with an interest rate f 1% per mnth Mnthly payment: 880.87 eur Questin 1: after n payments, hw much is there still t pay? Questin 2: hw lng des it take t pay the whle mrtgage? Dente by b n the value f the lan after n payments b 0 =80.000 b n+1 -b n =0.01b n -880.87; in ther wrds, b n+1 =1.01b n -880.87 What is the smallest n such that b n 0 Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Figure 1.6, page 6 8
Example: grwth f a yeast culture We are given data n the grwth f a yeast culture Measurements n the size f the culture at varius time pints Prblem: prpse a mdel fr the grwth Idea: lk at the change with respect t the ppulatin size Observe that the change can be apprximated as a straight line Measure the slpe f the line: 0.5 Prpsed mdel: p n =p n+1 -p n =0.5p n Slutin: p n+1 =1.5p n, Gd mdel fr the little data we have The mdel predicts infinite grwth; unlikely t hld against mre data Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Figure 1.7, page 10 9
Get mre data n the yeast culture; plt the change per hur against the ppulatin size at the time Nte The culture levels ut at abut 665 units Grwth rate slws dwn t almst 0 as the ppulatin appraches the max value Old mdel: p n+1 -p n =kp n New mdel: replace the cnstant k with a simple functin that appraches 0 as p n appraches the max value New mdel: Example (cntinued) Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Figure 1.8, page 11 p n+1 -p n =r(665-p n )p n Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 10
Example (cntinued) New mdel: p n+1 -p n =r(665-p n )p n Hw d we test if the mdel makes sense? Cmpare the differences p n+1 -p n and (665-p n )p n Check if there is a reasnable prprtinality Answer: YES! r=0.00082 Final mdel: p n+1 =p n +0.00082(665-p n )p n Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Figure 1.9, page 11 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 11
Example (cntinued) Final mdel: p n+1 =p n +0.00082(665-p n )p n Test the mdel Result: very gd fit Cmment: discuss later hw t measure the gdness f a fit; fr nw nly thrugh visual inspectin Girdan et al. A first curse in mathematical mdeling. 2003 Figure 1.10, page 12 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 12
Linear dynamical systems: a n+1 =ra n Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 13
Slutins t linear dynamical systems Linear dynamical systems: a n+1 =ra n, fr sme cnstant r By inductin: the slutin is a n =r n a 0 r=a 1 /a 0 14
Linear dynamical systems: a n =r n a 0 r=0, 1, -1 3,5 r=1 3,5 3 2,5 2 r=0 3 2,5 2 1,5 1 0,5 0 1,5 1 0,5 0 4 3 2 1 0-1 -2-3 r=-1-4
300 r=1,25 Linear dynamical systems: a n =r n a 0 r>1, r<-1 250 200 150 100 50 0 300 r=-1,25 200 100 0-100 -200-300 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 16
4,5 4 3,5 3 2,5 2 1,5 1 r=0,8 Linear dynamical systems: a n =r n a 0-1<r<1 0,5 0 6 5 4 3 2 1 0-1 -2-3 -4-5 r=-0,8 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 17
Affine dynamical systems :a n+1 =ra n +b Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 21
Example Example: prescriptin fr digxin (treatment f sme heart cnditins) Prblem: Prescribe an amunt that keeps the cncentratin f digxin in the bldstream abve an effective level, withut exceeding a safe level (variatin here amng patients) Several questins t settle what is the decay f a single dse at what intervals t give the cnsecutive dses (nt cnsidered in this example) what dses t give Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 22
Example (cntinued) First questin: what is the decay f a single dse? Give a single dse and measure the amunt f digxin remaining in the bldstream after n days n 0 1 2 3 4 5 6 7 8 a n 0.500 0.345 0.238 0.164 0.113 0.078 0.054 0.037 0.026 a n -0.155-0.107-0.074-0.051-0.035-0.024-0.017-0.011 Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Table 1.2, page 13 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 23
Example (cntinued) Plt a n against a n Cnclusin: a n+1 -a n =-0.5 a n a n+1 = 0.5 a n Girdan et al. A first curse in mathematical mdeling. (3 rd editin) Fig. 1.11, page 14 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 24
Example (cntinued) Secnd part: additinal dses We add daily a dsage f 0.1 Mdel: a n+1 = 0.5 a n +0.1 Initial value a 0 : might be different than the subsequent dses a 0 =0.1 (series A) a 0 =0.2 (series B) a 0 =0.3 (series C) 0,35 0,3 0,25 0,2 0,15 0,1 0,05 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A B C Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 25
Analytic slutins f affine dynamical systems Affine dynamical systems a n+1 =ra n +b, fr sme cnstants r, b with r 1 Analytic slutin: a n =r n c+b/(1-r), where c=a 0 -b/(1-r) a n =ra n-1 +b a n+1 -a n =r(a n -a n-1 ) Let x n =a n+1 -a n, x 0 =a 1 -a 0 =ra 0 +b-a 0 =(r-1)a 0 +b Then x n =rx n-1, i.e., x n =r n x 0 S a k+1 -a k =r k x 0. Sum this relatin frm k=0 t n-1: a n -a 0 =x 0 (1-r n )/(1-r)= -r n x 0 /(1-r)+x 0 /(1-r) Replace x 0 /(1-r)=-a 0 +b/(1-r) a n -a 0 =r n c-a 0 +b/(1-r), where c=a 0 -b/(1-r) a n =r n c+b/(1-r) Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 26
Equilibrium pints Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 27
Equilibrium Cnsider a dynamical system a n+1 =f(a n ) A number a is called an equilibrium pint (r a fixed pint) f the dynamical system if a=f(a) In ther wrds, if we start with initial value a 0 =a, then a n =a, fr all n 0 Imprtant t identify the equilibrium pints f a dynamical system (and their prperties) t knw abut its asympttic behavir Example. Linear dynamical systems: a n+1 =ra n, r 0 Lk fr equilibrium pints: slve the equatin x=rx, i.e., (1-r)x=0 If r 1, then 0 is the nly equilibrium pint If r=1, then all numbers are equilibrium pints Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 28
Types f equilibrium Types f equilibrium pints (infrmal definitins) Stable: starting frm a nearby initial pint will give an rbit that remains nearby the riginal rbit Asympttically stable (attractr): starting frm a nearby initial pint will give an rbit that cnverges twards the riginal rbit Example: a pendulum in the lwest psitin Unstable: starting frm a nearby initial pint may give an rbit that ges away frm the riginal rbit Example: a pendulum in the highest psitin Stable-unstable equilibrium Surce fr picture: Wikipedia Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 29
Types f equilibrium pints Affine dynamical systems; a n+1 =ra n +b, r 0 Lk fr equilibrium pints: slve the equatin x=rx+b, i.e., (1-r)x=b If r 1, then b/(1-r) is the nly equilibrium pint If r=1 and b=0, then all numbers are equilibrium pints If r=1 and b 0, then the dynamical system has n equilibrium pint Assume r 1. What kind f equilibrium pint is b/(1-r)? (asympttically) stable, unstable? Recall that a n =r n c+b/(1-r), where c=a 0 -b/(1-r) r <1: b/(1-r) is asympttically stable r >1: b/(1-r) is unstable r=-1: b/2 is stable tw cnstant subsequences (the dd and the even terms) n either side f the equilibrium Depending n the value f a 0, the tw subsequences can be clse t b/2 Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 30
Nnlinear systems a n+1 =f(a n ), where f is a nn-linear functin Example: a n+1 =r(1-a n )a n, that came up earlier in this lecture The system can have very different behavir depending n r Als called the lgistic map Typical example fr hw chatic behavir can rise frm very simple (nn-linear) dynamics Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 31
Bifurcatin diagram fr a n+1 =r(1-a n )a n. Fr each r the diagram shws the perid p f the dynamical system and the attractrs f its p cnvergent subsequences a np+i, with i=0,1,,p-1 Perid dubles as r increases Eventually it leads t chas Picture frm Wikipedia: http://en.wikipedia.rg/wiki/lgistic_map 33
Learning bjectives Understand the cncept f mdeling the change in a discrete dynamical systems Able t write a linear and an affine mdel with difference equatins fr a simple real-life phenmenna Understand the diverse behavir that a linear dynamical system mdel can have Understand the ntin f equilibrium pint Understand the different types f stability f equilibrium pints Cmputatinal Mdeling Techniques http://users.ab.fi/ipetre/cmpmd/ 35