/* ATK IV - Numerical Programming (2006) */ /* Excercise 3.2 - Polynomials */ #include #include #define N 250 void horner(double x, double a[],int n, double *y, double *dy); int main(void){ double x, y, dy; double list[N+1]; int n=250; FILE *file; /* Defines a pointer for the data stream */ file = fopen("expc.txt","rt"); /* Opens the data stream */ while(fscanf(file,"%lf\n",&list[n])!=EOF){ n--; /* Scans the coefficients from data stream */ } fclose(file); /* Closes the data stream */ for(n=0;n<=200;n++){ horner(n*1.0,list,N,&y,&dy); printf("%lf %G %G %G\n",n*1.0,y,dy,exp(n*1.0)); } return 0; }