#include "math.h" #include #include "myfunc.h" // a million steps, to get a large number of calculations #define STEPS 1000000 int main() { // sample program to verify the speed and precision of taylor series expansion of sine and cosine // first, as a baseline, calculate the speed with the optimized standard library functions int i,j; double a,b; double av[4] = {0,0,0,0}; // 4 times the average of sine**2 + cosine**2 -1; double rms[4] = {0,0,0,0}; // and the RMS of them int tot=0; for (j=0; j<10; j++) for (i=0; i0) { av[i]/=tot; rms[i]/=tot; } rms[i] -= av[i]*av[i]; if (rms[i]<0) fprintf(stderr,"Due to precision, negative RMS in routine %d\n",i); else rms[i] = sqrt(rms[i]); fprintf(stdout,"routine %d, average %e, rms %e\n",i,av[i],rms[i]); } powercount(); }