Question: #include #include int main ( ) { int n; / / number of intervals double a , b; / / lower and upper limits of

#include
#include
int main()
{
int n; // number of intervals
double a, b; // lower and upper limits of integration
double h, sum; // h is length of each interval
// Input:
printf("Enter the lower limit of integration: ");
scanf("%lf", &a);
printf("Enter the upper limit of integration: ");
scanf("%lf", &b);
printf("Enter the total number of intervals: ");
scanf("%d", &n);
// Calculate h
h =(b - a)/ n;
// Initialize sum to 0
sum =0;
// Calculate the midpoint rule
for (int i =1; i = n; i++){
double x = a +(i-1)*h +(h/2);
sum += h *(1+ pow(x,2));
}
// Output
printf("The value of the integral is: %lf
", sum);
return 0;
}
Part 2: Parallel Implementation
Modify the serial program to create a parallel version using C and CUDA to solve the same problem.
#include #include int main ( ) { int n; / /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!