Numerical Integration: Some Riemann sums
Left, right, and midpoint Riemann sums
We partition the interval into equal parts: for with For the choice of tags, we distinguish the following three cases: choose for each sub-interval always the
- left endpoint, (left Riemann sum)
- right endpoint, (right Riemann sum)
- midpoint, (midpoint Riemann sum)
The Riemann sums can now be written as follows:
- left Riemann sum =
- right Riemann sum =
- midpoint Riemann sum =
These sums are used to approximate the area under the curve . A visualisation of the Riemann sums is made available below for you to play with, so that you can get a better idea of the differing situations.
Programming task
Write a function Riemannsom(f,a,b,n,methode'left endpoint')
that calculates not only the left Riemann sum of the function on the interval when divided into subintervals, but also the right Riemann sum and midpoint Riemann sum, respectively with the option method='right endpoint'
or method='midpoint'
.
Apply your function with in the following two cases: