/* ************************************************************************ * カオス:ロギスティック方程式 * i:世代数、x:個体数 * x0:初期値 * nlim:時間の最大値 * a:パラメータ ************************************************************************ */ #include #include main() { double x; double a, x0; int i, nlim; FILE *output; /* save data in logistic.dat */ output = fopen("logistic.dat","w"); printf("Input: a\n"); scanf("%lf", &a); printf("a=%g\n", a); printf("Input: x0\n"); scanf("%lf", &x0); printf("x0=%g\n", x0); printf("Input: nlim\n"); scanf("%d", &nlim); printf("nlim=%d\n", nlim); x = x0; /* initial position */ i=0; fprintf(output, "%d\t%f\n", i, x); while(i <= nlim) { i++; x=a*(1.0-x)*x; fprintf(output, "%d\t%f\n", i, x); } printf("data stored in logstic.dat\n"); fclose(output); } /*-----------------------end of main program--------------------------*/