// Calculation Program for displaying a S-shaped curve, 21 (Sun.) Feb., 2010



// file name:S_curve.c



#include< stdio.h>

#include< math.h>



void main(void)

{

	double x,y,a,b,c,k,p,q,pi;

	double t,dt;// intermediate variable and its increment

	double tmax;

	double xx[10001],yy[10001];// Take care of the upper limit of storage memory capacitance.

	int i,imax;



	FILE *fp;



// Setting of the constants

	a=0.6;// 0.6

	b=0.6;// 0.6

	c=2.8;// 2.8

	k=1.0;// 1.0

	p=2.0;// 2.0

	q=1.6;// 1.6

	

	pi=3.1415927;// pi is the Pi.

	 

// Setting of the other parameters

	tmax=4.0*pi;// the maximum value of t

	dt=2*tmax/4000;// plotting interval of t



// execution of calculation

	i=0;

	for(t=-tmax;t<=tmax;t=t+dt)

		{

		i++;

		x=a*((exp(p*t)-1.)/(exp(p*t)+1.))-c*t*exp(-q*t*t)*cos(k*t*t);

		y=b*((exp(p*t)-1.)/(exp(p*t)+1.))+c*t*exp(-q*t*t)*sin(k*t*t);

		yy[i]=y;

		xx[i]=x;

		printf("i=%d,x=%f,y=%f\n",i,x,y);

		}

	imax=i;



	fp=fopen("S_curve.txt","w");

	if(fp==NULL)

		{

		printf("FILE OPEN ERROR\n");

		}

	else

		{

		for(i=1;i<=imax;i++)

			{

			fprintf(fp,"%f,%f\n",xx[i],yy[i]);

			}

		fflush(fp);

		fclose(fp);

		}

	printf("end\n");

}// the end of the program





RETURN