> #OK to post #Timothy Nasralla, RUID: 192005950 Homework 8, October 4 2021 #For > question #1 we were expected to provide the first 1000 terms of a function. > #For first order non-linear recurrence equations, the below function works. > Recc:=proc(f,x,xold,K1,K2) local xnew,i,L: xnew := xold: for i from 1 to K1 do > xnew:=subs(x=xnew,f): #we don't record the first values of K1, since we are > interested in the long-time behavior of the orbit od: L:=[xold]: for i from K1 > to K2 do xnew:=subs(x=xnew,f): #we compute the next member of the orbit > L:=[op(L),xnew]: #we append it to the list od: L: #that's the output end: > evalf(Recc(((1+9*x)/(2+x)),x,1,1,1000)) [1., 5.812500000, 6.824000000, 7.073436083, 7.126398881, 7.137271861, 7.139488432, 7.139939656, 7.140031484, 7.140050170, [...981 terms...], 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945, 7.140054945] > > #Based on these numbers,the stable steady state solution is 7.14 > approximately. Based on f(x) = x, the x is 7.14 or -0.14 which are the two > steady state solutions. However, when using both for the absolute value of > (f'(x) <1, we see that 7.14 is the only stable solution. > #Question 2, find the first 1000 terms of the orbit where x0 = .5 and x(n) = > k*x(n-1) * (1-x(n-1)). > evalf(Recc((x*(1-x)),x,0.5,1,1000)) [0.5, 0.1875, 0.15234375, 0.1291351318, 0.1124592495, 0.09981216670, 0.08984969808, 0.08177672983, 0.07508929629, 0.06945089387, [...981 terms...], 0.0009993245315, 0.0009983258820, 0.0009973292274, 0.0009963345618, 0.0009953418792, 0.0009943511737, 0.0009933624394, 0.0009923756705, 0.0009913908610, 0.0009904080051] > evalf(Recc(2*x*(1 - x), x, 0.5, 1, 1000)); [0.5, 0.5000, 0.50000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, [...981 terms...], 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000, 0.5000000000] > evalf(Recc(2.5*x*(1 - x), x, 0.5, 1, 1000)); [0.5, 0.5859375, 0.6065368652, 0.5966247410, 0.6016591485, 0.5991635438, 0.6004164790, 0.5997913268, 0.6001042278, 0.5999478590, [...981 terms...], 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000, 0.6000000000] > evalf(Recc(3.1*x*(1 - x), x, 0.5, 1, 1000)); [0.5, 0.5405625, 0.7698995192, 0.5491781734, 0.7675026726, 0.5531711926, 0.7662357553, 0.5552674201, 0.7655310881, 0.5564290480, [...981 terms...], 0.5580141245, 0.7645665203, 0.5580141245, 0.7645665203, 0.5580141245, 0.7645665203, 0.5580141245, 0.7645665203, 0.5580141245, 0.7645665203] > evalf(Recc(3.5*x*(1 - x), x, 0.5, 1, 1000)); [0.5, 0.3828125, 0.8269348143, 0.5008976952, 0.8749971794, 0.3828199039, 0.8269408878, 0.5008837956, 0.8749972662, 0.3828196760, [...981 terms...], 0.5008842111, 0.8749972637, 0.3828196827, 0.8269407062, 0.5008842111, 0.8749972637, 0.3828196827, 0.8269407062, 0.5008842111, 0.8749972637] > #I notice that the number of fixed points increases. The first recurrence, > where k=1 had 1 fixed point at near 0. The 2nd, at k=2 had 1 fixed point where > k = .5. When k=2.5, the fixed point was .6. When k = 3.1 however, there were > two fixed points, .558 and .768, which the terms towards the end alternated > between. And when k = 3.5, the fixed points alternated between .827, .500, and > .383. > #Question 3: x(n) = (x(n-1) + 2*x(n-2))/(x(n-1) + 9*x(n-2)), x(0) = 0.5 x(1) = > 0.7 > #For second order nonlinear equations, the below function will evaluate it. To > input the function, one must use x(n-1) as x and x(n-2) as xf. > TwoRecc:=proc(f,x,xf,xold,xoldest,K1,K2) local xnewer,xnew,i,L: xnewer := > xold: xnew := xoldest: for i from 1 to K1 do xnew := xnewer: > xnewer:=subs(x=xnewer,xf=xnew,f): #we don't record the first values of K1, > since we are interested in the long-time behavior of the orbit od: > L:=[xoldest, xold]: for i from K1 to K2 do xnewer:=subs(x=xnewer,xf =xnew,f): > #we compute the next member of the orbit L:=[op(L),xnewer]: #we append it to > the list od: L: #that's the output end: > TwoRecc((x + 2*xf)/(x + 9*xf), x, xf, 0.7, 0.5, 3, 1000) [0.5, 0.7, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000, 0.3000000000] > #There seemingly is a steady state value where x = 0.30