/* * logistic map * * just calculate x vs n * * by N Giordano -- July 2006 * * usage: logistic mu [x_0] [n_max] * * mu = the value of the control parameter (required) - value should be between 0 and 4 * x_0 = initial value of x (optional) * n_max = number of iterations (optional) * * results are written to standard output */ #include #include double atof(); double mu; double x; int n_max; main(argc,argv) int argc; char* argv[]; { int seed; int i; /* get parameter values and initialize variables */ if(argc <=1) { fprintf(stderr,"usage map mu [x_0] [n_max]\n"); exit(0); } mu = atof(argv[1]); if(argc >= 3) { x = atof(argv[2]); } else { x = 0.314159; } if(argc >= 4) { n_max = atoi(argv[3]); } else { n_max = 100; } /* do the actual calculation here */ for(i = 1; i < n_max; i++) { printf("%d\t%g\n",i,x); x = mu * x * (1.0 - x); } }