Riemann Sums

Numerical estimates to definite integrals can be obtained via various types of summations. This page provides

Visualization

This demo allows you to choose a function, partition size, and sum type (from Left, Right, Midpoint, or Trapezoidal) to compute and visualize the corresponding numerical integration approximation.

Computation

Here’s some live SageMath code that allows you to actually compute these sums.

\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f(x_{i-1}) \, \Delta x\]

\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f(x_i) \, \Delta x\]

\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f\left(\frac{x_{i-1} + x_i}{2}\right) \, \Delta x\]

\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n \frac{f(x_{i-1}) + f(x_i)}{2} \, \Delta x\]

Note how similar the computer code for the sum is to the mathematical notation. That is

  • sum(f(x(i))*dx, i,1,n) looks like
  • \(\sum_{i=1}^n f(x_i) \, \Delta x\)