In two dimensions the Rieman integral determines the area between the x axis and the function y = f(x) in an interval x1 < x < x2 by nesting it between two approximative sums. Both are constructed by a series of rectangles with intervals along the x axis. For the upper sum the approximative value of y in each interval is equal to the largest value in the interval (its supremum); for the lower sum it is equal to the smalles value (infimum). The Riemann integral exists, when both sums converge with decreasing interval width, and when they converge to the same limit.
The definition is not identical to the classical rectangle algorithm, where the value of the function is equal to the value at the beginning of the interval (more generally: always at the same point in the interval). For "well behaved" functions there will be no difference in results, yet the Riemann definition is more generally applicable.
The approximative calculation of the Riemann integral is shown for the example of a sine function (blue). Its definite integral is to be calculated in the range x2 - x1. The initial value x1 is defined by a slider, the end point x2 by drawing the red point with the mouse. The yellow curve is the analytic solution cos x - cos x1.
The number of intervals (n - 1) is defined by slider n. Reset defines 1 < x < 4 and n = 10 (9 intervals) .
The left window shows in red the approximation by the supremum series, with the blue point as the sum; the function always lies below the rectangle. The right window shows the approximation by the infimum series; the function always lies above the rectangle.
Correspondingly the upper sum of the rectangles is always higher than the analytic integral, while the lower sum is always lower - for finite interval widths. With decreasing interval widths both converge to the same value, the Riemann integral.