// Calculation Program for displaying a single convex circle, 2 July, 2008



// Equation of the curve: exp(b*b*x*x)+exp(c*c*y*y)=2*exp(a*a). a, b and c are arbitrary real numbers



// file name: distorted_circle_convex.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];



	FILE *fp;



// Setting of the constants

	a=10;

	b=2;

	c=1;



	printf("a=%f\n\n",a);



// Setting of the other parameters

	// xmin and xmax are the minimum and maximum points of the curve on the x-axis

	xmin=-sqrt(log(2*exp(a*a)-1)/(b*b));

	xmax=sqrt(log(2*exp(a*a)-1)/(b*b));

	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=sqrt(log(2*exp(a*a)-exp(b*b*x*x))/(c*c));

		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]=-sqrt(log(2*exp(a*a)-exp(b*b*x*x))/(c*c));

		}



	xx[2*imax]=xx[1];

	x=xx[2*imax];

	y=sqrt(log(2*exp(a*a)-exp(b*b*x*x))/(c*c));

	yy[2*imax]=y;



// writing the calculated coordinates data of the curve into a textfile

	fp=fopen("distorted_circle.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