BHS Calculus logo

Calculating Riemann Sums

on the TI-89



Riemann sums can be used to approximate the value of an area (definite integral) by filling the area, as well as possible, with rectangles, and then adding the areas of all of the rectangles. Although much better approximations exist (see the Trapezoidal Rule and Simpson's Rule), the Riemann sum is easy to understand and is fundamental to the concept of the definite integral.

Riemann sums can be arduous, tedious, repetitive, and error-prone to calculate by hand, so they are prime candidates for computer software. A function that calculates Riemann sums is given below. Note that this is not a simple, one-line function - if possible, it will be easier to transfer it from another calculator, or download the function and install it using TI Connect than to type it.

The syntax for the function is:

riemann(expression, variable, lower limit, upper limit, number of intervals, which sum) or riemann(f(x), x, a, b, n, which)

where "which sum" takes the values:

The easiest way to get this function is to transfer it from another calculator or download the function file and install via TI Connect.

If you need to type the function by hand, instructions are given below.

Note:

If you must type the program by hand, it is easier to enter this function using the Program Editor than the Home screen. You access the program editor by pressing the apps key key, Then select "7: Program Editor" and "3: New" from the submenu.

applications menu

In the New dialog, select "Function" from the Type menu, and type the name of the function ("riemann") in the Variable field.

New dialog

Now, type the function (shown at right). Some pointers:

  • Words in bold are already supplied by the program editor.
  • Press enter after each line, and the program editor will supply a ":" to start the next line.
  • It is easiest to get the keywords ("Local," "Else," etc.) from the Catalog menu.
  • If you make a mistake, just use the arrow keys to move back to it and change it.

riemann(f,x,a,b,n,w)

:Func

:Local dx,s,c

:(b-a)/n sto key dx

:If w<0 Then

:a sto key c

:b-dx b

:ElseIf w=0 Then

:a+dx/2 sto key c

:Else

:a+dx sto key c

:EndIf

:sum(seq(f,x,c,b,dx)) sto key s

:Return dx*s

:EndFunc

The function shown at right calculates a Riemann approximation to the area under the graph of y = x2 on [0, 4], using 4 rectangles (n = 4) constructed using left-hand endpoints.

lower sum screen shot

This function calculates a Riemann approximation to the area under the graph of y = x2 on [0, 4], using 4 rectangles (n = 4) constructed using midpoints.

midpoint screen shot

This function calculates a Riemann approximation to the area under the graph of y = x2 on [0, 4], using 4 rectangles (n = 4) constructed using right-hand endpoints.

right hand sum screen shot


last update December 31, 2008 by JL Stanbrough