/* This program takes an initial value of x and iterates the logistic map 2000 times. 
It returns a file where the first column is the step number and the second column is the value of x.
Juan G. Restrepo
*/


#include <stdio.h>
#include <math.h>
#include <stdlib.h>  //load some libraries


int main()          //main program
{

//*************** FILES TO WRITE *****************
FILE * file1;
file1 = fopen("file1.txt","w");
//_______________________________________


//*************** DEFINE VARIABLES ******
int i;       //integer counter
double x,t;    //double-precision variable, time
double r = 3.6;   //logistic map parameter
int nsteps = 2000;  //number of steps
//_______________________________________

x = 0.25;         //initial conditions: this is x(0)

for(i = 0; i < nsteps; i++)           //start loop 
	{
	x = r*x*(1.0-x);                  //logistic map iteration
	fprintf(file1,"\n %d %f", i, x);  //print to file for plotting
    }							      //end loop


printf("t = %d y = %.12f\n",i,x);   //print final value

fclose(file1); //close file

return(0);
}


