// Calculation Program for displaying five extended-egg-curves II, 2008/8/13
// Equation of the curve: x^8+2*d*x^4*y^4+f*y^8=a*x^6+c*x^2*y^4+e*y^4
// Costant "c" is a variable parameter
// file name: extended_egg_curve_6a.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,c,d,e,f,dc,cmin,cmax;
int i,imax,n,nmax,j,m;
double xmax,dx;
double xx[2005],yy[10][1005];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// Setting of the constants
a=4;
d=0.2;
f=0.2;
e=0;
printf("a=%f\n\n",a);
// Setting of the other parameters
xmax=sqrt(a);// maximum value of x
dx=xmax/400;// plotting interval of x
cmin=-20;
cmax=-4;
dc=(cmax-cmin)/4;
i=0;
// execution of calculation
for(x=0;x<=xmax;x=x+dx)
{
i++;
n=0;
xx[i]=x;
for(c=cmin;c<=cmax;c=c+dc)
{
n++;
y=sqrt(sqrt(((c*x*x+e-2*d*x*x*x*x)+sqrt(4*(d*d-f)*x*x*x*x*x*x*x*x+4*(a*f-c*d)*x*x*x*x*x*x+(c*c-4*d*e)*x*x*x*x+2*c*e*x*x+e*e))/(2*f)));
yy[n][i]=y;
printf("i=%d,n=%d,c=%f,x=%f,y=%f\n",i,n,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("extended_egg_curve.txt","w");
if(fp==NULL)
{
printf("FILE OPEN ERROR\n");
}
else
{
for(i=1;i<=2*imax;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