// Calculation Program for the minor axis of an egg body,
// 03 (Thur.) Dec., 2009
// egg equation: (x*x+y*y)**2=a*(x**3)+(a-b)*x*(y**2)
// The general condition needs b<=a,
// and in the case of b=0, the curve is led to a circle.
// file name: minor_axis.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double x,y,ypast,a,b,q,l2;
double xmax,dx;
// Setting of the constants
for(;;)
{
printf("Input of constant a; a= ? ");
scanf("%lf",&a);
if(a>0)
{
break;
}
else
{
printf("Please input the value of a after correcting a as a>0.\n");
}
}
for(;;)
{
printf("Input of constant b; b= ? ");
scanf("%lf",&b);
if(b>=0&&b<=a)
{
break;
}
else
{
printf("Pleease input the value of b after correcting b as 0< b < a or b=0 or b=a.\n");
}
}
printf("\n");
// Setting of the other parameters
xmax=a;// maximum value of x
dx=xmax/1000000;// minute increment of x
// execution of calculation
ypast=-1;
for(x=0;x<=xmax;x=x+dx)
{
y=sqrt(((a-b-2*x)+sqrt(4*b*x+(a-b)*(a-b)))*x/2);
if(y< ypast)
{
q=ypast;
break;
}
ypast=y;
}
l2=2*q;
printf("The minor axis of the egg is; l2=%lf\n",l2);
printf("\n");
printf("end\n");
}// the end of the program
RETURN