-
Notifications
You must be signed in to change notification settings - Fork 0
/
henon.c
83 lines (67 loc) · 1.13 KB
/
henon.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include <math.h>
const int l=100;
const int N=10033;
const int xmax=10;
const double eps=1e-5;
int Nper(double lambda, double be)
{
double x[N],newx[33];
int h,Nl,p,f,num;
x[0]=0.02;
x[1]=0.04;
Nl=10000;
for(h=2;h<N;h++) { //iterate 10033
if(x[h]>xmax) {
return 0;
}
else {
x[h]=1-(lambda*pow(x[h-1],2))-(be*x[h-2]);
}
}
for(p=Nl;p<=N;p++) {
num=0;
newx[num]=x[p];
num++;
}
for(f=1;f<33;f++) {
if(abs(newx[f]-newx[0])<eps) {
return f;
}
else {
return 33;
}
}
}
int main()
{
FILE *F;
double lam[l],b[l],db,dlam;
int i,k,j,period[l][l];
lam[0]=0;
lam[l-1]=2.0;
b[0]=-0.5;
b[l-1]=0.5;
dlam=fabs((lam[l-1]-lam[0])/l);
db=fabs((b[l-1]-b[0])/l);
for(i=0;i<l;i++) {
lam[i]=lam[0]+i*dlam;
b[i]=b[0]+i*db;
}
F=fopen("henon_c.txt","w+");
if(F==NULL) {
printf("\nError");
}
else {
for(k=0;k<l;k++) {
for(j=0;j<l;j++) {
period[k][j]=Nper(lam[k],b[j]);
printf(F,"%2i ",period[k][j]);
}
printf("\n");
}
}
fclose(F);
}