-
-
Save bemasher/660081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* LOGISTIC EQUATION */ | |
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
FILE *fp; | |
int i; | |
int k; | |
double r = 2.5; | |
double xp[20000]; | |
double x0[20000]; | |
double xmin[50]; | |
double xmax[50]; | |
fp = fopen("lynopinof.txt", "w"); | |
/* Initial condition */ | |
xp[0] = 0.501; | |
x0[0] = 0.5; | |
i = 0; | |
k = 1; | |
/* Program -------------------------------------- */ | |
while ( r<= 3) { | |
while (k< 20) { | |
for (i=0; i< 1500; i++) { | |
x0[i+1] = r * x0[i] * (1.0 - x0[i]); | |
xp[i+1] = r * xp[i] * (1.0 - xp[i]); | |
if (i> 500) { | |
if (fabs(xp[i] - x0[i]) > fabs(xp[i-1] - x0[i-1]) && fabs(xp[i-1] - xp[i-1]) < fabs(xp[i-2] - xp[i-2])) { | |
xmin[k] = fabs(xp[i-1] - x0[i-1]); | |
while (fabs(xp[i] - x0[i]) > fabs(xp[i-1] - x0[i-1])) { | |
i++; | |
} | |
xmax[k] = fabs(xp[i-1] - x0[i-1]); | |
fprintf(fp,"%6.31f %6.3lf %6.3lf %6.3lf\n", r, k, xmin[k], xmax[k]); | |
} | |
} | |
} | |
k++; | |
} | |
r=r+.02; | |
} | |
fclose(fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment