/* * combined.c * * This program combines what we saw before. It calculates e and pi * and then integrates the x^2. We also print out the elapsed time in * ms at several points in our program. We have replaced the function y=x^2 * with a more complex polynomial 3x^3 + 2x^2 + x. */ #include #include #define num_steps 10000000 /* steps to use in taylor expansions */ #define int_steps (1<<30) /* steps to use in integration */ int main(int argc, char *argv[]) { double start, stop; /* times of beginning and end of procedure */ /* Values for part 1 */ double e, pi, factorial, product; int i; /* Values for part 2 */ double sum; double x; /* start the timer */ start = clock(); #pragma omp parallel reduction(+: sum) { #pragma omp sections nowait { #pragma omp section { /* First we calculate e from its taylor expansion */ printf("e started at %.0f\n", clock()-start); e = 1; factorial = 1; for (i = 1; i