
CScD-543/443 Multiprocessor Example:
Numerical Integration — Simplest Approximation
Given a function in terms of (x,y) data points, one can approximate the integral of that function
over the interval represented by the x values several ways. As our specimen problem, we will
use the simplest approximation: integration by the trapezoid rule. In this approach, the interval
is considered to be constructed by a series of trapezoids, in which the base of the trapezoid is the
x-axis, the two sides being the line segments from the x axis up to the y values on either side of
the trapezoid, and the top line being a straight line connecting those two y values.
Let a represent the left y-value; b, the right y-value; and h, the x interval (xj – xj–1).
The total area can be computed as two parts: a rectangle and a triangle.
The rectangle: a · h
Note that this uses up part of b, so that the unused segment is in the triangle.
The triangle: ½ ( b – a ) · h
Total area:
hbahabha )(
2
1
)(
2
1
2
2
If we have evenly-spaced data points y0 through yn (n+1 data points for n
trapezoids), every point other than y0 and yn (the boundary points) appears twice. If we retain h
as the x-interval (evenly spaced, as noted), the formula adding up all the trapezoids simplifies to
this:
hyyy
n
n
j
j
2
1
2
1
1
1
0
If we do not have evenly spaced observations, then we need to explicitly handle the varying
increments:
n
j
jjjj
xxyy
1
11
2
1
This is an example of an “embarrassingly parallel” problem: forming the integral from x0 to xk is
completely separate from forming the integral from xk to xn (provided 0 < k < n, of course). Thus
we can compute in parallel the integral for several segments and then just add them together to
get the complete integral.
This is the problem that we will do in the various distributed multiprocessing environments that
we will study in this class as the initial parallel programming projects. That means that the bulk
of your time will not be spent on the integration algorithm, but instead will be spent on porting
that algorithm over to a new parallel processing environment.
Printed 2020–12 –月–02 at 10:56