//  Calculation Program for displaying a single egg curve 2
// (Suugaku-Dokusyuu-Juku's), 17(Thurs.) Sep., 2009

// recommended values: a=1.5, b=1.2, c=8

// file name: egg_shaped_curve_SUUDUKU_2.c

#include< stdio.h>

#include< math.h>

void main(void)

{

	double x,y,a,b,c;

	int i,imax,j,m;

	double 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.5;

	b=1.2;

        c=8;

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


// Setting of the other parameters

	xmax=a;// the maximum value of x

	dx=xmax/2000;// the plotting interval of x

// execution of calculation

	i=0;

	for(x=-xmax;x<=xmax+dx/10;x=x+dx)

	{

		i++;

		xx[i]=x;

	        if(x>xmax)

        	{

         		y=0;

        	}

        	else

        	{
         		y=(1+(x+a)/c)*sqrt(1-(x/a)*(x/a))/b;

        	}

		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;i++)

	{
		j++;

		m=imax-j;

		xx[i]=xx[m];

		yy[i]=-yy[m];

	}

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

	fp=fopen("egg-shaped curve.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

Revised on May 13, 2020 and Jun. 01, 2020.