### Riemann Sums Program code for the HP 38G graphing calculator

Thanks are due to Math 20A class member Eric Baker for providing this HP 38G program, and for creating this web page.

To enter the program go the the program catalog by pressing the blue shift key and 0. Select NEW from the screen menu and enter a name like RSUM.  Once the program has been entered, it can be run from the program catalog.

0>>L:
0>>R:
INPUT A; "RSUM"; "LL"; "LOWER LIMIT"; 0:
INPUT B; "RSUM"; "UL"; "UPPER LIMIT"; 1:
INPUT D; "RSUM"; "DIVS"; "NUMBER OF DIVISIONS; 100:
1/D>>D:
FOR I=A TO B-D STEP D;
F1(I)>>Q:
Q+L>>L:
END:
F1(B)>>Q:
Q+L>>R:
ERASE:
DISP 1; "Left Sum":
DISP 2; L*D:
DISP 3; "Right Sum":
DISP 4; R*D:
DISP 5; "Midpoint Sum":
DISP 6; (D*L+D*R)/2:
FREEZE:

Comments on the program listing
• To enter letters hold the A...Z key and press the corresponding letter.
• Symbols like quotes are added by pressing the blue shift key and ( to get to the character menu.
• Take care to distinguish between the character ; (semicolon) and the character : (colon), between 0 (zero) and O (upper case "oh"), and between 1 (one) and I (upper case i).
• The symbol >> is an attempt to reproduce a right-pointing triangle. This symbol is produced by hitting the STO menu button.
• The line that starts with FOR is supposed to end with a semicolon.

Running the program
• This program calculates left and right Riemann sums. It also calculates Riemann sums based on midpoints.
• Before running the program you need to make sure that you're using the "Function" ApLet, which is accessable with the LIB key.
• To enter an equation, go to F1(X) in the the symbolic view by pressing the SYMB button.
• The lower limit of integration must be less than the upper limit.  The # of divisions must also be greater than zero or there will be an error.
• An error message that says "No Current Equation" indicates that the Function ApLet isn't running or that there is no equation in F1(X).
• As a test of the program, evaluate the definite integral of x^3 (x cubed) from LL=1 to UL=3 using DIVS=100 subdivisions. The left and right Riemann sum should be 19.8702 and 20.1402, respectively.  Midpoint should be 20.0052.

Back to the Math20A homepage.
November 18, 1998