# on the TI-89

The Trapezoidal Rule can be used to provide a more accurate approximation of the value of a definite integral than a Riemann sum, with just a little more calculation. The Trapezoidal Rule says:

Like Riemann sums, approximating a definite integral can be tedious and error-prone, but it is easily programmed. Below is a function that calculates a Trapezoidal Rule approximation.

The syntax for the function is:

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

The easiest way to get this function is to transfer it from another calculator, or download the function and install it using 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 ("trap") 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. trap(f, x, a, b, n) : Func : Local dx, s, c, i : (b - a)/n dx : 0 s : a + dx c : For i, 1, n - 1 : s + (f | x = c) s : c + dx c : EndFor : Return dx* (( f | x = a) + 2*s + (f | x = b))/2 : EndFunc The function shown at right uses the trapezoidal rule function to approximate the value of with n = 4.

last update November 26, 2007 by JL Stanbrough