// Calculation Program for displaying a single rectangle, 22(Sun.) June, 2008
// Equation of rectangle:exp(x*x-bx)+exp(y*y-c*y)=a*exp(a*a), where the values of a, b and c are arbitrary real numbers.
// file name: rectangle_E.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,a,b,c;
int i,imax,j,m;
double xmin,xmax,dx;
double xx[10001],yy[10001];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// Setting of the constants
a=1;
b=100;
c=100;
printf("a=%f\n\n",a);
// Setting of the other parameters
// xmin and xmax represent the two point at which a rectangle cuts the x-axis.
xmin=b-sqrt(b*b+log(2*exp(a*a)-1));
xmax=b+sqrt(b*b+log(2*exp(a*a)-1));
dx=(xmax-xmin)/4000;// plotting interval of x
// Execution of calculation
i=0;
for(x=xmin+dx;x< xmax;x=x+dx)
{
i++;
xx[i]=x;
y=c+sqrt(c*c+log(2*exp(a*a)-exp(x*x-2*b*x)));
yy[i]=y;
printf("i=%d,x=%f,y=%f\n",i,x,y);
}
imax=i;
j=0;
for(i=imax+1;i<=2*imax-1;i++)
{
j++;
m=imax-j;
xx[i]=xx[m];
x=xx[i];
yy[i]=c-sqrt(c*c+log(2*exp(a*a)-exp(x*x-2*b*x)));
}
xx[2*imax]=xx[1];
x=xx[2*imax];
y=c+sqrt(c*c+log(2*exp(a*a)-exp(x*x-2*b*x)));
yy[2*imax]=y;
// writing the calculated coordinates data of the curve into a textfile
fp=fopen("rectangle.txt","w");
if(fp==NULL)
{
printf("FILE OPEN ERROR\n");
}
else
{
for(i=1;i<=2*imax;i++)
{
fprintf(fp,"%f,%f\n",xx[i],yy[i]);
}
fflush(fp);
fclose(fp);
}
printf("end\n");
}// the end of the program
RETURN