Overview
An approximation of the area under a curve by dividing it into
where
From definite integral to Riemann sum
From Riemann sum to definite integral
Examples
Detailed example
We can convert between definite integral and Riemann sum (where
is the number of rectangles): Turn the original sum (
) to this form ( ), by changing the sign of : From this equation, we can identify the number of rectangles for the Riemann sum is
. Similarly, we extract the width of each rectangle: Using the width of each rectangle to find endpoints:
We also extract the height of each rectangle:
Rewrite the function in terms of
and , using the equation : From here, we can deduce that
and . Thus . We define the definite integral as:
Left Riemann sum
Divide the area into equal-width rectangles, where the height of each rectangle matches the function value at the left endpoint of its base.
Right Riemann sum
The height of each rectangle is equal to the value of the function at the right endpoint of its base.
Right Riemann sum
Approximate the area between
and the -axis on the interval using Right Riemann sum with 9 equal subdivisions then each rectangle has the height of
and area of So a Right Riemann sum is calculated as:
Midpoint Riemann sum
Divide the area is equal to the value of the function at the midpoint of its base
Trapezoidal Rule
Use equal-height trapezoids, each touches the curve at both of its top vertices
Example
Trapezoidal Sums
Approximate the area between the
-axis and , from to using a trapezoidal sum with 4 equal subdivisions. Repeating with all 4 trapezoids:
Sage Code
# Sage
var('x, i')
def left_sum(func, low_bound, upper_bound, num_recs):
w = (upper_bound - low_bound) / num_recs
left_sum = sum(w * func(x=low_bound + i*w), i, 0, num_recs-1)
return left_sum
def mid_sum(func, low_bound, upper_bound, num_recs):
w = (upper_bound - low_bound) / num_recs
mid_sum = sum(w * func(x=low_bound + (i+1/2)*w), i, 0, num_recs-1)
return mid_sum
def right_sum(func, low_bound, upper_bound, num_recs):
w = (upper_bound - low_bound) / num_recs
right_sum = sum(w * func(x=low_bound + i*w), i, 1, num_recs)
return right_sum
def trapezoid_sum(func, low_bound, upper_bound, num_recs):
w = (upper_bound - lowlow_bound + (i+1)*w))/2, i, 0, num_recs-1)
return trap_sum