#include <stdio.h>


int main () {
  double x, y;
  double a;
  int i, N, trans;
  FILE *gp;
  
  N = 10000;
  trans = 9900;
  gp = fopen("logistic.dat", "w");
  for (a=0; a<=4; a+= 0.005) {
    x = 0.342567;
    for (i=0; i<N; i++) {
      y = a * x * (1-x);
      x = y;
      if (i> trans) {
        fprintf(gp, "%f %f\n", a, y);
      }
    }
  }
  fclose(gp);
  gp = popen("gnuplot", "w");
  fprintf(gp, "plot 'logistic.dat' w d\n");
  fflush(gp);
  getchar();
  fclose(gp);
}