﻿ C_program_single_heart-curve_a
```

// Calculation Program for displaying single heart curve, 25(Tues.) Dec., 2007

// Equation of the curve: x*x+(y-bx)**2=1 at x>0, x*x+(y+bx)**2=1 at x<0, where b>0.

// file name: heart_curve_a1_E.c

#include< stdio.h>

#include< math.h>

void main(void)

{

double x,y,b;

int i,imax,j;

double xmax,dx;

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

FILE *fp;

// setting of the constant

b=0.8;

xmax=1;// the maximum value of x

dx=xmax/1000;// plotting interval of x

i=0;

// execution of calculation

for(x=0;x<=xmax;x=x+dx)

{

i++;

xx[i]=x;

y=sqrt(1-x*x)+b*x;

yy[i]=y;

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

}

for(x=xmax;x>=0;x=x-dx)

{

i++;

xx[i]=x;

y=-sqrt(1-x*x)+b*x;

yy[i]=y;

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

}

for(x=0;x>=-xmax;x=x-dx)

{

i++;

xx[i]=x;

y=-sqrt(1-x*x)-b*x;

yy[i]=y;

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

}

for(x=-xmax;x<=0;x=x+dx)

{

i++;

xx[i]=x;

y=sqrt(1-x*x)-b*x;

yy[i]=y;

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

}

imax=i;

j=0;

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

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