Function Repository Resource:

# RiemannSum

Compute information related to a Riemann sum

Contributed by: Wolfram|Alpha Math Team, Jeremy Stratton-Smith
 ResourceFunction["RiemannSum"][expr,{x,xmin,xmax,n},m,method] computes an association of data related to the Riemann sum of expr specified by method on the domain xmin<=x<=xmax partitioned into n intervals of equal length. ResourceFunction["RiemannSum"][expr,{x,xmin,xmax,n},m,method,property] computes the information specified by property related to the Riemann sum of expr on the given domain. ResourceFunction["RiemannSum"][expr,{x,xmin,xmax,n},m,All,property] computes the information specified by property for all Riemann sum methods. ResourceFunction["RiemannSum"][expr,{x,xmin,xmax,n},m] computes all properties of the Riemann sum for all methods.

## Details

The input expr is expected to be the kind of input that Plot accepts (e.g. Sin[x], x2, etc.).
The input method can be any of All, "Left", "Right", "Midpoint" or "Trapezoidal" and defaults to All. This input determines the value to be taken in each of the intervals of the Riemann sum which is used for computing the sum.
The input property can be any of the following:
 "InactiveSum" inactivated Sum over the input variable m, where the summand is determined by the method and n. "Sum" activated sum "InactiveIntegral" inactivated integral that the given Riemann sum approximates "Integral" actual value of the integral "AbsoluteError" absolute error between the integral value and the sum value "RelativeError" relative error between the integral value and the sum value "Plot" plot showing the curve and the areas that are computed as the terms of the Riemann sum Dataset formatted output of all properties as a Dataset
A Riemann sum is an approximation of an integral and one of the first ways that a definite integral is introduced and defined.

## Examples

### Basic Examples (2)

Compute information related to a left Riemann sum:

 In:= Out= Alternatively compute just a particular property:

 In:= Out= ### Scope (2)

For easy comparison, return only a particular property for all four methods:

 In:= Out= Check that in this special case, all four methods return the same result:

 In:= Out= RiemannSum can also compute with a symbolic number of intervals:

 In:= Out= Compute the limiting behavior of the sum as the number of intervals goes to infinity:

 In:= Out= Show that this matches the actual value of the definite integral:

 In:= Out= ### Applications (3)

Show that in the finite case, the four methods may return differently:

 In:= Out= This can be seen symbolically as well:

 In:= Out= But in the limit, they are equivalent, and are equivalent to computing the definite integral:

 In:= Out= In:= Out= ### Properties and Relations (2)

For a given curve, one of the "Left", "Right", "Midpoint" or "Trapezoidal" Riemann sums will be the best approximation for the definite integral:

 In:= Out= In:= Out= For curves that are concave up, the "Left" method will under approximate the definite integral, while the "Right" and "Trapezoidal" methods will over approximate:

 In:= Out= In:= Out= ## Publisher

Wolfram|Alpha Math Team

## Version History

• 2.0.0 – 23 March 2023
• 1.0.0 – 02 June 2021