Riemann Sums Program code for the Sharp EL-9200 and EL-9300 calculators
Select NEW in the program menu. Then select REAL in the MODE menu. When prompted for a title, use "riemann". The "..." in the following program is where the integrand (the function to be integrated) should be entered.
Goto start
Label eqn
f=...
Return
Label start
Print "l-limit
Input a
Print "u-limit
Input b
Print "divns
Input n
x=a
s=0
i=1
h=(b-a)/n
Label 1
Gosub eqn
s=s+f*h
x=x+h
i=i+1
If i<=n Goto 1
Print "left sum
Print s
Gosub eqn
s=s+f*h
x=a
Gosub eqn
s=s-f*h
Print "right sum
Print s
End
Comments on the program listing
- Take care to distinguish between the character 1 (one) and
the character l (lower case "ell"), and between 0 (zero) and O (upper case "oh").
- "Goto", "Label", Return", "Gosub", and "If" are in the BRANCH menu.
- "Print", the quote mark ", "Input", and "End" are in the PROG menu.
- = and <= are in the INEQ menu.
Running the program
- This program calculates left and right Riemann sums.
- The formula for the function to be integrated must be entered where the "..." appears above.
- The lower limit of integration must be less than the upper limit.
- As a test of the program, evaluate the definite integral of x^3 (x cubed) from A=1 to B=3 using
N=100 subdivisions. The left and right Riemann sums should be 19.7408 and 20.2608, respectively.
Back to the Math20A homepage.
October 23, 1998