RSum for the HP 48G(X)


The following is in the Hewlett Packard ASCII format used by hp link and other hp datainterchange programs.  There are four issues that you should be aware of if you areattempting to type this program into your calculator 'by hand':

  1. The first line of the program contains identification information that is used internally by the calculator.  It is should be omitted if you are entering the program 'by hand'.  Thus, as usual, in entering the program by hand, the first keystroke should produce the '<<' '>>' character.pair.
  2. Non-ASCII characters are 'escaped'; i.e., preceded by the backslash character.  For instance, the 'store as parameters' symbol (a simple right directed arrow wpe3.jpg (752 bytes)) is denoted by '\->', the 'store as a list' command, wpe4.jpg (988 bytes), is denoted by '\->LIST', and the double angle brackets that enclose a program are denoted by '\<<' and '\>>'.  \GSLIST denotes the 'sum list term by term' function, wpe2.jpg (1010 bytes), found in MTH/LIST.  The 'to tag' function, wpe5.jpg (995 bytes), is denoted by  \->TAG.   Finally, the '|' (often found on the shifted '\' key on computer keyboards) is the 'evaluate at' function.
  3. The ampersand ('@') always marks the beginning of a comment.  Within any line of the program, all of the text that lies to the right of an ampersand character will be ignored when the program is compiled.  Since comments are not executed, they can all be omitted when entering the program 'by hand'.
  4. The hp48G(X) parser is context-free; none of the of the program's 'white space' formatting has any effect on its execution.  In particular, the indenting of lines in the display below is done purely for readability.  Indenting can be omitted without affecting the program's correct operation.

THIS PROGRAM HAS NOT BEEN PLACED IN THE PUBLIC DOMAIN.  IN UNALTERED FORM, IT CAN BE USED FOR ANY NON-COMMERCIAL EDUCATIONAL PURPOSE.  THECODE GIVEN BELOW SHOULD NOT BE MODIFIED IN ANY WAY WITHOUT THEWRITTEN PERMISSION OF THE AUTHOR.  IF YOU USE ANY PART OF THE CODE OR ANY OF THEIDEAS WORKED OUT WITHIN IT, THE COPYRIGHT NOTICE INCLUDED IN THIS PROGRAM MUSTBE DISPLAYED AT YOUR PROGRAM'S STARTUP.


%%HP: T(3)A(R)F(.);\<< CLLCD"HP 48G: Riemann Sums" 2 DISP@"  Copyright (c) 1996" 4 DISP"    by Jack Courtney" 5 DISP" All Rights Reserved" 6 DISP\-> x a b n    \<< x INDEP STEQ b a - n /        \-> h        \<< a b XRNG 'a+I*h' 'I' 0 n 1 SEQ   @ Generate a list of the x-values            DUP 1 \<< RCEQ x ROT 2 \->LIST | \->NUM \>> DOLIST @ and of the function values            DUP TAIL \GSLIST h *             @ Calculate the RH sum            SWAP REVLIST TAIL \GSLIST h *    @ Calculate the LH sum            SWAP DUP2 + 2 /                  @ Trapezoidal sum (TR)=(RH+LH)/2            "Trapezoidal Sum" \->TAG ROT            "Left Hand Sum"   \->TAG ROT            "Right Hand Sum"  \->TAG ROT            4 ROLL DUP TAIL            SWAP REVLIST TAIL REVLIST            ADD 2 /                          @ Generate a list of the x-values at the midpoints            1 \<< RCEQ 'PPAR' 3 GET ROT 2 \->LIST | \->NUM \>> DOLIST @ and of the function values            \GSLIST h * DUP                  @ Calculate the midpoint sum (MP)            "Mid Point Sum" \->TAG            SWAP 2 * 3 PICK DTAG + 3 /       @ Simpson's sum = (2*MP+TR)/3            "Simpson's Sum" \->TAG        \>>    \>>\>>

Click here to download an electronic copy. (To load this directly into your calculator, you will need hplink hardware and hplink or hpcomm software or an equivalent.)


09/05/96(jac)