% Some code to study Problem 3, Homework 3, Math 5110, Fall 2005 % Set values for the parameters A=1/3; alpha=1/2; gamma=2/3; % Input number of steps nsteps = 30; % Input some initial conditions (low values of both c and q) c0=0.1; q0=0.1; % Input the function for h with n=2 (to be varied by hand) h = inline('c^2/(1+c^2)','c') % Initialize vectors to save the results c=c0 q=q0 % Run a loop for i=1:(nsteps-1), c(i+1)=(1-q(i))*(c(i)+A)+q(i)*gamma; q(i+1)=alpha*q(i)+(1-alpha)*h(c(i)); end %Plot up the results as functions of time plot(1:nsteps,c,'r',1:nsteps,q,'b') %Plot up c as a function of q plot(q,c,'r') % Now you can go back and change n to see if and when the equilibrium % becomes unstable