#include "conio.h"
#include "math.h"
{
int n,i;
float a,la,b,x[50],y[50],lx[50],ly[50],lx2[50],m[50];
float elx = 0,ely = 0,elx2 = 0,em = 0;
clrscr ();
printf ("Exponential Curve Fitting:\n\n");
printf ("\n-------------------------------------\n\n\n");
printf ("Enter the number of values do you give : ");
scanf ("%d",&n);
clrscr ();
for (i=0; i
{
printf ("Enter X%d: ",i);
scanf ("%f",&x[i]);
printf ("Enter Y%d: ",i);
scanf ("%f",&y[i]);
printf ("\n");
}
for (i=0; i
{
lx[i] = logl (x[i]);
ly[i] = logl (y[i]);
lx2[i] = lx[i] * lx[i];
m[i] = lx[i] * ly[i];
}
for (i=0; i
{
elx += lx[i];
ely += ly[i];
elx2 += lx2[i];
em += m[i];
}
b = ((n * em) - (elx * ely)) / ((n * elx2) - (elx * elx));
la = (ely - (b * elx)) / n;
a = exp (la);
clrscr ();
printf ("\nXi Yi ln(Xi) ln(Yi)\tln(Xi)2 ln(Xi)ln(Yi)\n\n");
for (i=0; i
{
printf ("%f ",x[i]);
printf ("%f ",y[i]);
printf ("%f ",lx[i]);
printf ("%f ",ly[i]);
printf ("%f ",lx2[i]);
printf ("%f\n",m[i]);
printf ("\n");
}
printf ("\n-------------------------------------");
printf ("\n\n\na = %f",a);
printf ("\n\nb = %f",b);
getch ();
}
0 comments:
Post a Comment