next up previous
Next: About this document ... Up: lab_template Previous: lab_template

Subsections


Rectangular Approximations to Integrals

Introduction

The purpose of this lab is to acquaint you with some rectangular approximations to integrals.

Rectangular Approximations

Integration, the second major theme of calculus, deals with areas, volumes, masses, and averages such as centers of mass and gyration. In lecture you have learned that the area under a curve between two points $a$ and $b$ can be found as a limit of a sum of areas of rectangles which approximate the area under the curve of interest. Not all ``area finding'' problems can be solved using analytical techniques. The Riemann sum definition of area under a curve gives rise to several numerical methods which can approximate the area of interest with great accuracy.

Suppose $f(x)$ is a non-negative, continuous function defined on some interval $[a,b]$. Then by the area under the curve $y=f(x)$ between $x=a$ and $x=b$ we mean the area of the region bounded above by the graph of $f(x)$, below by the $x$-axis, on the left by the vertical line $x=a$, and on the right by the vertical line $x=b$. All of the numerical methods in this lab depend on subdividing the interval $[a,b]$ into subintervals of uniform length.

In these simple rectangular approximation methods, the area above each subinterval is approximated by the area of a rectangle, with the height of the rectangle being chosen according to some rule. In particular, we will consider the left, right and midpoint rules.

The Maple student package has commands for visualizing these three rectangular area approximations. To use them, you first must load the package via the with command. Then try the three commands given below to help you understand the differences between the three different rectangular approximations. Note that the different rules choose rectangles which in each case will either underestimate or overestimate the area.

> with(student):
> rightbox(x^2,x=0..4,8)
> leftbox(x^2,x=0..4,8)
> middlebox(x^2,x=0..4,8)

To commands below show how to approximate the area under the curve $y=x^2$ using the left-endpoint rule in Maple

> f:=x->x^2
> h:=(4-0)/8
> h*(f(0)+f(0.5)+f(1)+f(1.5)+f(2)+f(2.5)+f(3)+f(3.5))

There are also Maple commands leftsum, rightsum, and middlesum to sum the areas of the rectangles, see the examples below. Note the use of evalf to obtain the desired numerical answers.

> rightsum(x^2,x=0..4,8)
> evalf(rightsum(x^2,x=0..4,8))
> evalf(leftsum(x^2,x=0..4,8))
> evalf(middlesum(x^2,x=0..4,8))

Accuracy

It should be clear from the graphs that adding up the areas of the rectangles only approximates the area under the curve. However, by increasing the number of subintervals the accuracy of the approximation can be improved. One way to measure how good the approximation is is the absolute error, which is the difference between the actual answer and the estimated answer. Later on in the course, you will learn techniques for finding the exact answer. Approximations, however, are important because exact answers cannot always be found.

All of the Maple commands described so far in this lab can include a third argument to specify the number of subintervals. The default is 4 subintervals. The example below approximates the area under $y=x^2$ from $x=0$ to $x=4$ using the rightsum command with 50, 100, 320 and 321 subintervals. As the number of subintervals increases, the approximation gets closer and closer to the exact answer. You can see this by assigning a label to the approximation, assigning a label to the exact answer $(4^3/3)$ and taking their difference. The closer you are to the actual answer, the smaller the difference. The example below shows how we can use Maple to approximate this area with an absolute error no greater than 0.1.

> exact := int(x^2,x=0..4)
> estimate := evalf(rightsum(x^2,x=0..4,50))
> evalf(abs(exact-estimate))
> estimate := evalf(rightsum(x^2,x=0..4,100))
> evalf(abs(exact-estimate))
> estimate := evalf(rightsum(x^2,x=0..4,320))
> evalf(abs(exact-estimate))
> estimate := evalf(rightsum(x^2,x=0..4,321))
> evalf(abs(exact-estimate))

Finding area

If you want to find the area bounded by the graph of two functions, you should first plot both functions on the same graph. You can then find the intersection points using either the solve or fsolve command. Once this is done, you can calculate the definite integral in Maple. An example below illustrates how this can be done in Maple by finding the area bounded by the graphs of $f(x)=-x^2+4x+6$ and $g(x)=x/3+2$:
> f := x-> -x^2+4*x+6
> g := x-> x/3+2
> plot({f(x),g(x)},x=-2..6)
> a := fsolve(f(x)=g(x),x=-2..0)
> b := fsolve(f(x)=g(x),x=4..6)
> int(f(x)-g(x),x=a..b)

Exercises

  1. For the function $f(x)=-x^3-4x^2\cos(x)+5x+2$ over the interval $[0,4]$,
    1. Use the leftbox command to plot the rectangular approximation of the area above the x-axis and under $f(x)$ with 4 rectangles. Estimate the area under the curve, above the x-axis, with a Riemann Sum using the formula for the left-endpoint rule and show that you get the same answer when using the leftsum command.
    2. Repeat the above using middlebox for the plot, the midpoint rule for the Riemann Sum estimate and the middlesum command to check your answer.
    3. Use a definite integral to find the exact area under $f(x)$, above the x-axis, over the interval $[0,4]$ and label this answer exact. Using the commands leftsum and middlesum, calculate the absolute error to determine the minimum number of rectangles required to estimate the area under $f$ with error no greater than 0.1. Based on your results, state which approximation method is better, left hand endpoint rule or the midpoint rule.

  2. Find the area of the region bounded by the curves $\displaystyle f(x)=\frac{x^3-12x+1}{x^2+1}$ and $\displaystyle g(x)=\frac{x^2}{4}-3\cos(x)-10$. You must first plot the region bounded by the given curves and solve for their intersection points.


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2019-09-12