Riemann sum

From HandWiki
Short description: Approximation technique in integral calculus
Four of the methods for approximating the area under curves. Left and right methods make the approximation using the right and left endpoints of each subinterval, respectively. Upper and lower methods make the approximation using the largest and smallest endpoint values of each subinterval, respectively. The values of the sums converge as the subintervals halve from top-left to bottom-right.

In mathematics, a Riemann sum is a certain kind of approximation of an integral by a finite sum. It is named after nineteenth century German mathematician Bernhard Riemann. One very common application is in numerical integration, i.e., approximating the area of functions or lines on a graph, where it is also known as the rectangle rule. It can also be applied for approximating the length of curves and other approximations.

The sum is calculated by partitioning the region into shapes (rectangles, trapezoids, parabolas, or cubics (sometimes infinitesimally small)) that together form a region that is similar to the region being measured, then calculating the area for each of these shapes, and finally adding all of these small areas together. This approach can be used to find a numerical approximation for a definite integral even if the fundamental theorem of calculus does not make it easy to find a closed-form solution.

Because the region by the small shapes is usually not exactly the same shape as the region being measured, the Riemann sum will differ from the area being measured. This error can be reduced by dividing up the region more finely, using smaller and smaller shapes. As the shapes get smaller and smaller, the sum approaches the Riemann integral.

Definition

Let [math]\displaystyle{ f: [a, b] \to \mathbb R }[/math] be a function defined on a closed interval [math]\displaystyle{ [a, b] }[/math] of the real numbers, [math]\displaystyle{ \mathbb R }[/math], and [math]\displaystyle{ P = (x_0, x_1, \ldots, x_n) }[/math] as a partition of [math]\displaystyle{ [a, b] }[/math], that is [math]\displaystyle{ a = x_0 \lt x_1 \lt x_2 \lt \dots \lt x_n = b. }[/math] A Riemann sum [math]\displaystyle{ S }[/math] of [math]\displaystyle{ f }[/math] over [math]\displaystyle{ [a, b] }[/math] with partition [math]\displaystyle{ P }[/math] is defined as [math]\displaystyle{ S = \sum_{i = 1}^{n} f(x_i^*)\, \Delta x_i, }[/math] where [math]\displaystyle{ \Delta x_i = x_i - x_{i - 1} }[/math] and [math]\displaystyle{ x_i^* \in [x_{i - 1}, x_i] }[/math].[1] One might produce different Riemann sums depending on which [math]\displaystyle{ x_i^* }[/math]'s are chosen. In the end this will not matter, if the function is Riemann integrable, when the difference or width of the summands [math]\displaystyle{ \Delta x_i }[/math] approaches zero.

Types of Riemann sums

Specific choices of [math]\displaystyle{ x_i^* }[/math] give different types of Riemann sums:

  • If [math]\displaystyle{ x_i^*=x_{i-1} }[/math] for all i, the method is the left rule[2][3] and gives a left Riemann sum.
  • If [math]\displaystyle{ x_i^* = x_i }[/math] for all i, the method is the right rule[2][3] and gives a right Riemann sum.
  • If [math]\displaystyle{ x_i^* = (x_i + x_{i - 1})/2 }[/math] for all i, the method is the midpoint rule[2][3] and gives a middle Riemann sum.
  • If [math]\displaystyle{ f(x_i^*) = \sup f([x_{i - 1}, x_i]) }[/math] (that is, the supremum of[math]\displaystyle{ f }[/math] over [math]\displaystyle{ [x_{i - 1}, x_i] }[/math]), the method is the upper rule and gives an upper Riemann sum or upper Darboux sum.
  • If [math]\displaystyle{ f(x_i^*) = \inf f([x_{i - 1}, x_i]) }[/math] (that is, the infimum of f over [math]\displaystyle{ [x_{i - 1}, x_i] }[/math]), the method is the lower rule and gives a lower Riemann sum or lower Darboux sum.

All these Riemann summation methods are among the most basic ways to accomplish numerical integration. Loosely speaking, a function is Riemann integrable if all Riemann sums converge as the partition "gets finer and finer".

While not derived as a Riemann sum, taking the average of the left and right Riemann sums is the trapezoidal rule and gives a trapezoidal sum. It is one of the simplest of a very general way of approximating integrals using weighted averages. This is followed in complexity by Simpson's rule and Newton–Cotes formulas.

Any Riemann sum on a given partition (that is, for any choice of [math]\displaystyle{ x_i^* }[/math] between [math]\displaystyle{ x_{i - 1} }[/math] and [math]\displaystyle{ x_i }[/math]) is contained between the lower and upper Darboux sums. This forms the basis of the Darboux integral, which is ultimately equivalent to the Riemann integral.

Riemann summation methods

The four Riemann summation methods are usually best approached with subintervals of equal size. The interval [a, b] is therefore divided into [math]\displaystyle{ n }[/math] subintervals, each of length [math]\displaystyle{ \Delta x = \frac{b-a}{n}. }[/math]

The points in the partition will then be [math]\displaystyle{ a, \; a + \Delta x, \; a + 2 \Delta x, \; \ldots, \; a + (n-2) \Delta x, \; a + (n - 1)\Delta x, \; b. }[/math]

Left rule

Left Riemann sum of xx3 over [0, 2] using 4 subintervals

For the left rule, the function is approximated by its values at the left endpoints of the subintervals. This gives multiple rectangles with base Δx and height f(a + iΔx). Doing this for i = 0, 1, ..., n − 1, and summing the resulting areas gives [math]\displaystyle{ S_\mathrm{left} = \Delta x \left[f(a) + f(a + \Delta x) + f(a + 2 \Delta x) + \dots + f(b - \Delta x)\right]. }[/math]

The left Riemann sum amounts to an overestimation if f is monotonically decreasing on this interval, and an underestimation if it is monotonically increasing. The error of this formula will be [math]\displaystyle{ \left\vert\int_{a}^{b} f(x)\, dx - S_\mathrm{left}\right\vert \le \frac{M_1 (b - a)^2}{2n}, }[/math] where [math]\displaystyle{ M_1 }[/math] is the maximum value of the absolute value of [math]\displaystyle{ f^{\prime}(x) }[/math] over the interval.

Right rule

Right Riemann sum of xx3 over [0, 2] using 4 subintervals

For the right rule, the function is approximated by its values at the right endpoints of the subintervals. This gives multiple rectangles with base Δx and height f(a + iΔx). Doing this for i = 1, ..., n, and summing the resulting areas gives [math]\displaystyle{ S_\mathrm{right} = \Delta x \left[f(a + \Delta x) + f(a + 2 \Delta x) + \dots + f(b)\right]. }[/math]

The right Riemann sum amounts to an underestimation if f is monotonically decreasing, and an overestimation if it is monotonically increasing. The error of this formula will be [math]\displaystyle{ \left\vert\int_{a}^{b} f(x)\, dx - S_\mathrm{right}\right\vert \le \frac{M_1 (b - a)^2}{2n}, }[/math] where [math]\displaystyle{ M_1 }[/math] is the maximum value of the absolute value of [math]\displaystyle{ f^{\prime}(x) }[/math] over the interval.

Midpoint rule

Middle Riemann sum of xx3 over [0, 2] using 4 subintervals

For the midpoint rule, the function is approximated by its values at the midpoints of the subintervals. This gives f(a + Δx/2) for the first subinterval, f(a + 3Δx/2) for the next one, and so on until f(b − Δx/2). Summing the resulting areas gives [math]\displaystyle{ S_\mathrm{mid} = \Delta x\left[f\left(a + \tfrac{\Delta x}{2}\right) + f\left(a + \tfrac{3\Delta x}{2}\right) + \dots + f \left(b - \tfrac{\Delta x}{2}\right)\right]. }[/math]

The error of this formula will be [math]\displaystyle{ \left\vert\int_a^b f(x)\, dx - S_\mathrm{mid}\right\vert \le \frac{M_2(b - a)^3}{24n^2}, }[/math] where [math]\displaystyle{ M_2 }[/math] is the maximum value of the absolute value of [math]\displaystyle{ f^{\prime\prime}(x) }[/math] over the interval. This error is half of that of the trapezoidal sum; as such the middle Riemann sum is the most accurate approach to the Riemann sum.

Generalized midpoint rule

A generalized midpoint rule formula is given by [math]\displaystyle{ \int_a^bf(x)dx=\sum_{m=1}^M \sum_{n=0}^N \frac{\Delta x^{2n+1}}{4^{n}(2n+1)!}f^{(2n)}(x_{m}) }[/math]

or

[math]\displaystyle{ \int_a^bf(x)dx=\lim_{M,N \to\infty}\sum_{m=1}^M \sum_{n=0}^N \frac{\Delta x^{2n+1}}{4^{n}(2n+1)!}f^{(2n)}(x_{m}), }[/math]

where

[math]\displaystyle{ x_{m}=a + \Delta x\left(m-\frac{1}{2}\right) }[/math], [math]\displaystyle{ \Delta x = \frac{b-a}{M} }[/math], and [math]\displaystyle{ f^{(2n)} (x_{m}) }[/math] denotes the [math]\displaystyle{ 2n }[/math]-th derivative.

Trapezoidal rule

Main page: Trapezoidal rule
Trapezoidal sum of xx3 over [0, 2] using 4 subintervals

For the trapezoidal rule, the function is approximated by the average of its values at the left and right endpoints of the subintervals. Using the area formula [math]\displaystyle{ \tfrac{1}{2}h(b_1 + b_2) }[/math] for a trapezium with parallel sides b1 and b2, and height h, and summing the resulting areas gives [math]\displaystyle{ S_\mathrm{trap} = \tfrac{1}{2}\Delta x\left[f(a) + 2f(a + \Delta x) + 2f(a + 2\Delta x) + \dots + f(b)\right]. }[/math]

The error of this formula will be [math]\displaystyle{ \left\vert\int_a^b f(x)\, dx - S_\mathrm{trap}\right\vert \le \frac{M_2(b - a)^3}{12n^2}, }[/math] where [math]\displaystyle{ M_2 }[/math] is the maximum value of the absolute value of [math]\displaystyle{ f''(x) }[/math].

The approximation obtained with the trapezoidal sum for a function is the same as the average of the left hand and right hand sums of that function.

Connection with integration

For a one-dimensional Riemann sum over domain [math]\displaystyle{ [a, b] }[/math], as the maximum size of a subinterval shrinks to zero (that is the limit of the norm of the subintervals goes to zero), some functions will have all Riemann sums converge to the same value. This limiting value, if it exists, is defined as the definite Riemann integral of the function over the domain, [math]\displaystyle{ \int_a^b f(x)\, dx = \lim_{\|\Delta x\| \rightarrow 0} \sum_{i = 1}^{n} f(x_i^*)\, \Delta x_i. }[/math]

For a finite-sized domain, if the maximum size of a subinterval shrinks to zero, this implies the number of subinterval goes to infinity. For finite partitions, Riemann sums are always approximations to the limiting value and this approximation gets better as the partition gets finer. The following animations help demonstrate how increasing the number of subintervals (while lowering the maximum subinterval size) better approximates the "area" under the curve:

Since the red function here is assumed to be a smooth function, all three Riemann sums will converge to the same value as the number of subintervals goes to infinity.

Example

Comparison of the right Riemann sum with the integral of xx2 over [math]\displaystyle{ [0,2] }[/math].
A visual representation of the area under the curve y = x2 over [0, 2]. Using antiderivatives this area is exactly [math]\displaystyle{ \dfrac{8}{3} }[/math].
Approximating the area under the curve y = x2 over [0, 2] using the right Riemann sum. Notice that because the function is monotonically increasing, the right Riemann sum will always overestimate the area contributed by each term in the sum (and do so maximally).
The value of the right Riemann sum of xx2 over [math]\displaystyle{ [0,2] }[/math]. As the number of rectangles increases, it approaches the exact area of [math]\displaystyle{ \dfrac{8}{3} }[/math].

Taking an example, the area under the curve y = x2 over [0, 2] can be procedurally computed using Riemann's method.

The interval [0, 2] is firstly divided into n subintervals, each of which is given a width of [math]\displaystyle{ \tfrac{2}{n} }[/math]; these are the widths of the Riemann rectangles (hereafter "boxes"). Because the right Riemann sum is to be used, the sequence of x coordinates for the boxes will be [math]\displaystyle{ x_1, x_2, \ldots, x_n }[/math]. Therefore, the sequence of the heights of the boxes will be [math]\displaystyle{ x_1^2, x_2^2, \ldots, x_n^2 }[/math]. It is an important fact that [math]\displaystyle{ x_i = \tfrac{2i}{n} }[/math], and [math]\displaystyle{ x_n = 2 }[/math].

The area of each box will be [math]\displaystyle{ \tfrac{2}{n} \times x_i^2 }[/math] and therefore the nth right Riemann sum will be: [math]\displaystyle{ \begin{align} S &= \frac{2}{n} \left(\frac{2}{n}\right)^2 + \dots + \frac{2}{n} \left(\frac{2i}{n}\right)^2 + \dots + \frac{2}{n} \left(\frac{2n}{n}\right)^2\\[1ex] &= \frac{8}{n^3} \left(1 + \dots + i^2 + \dots + n^2\right)\\[1ex] &= \frac{8}{n^3} \left(\frac{n(n + 1)(2n + 1)}{6}\right)\\[1ex] &= \frac{8}{n^3} \left(\frac{2n^3 + 3n^2 + n}{6}\right)\\[1ex] &= \frac{8}{3} + \frac{4}{n} + \frac{4}{3n^2}. \end{align} }[/math]

If the limit is viewed as n → ∞, it can be concluded that the approximation approaches the actual value of the area under the curve as the number of boxes increases. Hence: [math]\displaystyle{ \lim_{n \to \infty} S = \lim_{n \to \infty}\left(\frac{8}{3} + \frac{4}{n} + \frac{4}{3n^2}\right) = \frac{8}{3}. }[/math]

This method agrees with the definite integral as calculated in more mechanical ways: [math]\displaystyle{ \int_0^2 x^2\, dx = \frac{8}{3}. }[/math]

Because the function is continuous and monotonically increasing over the interval, a right Riemann sum overestimates the integral by the largest amount (while a left Riemann sum would underestimate the integral by the largest amount). This fact, which is intuitively clear from the diagrams, shows how the nature of the function determines how accurate the integral is estimated. While simple, right and left Riemann sums are often less accurate than more advanced techniques of estimating an integral such as the Trapezoidal rule or Simpson's rule.

The example function has an easy-to-find anti-derivative so estimating the integral by Riemann sums is mostly an academic exercise; however it must be remembered that not all functions have anti-derivatives so estimating their integrals by summation is practically important.


Higher dimensions

The basic idea behind a Riemann sum is to "break-up" the domain via a partition into pieces, multiply the "size" of each piece by some value the function takes on that piece, and sum all these products. This can be generalized to allow Riemann sums for functions over domains of more than one dimension.

While intuitively, the process of partitioning the domain is easy to grasp, the technical details of how the domain may be partitioned get much more complicated than the one dimensional case and involves aspects of the geometrical shape of the domain.[4]

Two dimensions

In two dimensions, the domain [math]\displaystyle{ A }[/math] may be divided into a number of two-dimensional cells [math]\displaystyle{ A_i }[/math] such that [math]\displaystyle{ A = \bigcup_i A_i }[/math]. Each cell then can be interpreted as having an "area" denoted by [math]\displaystyle{ \Delta A_i }[/math].[5] The two-dimensional Riemann sum is [math]\displaystyle{ S = \sum_{i = 1}^n f(x_i^*, y_i^*)\, \Delta A_i, }[/math] where [math]\displaystyle{ (x_i^*, y_i^*) \in A_i }[/math].

Three dimensions

In three dimensions, the domain [math]\displaystyle{ V }[/math] is partitioned into a number of three-dimensional cells [math]\displaystyle{ V_i }[/math] such that [math]\displaystyle{ V = \bigcup_i V_i }[/math]. Each cell then can be interpreted as having a "volume" denoted by [math]\displaystyle{ \Delta V_i }[/math]. The three-dimensional Riemann sum is[6] [math]\displaystyle{ S = \sum_{i = 1}^n f(x_i^*, y_i^*, z_i^*)\, \Delta V_i, }[/math] where [math]\displaystyle{ (x_i^*, y_i^*, z_i^*) \in V_i }[/math].

Arbitrary number of dimensions

Higher dimensional Riemann sums follow a similar pattern. An n-dimensional Riemann sum is [math]\displaystyle{ S = \sum_i f(P_i^*)\, \Delta V_i, }[/math] where [math]\displaystyle{ P_i^* \in V_i }[/math], that is, it is a point in the n-dimensional cell [math]\displaystyle{ V_i }[/math] with n-dimensional volume [math]\displaystyle{ \Delta V_i }[/math].

Generalization

In high generality, Riemann sums can be written [math]\displaystyle{ S = \sum_i f(P_i^*) \mu(V_i), }[/math] where [math]\displaystyle{ P_i^* }[/math] stands for any arbitrary point contained in the set [math]\displaystyle{ V_i }[/math] and [math]\displaystyle{ \mu }[/math] is a measure on the underlying set. Roughly speaking, a measure is a function that gives a "size" of a set, in this case the size of the set [math]\displaystyle{ V_i }[/math]; in one dimension this can often be interpreted as a length, in two dimensions as an area, in three dimensions as a volume, and so on.

See also

References

  1. Hughes-Hallett, Deborah et al. (2005). Calculus (4th ed.). Wiley. p. 252.  (Among many equivalent variations on the definition, this reference closely resembles the one given here.)
  2. 2.0 2.1 2.2 Hughes-Hallett, Deborah et al. (2005). Calculus (4th ed.). Wiley. p. 340. "So far, we have three ways of estimating an integral using a Riemann sum: 1. The left rule uses the left endpoint of each subinterval. 2. The right rule uses the right endpoint of each subinterval. 3. The midpoint rule uses the midpoint of each subinterval." 
  3. 3.0 3.1 3.2 Ostebee, Arnold; Zorn, Paul (2002). Calculus from Graphical, Numerical, and Symbolic Points of View (Second ed.). p. M-33. "Left-rule, right-rule, and midpoint-rule approximating sums all fit this definition." 
  4. Swokowski, Earl W. (1979). Calculus with Analytic Geometry (Second ed.). Boston, MA: Prindle, Weber & Schmidt. pp. 821–822. ISBN 0-87150-268-2. https://archive.org/details/studentsupplemen00bron. 
  5. Ostebee, Arnold; Zorn, Paul (2002). Calculus from Graphical, Numerical, and Symbolic Points of View (Second ed.). p. M-34. "We chop the plane region R into m smaller regions R1, R2, R3, ..., Rm, perhaps of different sizes and shapes. The 'size' of a subregion Ri is now taken to be its area, denoted by ΔAi." 
  6. Swokowski, Earl W. (1979). Calculus with Analytic Geometry (Second ed.). Boston, MA: Prindle, Weber & Schmidt. pp. 857–858. ISBN 0-87150-268-2. https://archive.org/details/studentsupplemen00bron. 

External links