# 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:

• -1 means "use left-hand endpoints"
• 0 means "use midpoints"
• 1 means "use right-hand endpoints"

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:

• The function will produce nonsensical results if n is not a positive integer.
• There will be an error message if n = 0.
• The function will produce nonsensical results (or may go into an infinite loop) if the upper limit is less than or equal to the lower limit.
 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 key, Then select "7: Program Editor" and "3: New" from the submenu. In the New dialog, select "Function" from the Type menu, and type the name of the function ("riemann") in the Variable field. 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 dx :If w<0 Then :a c :b-dx b :ElseIf w=0 Then :a+dx/2 c :Else :a+dx c :EndIf :sum(seq(f,x,c,b,dx)) 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. 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. 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.

last update December 31, 2008 by JL Stanbrough