> #OK to post > #Timothy Nasralla, HW18, 11/08/21 > #Question 1: Make a function that calculates the number of eggs made by a > certain amount of chickens in an amount of days > C:= proc(a,b,c,d,e) local dayrate, layrate: layrate := b/a: dayrate := > layrate/c: d*e*layrate*dayrate; end: 6 > #Question 2: Similarly make a #function to calculate cistern speed. > W := proc(a,b,k) local cisa, cisb, cisc, first, secnd, new1st, ans,final: > first := cisa + cisb: secnd := cisa + cisc: new1st := subs(cisb=k*cisc,first): > ans := solve(new1st-secnd=1/a-1/b,cisc): final := 1/ans; end: > W(4,5,2) 20 > > #Question 3, test eigenvalues. > with(LinearAlgebra): > J := Matrix(2,2): J[1,1] :=diff(x-x^2-y*x,x): J[1,2] :=diff(x-x^2-y*x,y): > J[2,1] :=diff(3*x-2*x^2-y*x,x): J[2,2] :=diff(3*x-2*x^2-y*x,y): > Jeigen2 := subs(x=0, y=1, J) > Eigenvalues(Jeigen2) > Jeigen2 := subs(x=0, y=.9, J) > Eigenvalues(Jeigen2) > Jeigen2 := subs(x=0, y=1.1, J) > Eigenvalues(Jeigen2) > Jeigen1 := subs(x=2, y=-1, J) > Eigenvalues(Jeigen1) > read "/Users/tan88/OneDrive - Rutgers University/M18.txt" > #Question 4, Use the Dis2 function to confirm your answers. > Dis2([x*(1-x-y),x*(3-2*x-y)],x,y,[0.1,1],0.01,10) [[0.01, [0.1, 1]], [0.02, [0.0999, 1.0018]], [0.03, [0.0997984017, 1.003596602]], [0.04, [0.09969521514, 1.005389786]], [0.05, [0.09959045042, 1.007179534]], [0.06, [0.09948411771, 1.008965828]], [0.07, [0.09937622724, 1.010748649]], [0.08, [0.09926678929, 1.012527979]], [0.09, [0.09915581421, 1.014303801]], [0.10, [0.09904331240, 1.016076097]], [...981 terms...], [9.92, [0.001568728273, 1.500496290]], [9.93, [0.001560852237, 1.500519764]], [9.94, [0.001553015500, 1.500543120]], [9.95, [0.001545217869, 1.500566359]], [9.96, [0.001537459151, 1.500589481]], [9.97, [0.001529739154, 1.500612487]], [9.98, [0.001522057688, 1.500635377]], [9.99, [0.001514414562, 1.500658152]], [10.00, [0.001506809588, 1.500680812]], [10.01, [0.001499242577, 1.500703358]] ] > Digits := 10: Dis2([x*(1-x-y),x*(3-2*x-y)],x,y,[2.1,-0.9],0.01,10) [[0.01, [2.1, -0.9]], [0.02, [2.0958, -0.9063]], [0.03, [2.091828459, -0.9122793174]], [0.04, [2.088072599, -0.9179560713]], [0.05, [2.084520442, -0.9233472477]], [0.06, [2.081160754, -0.9284687818]], [0.07, [2.077982989, -0.9333356330]], [0.08, [2.074977242, -0.9379618537]], [0.09, [2.072134204, -0.9423606525]], [0.10, [2.069445122, -0.9465444522]], [...981 terms...], [9.92, [-Float(infinity), -Float(infinity)]], [9.93, [-Float(infinity), -Float(infinity)]], [9.94, [-Float(infinity), -Float(infinity)]], [9.95, [-Float(infinity), -Float(infinity)]], [9.96, [-Float(infinity), -Float(infinity)]], [9.97, [-Float(infinity), -Float(infinity)]], [9.98, [-Float(infinity), -Float(infinity)]], [9.99, [-Float(infinity), -Float(infinity)]], [10.00, [-Float(infinity), -Float(infinity)]], [10.01, [-Float(infinity), -Float(infinity)]]] > #As shown above, neither fixed point is stable. > > #Question 5, use the SIRS function and the Dis2 function to see how many > people get infected and to predict the future of an epidemic > Dis2(SIRS(s,i,0.01,0.5,1,50),s,i,[20,30],0.01,10) [[0.01, [20, 30]], [0.02, [19.9400, 29.7600]], [0.03, [19.88215856, 29.52174144]], [0.04, [19.82644347, 29.28521962]], [0.05, [19.77282297, 29.05042960]], [0.06, [19.72126581, 28.81736620]], [0.07, [19.67174116, 28.58602403]], [0.08, [19.62421864, 28.35639748]], [0.09, [19.57866835, 28.12848072]], [0.10, [19.53506079, 27.90226773]], [...981 terms...], [9.92, [49.00307656, 0.06463958648]], [9.93, [49.00742123, 0.06430994448]], [9.94, [49.01174740, 0.06398201149]], [9.95, [49.01605516, 0.06365577840]], [9.96, [49.02034458, 0.06333123613]], [9.97, [49.02461575, 0.06300837567]], [9.98, [49.02886873, 0.06268718805]], [9.99, [49.03310360, 0.06236766436]], [10.00, [49.03732043, 0.06204979573]], [10.01, [49.04151930, 0.06173357334]]] > Dis2(SIRS(s,i,0.01,0.5,1,80),s,i,[50,30],0.01,10) [[0.01, [50, 30]], [0.02, [49.8500, 29.8500]], [0.03, [49.70269775, 29.70030225]], [0.04, [49.55806424, 29.55091774]], [0.05, [49.41607070, 29.40185719]], [0.06, [49.27668863, 29.25313105]], [0.07, [49.13988979, 29.10474948]], [0.08, [49.00564617, 28.95672241]], [0.09, [48.87393004, 28.80905948]], [0.10, [48.74471389, 28.66177009]], [...981 terms...], [9.92, [76.21321414, 0.7097521083]], [9.93, [76.22319006, 0.7080638361]], [9.94, [76.23313670, 0.7063802861]], [9.95, [76.24305416, 0.7047014417]], [9.96, [76.25294252, 0.7030272863]], [9.97, [76.26280188, 0.7013578033]], [9.98, [76.27263233, 0.6996929764]], [9.99, [76.28243397, 0.6980327891]], [10.00, [76.29220688, 0.6963772252]], [10.01, [76.30195114, 0.6947262684]]] > Dis2(SIRS(s,i,0.01,0.5,1,120),s,i,[90,30],0.01,10) [[0.01, [90, 30]], [0.02, [89.7300, 29.9700]], [0.03, [89.46257919, 29.93922081]], [0.04, [89.19772620, 29.90767259]], [0.05, [88.93542957, 29.87536550]], [0.06, [88.67567774, 29.84230969]], [0.07, [88.41845910, 29.80851529]], [0.08, [88.16376192, 29.77399244]], [0.09, [87.91157443, 29.73875124]], [0.10, [87.66188476, 29.70280177]], [...981 terms...], [9.92, [97.91473117, 6.738654322]], [9.93, [97.92548289, 6.737249132]], [9.94, [97.93619439, 6.735851478]], [9.95, [97.94686579, 6.734461329]], [9.96, [97.95749721, 6.733078654]], [9.97, [97.96808878, 6.731703420]], [9.98, [97.97864061, 6.730335598]], [9.99, [97.98915282, 6.728975155]], [10.00, [97.99962552, 6.727622060]], [10.01, [98.01005884, 6.726276283]]] > #In the long run, 6 individiuals would be infected still.