// Calculation Program for displaying eye shaped curves (h), 16 Sep., 2008
// Equation of the curve: cosh(b*y**2)-1/cosh(-c*x**2)=exp(a)
// file name: eye_shaped_curves_h.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,amax,amin,da,b,c,z,acoshz;
int i,imax,n,nmax,j,m;
double xmax,xmin,dx;
double xx[2005],yy[10][2005];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// Setting of the constants
b=1;
c=1;
amax=1.8;// maximum value of a
amin=-2;// minimum value of a
da=(amax-amin)/4;// interval among parameter values of a
// Setting of the other parameters
xmax=4.1;// maximum value of x
xmin=-xmax;// minimum value of x
dx=(xmax-xmin)/820;// plotting interval of x
i=0;
n=0;
// execution of calculation
for(a=amin;a<=amax;a=a+da)
{
n++;
i=0;
for(x=-xmax;x<=xmax;x=x+dx)
{
i++;
xx[i]=x;
z=1/cosh(c*x*x)+exp(a);
if(a<0&z<1)
{
y=0;
}
else
{
acoshz=log(z+sqrt(z*z-1));
y=sqrt(acoshz/b);
}
yy[n][i]=y;
printf("i=%d,n=%d,a=%f,x=%f,y=%f\n",i,n,a,b,c,x,y);
}
}
imax=i;
nmax=n;
j=0;
for(i=imax+1;i<=2*imax;i++)
{
j++;
m=imax-j;
xx[i]=xx[m];
for(n=1;n<=nmax;++n)
{
yy[n][i]=-yy[n][m];
}
}
// writing the calculated coordinates data of the curve into a textfile
fp=fopen("eye-shaped curve.txt","w");
if(fp==NULL)
{
printf("FILE OPEN ERROR\n");
}
else
{
for(i=1;i<=2*imax-1;i++)
{
fprintf(fp,"%f,%f,%f,%f,%f,%f\n",xx[i],yy[1][i],yy[2][i],yy[3][i],yy[4][i],yy[5][i]);
}
fflush(fp);
fclose(fp);
}
printf("end\n");
}// the end of the program
RETURN