The Riemann sum of a real valued function f() over an interval [a,b] is defined as the sum of f(xi)×(xi+1-xi), as i runs from 0 to n, stepping through the points in the net.
Let's compute the area under the parabola y = x2, from x = 0 to 1. The trivial net, with no internal points, has only the endpoints 0 and 1. The Riemann sum is f(0)×(1-0) = 0, a rather poor estimate. Add a point to the net, at x = 1/2, and the sum becomes 0×1/2 + 1/4×1/2 = 1/8. If the net divides the interval into quarters, the sum is 14/64. If the net divides the interval into sixths, the sum is 55/216. Continue this process and the area approaches 1/3. Note that these nets have regularly spaced subintervals, thus reproducing Aristotles rectangles. In general, Riemann nets need not be regularly spaced.
Riemann sums generalize to higher dimensions. Given a rectangular box in 3 space, establish a Riemann net for each of the 3 dimensions. Call these nets x, y, and z, and compute the sum of:
f(xi,yj,zk) × (xi+1-xi) × (yj+1-yj) × (zk+1-zk)
as i j and k run through the points in the nets x y and z
We are really taking the cross product of all three nets.
If all three nets have granularity δ, the entire Riemann net, in 3 dimensions, has granularity δ.
The Riemann sum can be applied to an arbitrary region in space. Include only the points in the net that are contained in the region, or, set f = 0 outside the region. For example, let the set S be the unit ball in 3 space. A cube of size 2 contains this ball. All three cordinates run from -1 to 1. Define 3 nets of granularity δ over [-1,1] and take their cross product. When computing the Riemann sum, include only those points that are less than one unit away from the origin, i.e. the points in S.
When computing a Riemann sum, the function f() can be a complex or vector function. Riemann sums are computed per component.