QUAD
An MPI program to estimate an integral


QUAD is a program which estimates an integral over [0,1].

A typical approach would be to divide the interval [0,1] into P subintervals, and have each process produce an estimate for its subinterval.

This program, instead, takes N evenly spaced values in [0,1], and then assigns them in alternating order to the processes. If there were two processes, then process 0 would be getting all the odd numbered points, and process 1 the evens, for instance.

Depending on the quadrature method being used, if you double the number of intervals, you might expect the error to decrease by a factor of 1/2 or even 1/4. For the problem considered here, that will probably not happen. The improvement is slower than expected. Can you suggest why this is occurring? Is it because of parallel processing? The unusual division of the interval? The function being integrated? Something else?


Source Code:


Last revised on 21 October 2012.