Illustrations include approximating the integral using Riemann sums, specifically the middle Riemann sum for the integration range from 0 to 1. The graph displayed is that of x^2, with 10 terms of the midpoint Riemann sum. Additionally, the function calculates the sum area using left Riemann sums, and delta is the difference between x values. Finally, the area is computed.
Assess
Riemann sum
s interactively.
Syntax
rsums(f)
rsums(f,a,b)
rsums(f,[a,b])
Description
example
The interactive function
rsums(
f
approximates the integral of function f(x) using middle
Riemann sums
for x between 0 and 1. Additionally,
rsums(f)
generates a graph of f(x) using 10 rectangles, with the option to adjust the number of rectangles using a slider. The number of rectangles can range from 2 to 128. The input for the height of each rectangle in
f
can be a character vector or a
symbolic expression
, and is determined by the value of the
function in the middle
of each interval.
example
The integral approximation for the range of x from
a
to
b
can be calculated using the values of
rsums(
f
,
a
, and
b
. Additionally,
rsums(f,[a,b])
is included in the calculation.
Examples
collapse all
Approximate Integral by Riemann Sum
Use the middle Riemann sum to approximate the integral of x^2 from 0 to 1. Display a graph of x^2 using 10 terms for the integration range and find the total sum, which is 0.3325.
syms x
rsums(x^2)
Adjust the interval of integration for the variable “x” to span from 2 to 5 resulting in a Riemann sum total of 44.0475.
rsums(x^2,2,5)
Input Arguments
collapse all
f
—
Integrand
symbolic expression

symbolic function

symbolic number
f
The input for the integrand can be either a symbolical expression, a function, or a numerical value.
a
—
Lower bound
number

symbolic number
a
A numerical or symbolic value is designated as the lower limit.
b
—
Upper bound
number

symbolic number
b
The maximum value can be defined as either a numerical or symbolic representation.
Version History
Introduced before R2006a