/************************************************************************** Function Name: Simpsonthree Description: The simpsonthree works using the 3/8th rule of simpson that replicates the number of bins using the formula for simpsons rule. output: Double value corresponding to the sum of the individual integral results from the bins Input: Function to be integrated, upper limit, lower limit, number of bins ***********************************************************************/ #include #include double simpsonthree(double (*func)(double),double a,double b,int n) { double dH,dRes; int N=n; //This is the number of intervals double *x; x=malloc((N+1)*sizeof(double)); //malloc to allocate the memory for the size of the output to be summed int i; //loop variable x[0]=a; //intial value at which function is evaluated x[N]=b; //Final value at which function is evaluated dH=(b-a)/(double)N; //bin size dRes=3*dH/8*func(a); //variable initialized to integral value omp_set_num_threads(100); /*this sets the number of threads that will be used for the program*/ #pragma omp parallel //pragma!! #pragma omp for //for loop is being parallized for(i=1;i