Program Listings for the HP 48SX

Below you will find programs which enable you to calculate various Riemann sums and thereby obtain numerical approximations to integrals. The programs assume that the function you are interested in has already been stored as the variable F (you can do this most easily by way of the equation editor).

The program LRSU produces both the left and the right sum for a function of your choice. You can also choose the endpoints of the subinterval and the number of subintervals. All these programs use equal partitions of the original interval. The mid point sum and trapezoidal sum are produced by the program TMSUM. Both these programs make use of other programs namely L, R and M. You must also enter the latter programs in your calculator, but you will not need to use them directly.

Program Listing LRSU:

"ENTER A,B,N IN ORDER" PROMPT
'N' STO SWAP 'A' STO A-N/'H' STO CLEAR
N L
'LEFT' ->TAG
N R
'RIGHT' ->TAG
N
'N' ->TAG
{A H N}PURGE

Program Listing TMSUM:

"ENTER A,B,N IN ORDER" PROMPT
'N' STO SWAP 'A' STO A-N/'H' STO 
N R
N L
+2/
'TRAP' ->TAG
N M
'MID' ->TAG
{A H N}PURGE

Program Listing L:

-> N 'H*S (I=1,N,F(A+(I-1)*H))'

Program Listing R:

-> N 'H*S (I=1,N,F(A+I*H))'

Program Listing M:

-> N 'H*S (I=1,N,F(A+(I-1/2)*H))'

In order to test the program try the following example. Using the equation editor, enter the function f(x)=x2 as F. Run the programs LRSU and TMSUM with the inputs A=0, B=1 and N=10. Note that the program will halt after you have entered the values of A,B,N. This gives you the chance to see that you entered the correct values. The program will proceed as soon as you push the CONT key. You should find that the left sum is 0.285, the right sum is 0.385, the midpoint sum is 0.3325 and the trapezoidal sum is 0.335. It's a nice exercise to decide whether these are over or underestimates to the integral and why.


Send questions, comments, and suggestions to Professor Paul Goodey.

* Return to the OU home page .... * Return to the Math home page .... * Return to Paul Goodey's home page