function LogisticDifference %Plots solutions to the nonlinear difference equation x_{n+1}=rx_n(1-x_n) where x=x_n and y=x_{n+1} t=100; %total number of time steps n=[0:1:t]; %sets n=0,1,2,...,t x=[0:1:t]; %Establishes matrix dimensions, will be overwritten in the for loop %Initial Condition x0=.01; %Parameter r=3.3; steadystate=(r-1)/r+n-n; %Determines x_n in an iterative manner for i=1:t+1 if i==1; x(i)=x0; else x(i)=r*x(i-1)*(1-x(i-1)); i=i+1; end end x %x1=(r+1)/(2*r)+(((r-3)*(r+1))^(1/2))/(2*r)+n-n; %x2=(r+1)/(2*r)-(((r-3)*(r+1))^(1/2))/(2*r)+n-n; %Plots solutions plot(n,x,n,steadystate) %plot(n,x,n,steadystate,n,x1,n,x2) xlabel('n') ylabel('x_n') title('Plot of x_n as a function of n')