Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute information related to a Riemann sum
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. |
"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 |
Compute information related to a left Riemann sum:
In[1]:= |
![]() |
Out[1]= |
![]() |
Alternatively compute just a particular property:
In[2]:= |
![]() |
Out[2]= |
![]() |
For easy comparison, return only a particular property for all four methods:
In[3]:= |
![]() |
Out[3]= |
![]() |
Check that in this special case, all four methods return the same result:
In[4]:= |
![]() |
Out[4]= |
![]() |
RiemannSum can also compute with a symbolic number of intervals:
In[5]:= |
![]() |
Out[5]= |
![]() |
Compute the limiting behavior of the sum as the number of intervals goes to infinity:
In[6]:= |
![]() |
Out[6]= |
![]() |
Show that this matches the actual value of the definite integral:
In[7]:= |
![]() |
Out[7]= |
![]() |
Show that in the finite case, the four methods may return differently:
In[8]:= |
![]() |
Out[8]= |
![]() |
This can be seen symbolically as well:
In[9]:= |
![]() |
Out[9]= |
![]() |
But in the limit, they are equivalent, and are equivalent to computing the definite integral:
In[10]:= |
![]() |
Out[10]= |
![]() |
In[11]:= |
![]() |
Out[11]= |
![]() |
For a given curve, one of the "Left", "Right", "Midpoint" or "Trapezoidal" Riemann sums will be the best approximation for the definite integral:
In[12]:= |
![]() |
Out[12]= |
![]() |
In[13]:= |
![]() |
Out[13]= |
![]() |
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[14]:= |
![]() |
Out[14]= |
![]() |
In[15]:= |
![]() |
Out[15]= |
![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License