## LEFT-HAND SUM PROGRAM

WITH EXTENSION TO RIGHT-HAND SUMS AND THE TRAPEZOID RULE

### SHARP EL-9300C or EL-9200

General: To enter the program commands, press the programming key (middle upper key), then C key (which selects the NEW program option), then ENTER, then 1 (to select real mode), then the program name. The calculator will be in A-LOCK mode. Hit ALPHA at the end of the name, and then ENTER. After typing each command, press the ENTER key.
```Commands:			Remarks and keying instructions

h=(-a + b)/n			Use the minus sign below 3 to enter "minus a"
The Sharp automatically prompts for
undefined variables. Here a is the lower
limit, b is the upper limit, and n is the
number of subdivisions
For /, press the division key, under the
the ) key.
s=0				These two commands initialize s (the
i=0				running total for the sum) and the counter i.

Label 1				This spot in the program is labelled 1.
For Label, press 2ndF key followed by COMMAND
key, then B key for the BRNCH (branching
x=a+i*h				Calculate i-th x-coordinate.
f=x^3				This line defines the function to be
summed. To change functions, edit this line.
s=s+f*h				Add the next increment to the sum. For *,
press the multiplication key, under the ( key.

i=i+1				Add 1 to the counter.

If i< n Goto 1  		For If and Goto get to BRNCH menu as
before, then press 3 key for If and 2 key
for Goto. For < press 2ndF key followed
by COMMAND key,  then C key for INEQ menu,
then 2 key. If i is equal to n, (the
sum is complete and) the program goes on to
the next command.

Print s				The calculator will display s=(value).
End				(optional) For End, goto the PROG  menu as
before, then press 6 key.
```
Ending: After pressing the ENTER key for the last command (End), press the QUIT key.

Running the program: Remeber to re-edit when you switch functions. In the program menu (upper middle key) choose A (for RUN menu), then right arrow then down arrow to LSUM, then ENTER. Enter numbers at the question mark (a=? etc.) prompts.

Check: for f = x^3, lower limit 1, upper limit 3, and 100 subdivisions, the left-hand sum should be 19.7408.

RIGHT-HAND SUMS AND THE TRAPEZOID RULE

The program should be modified as follows: (Additions appear in boldface; the command f= .. is moved to the subroutine 2, the command Print s is deleted. Note that < changes to < =!).

```Goto 0		Start the program where it started before.
Label 2		These 3 commands form a ``subroutine,'' a
f=sin x		subprogram that can be accessed from anywhere
Return		in the program and returns to the accessing
Label 0		point.
h=(-a + b)/n
s=0
i=0
Label 1
x=a+i*h
Gosub 2
s=s+f*h
i=i+1
If i<=n Goto 1  Note the change from < to < =. The sum
l=s-f*h		s uses both the initial and the final values.
Print l		Subtracting the final contribution (sb) gives
x=a		the left-sum l; subtracting the initial
Gosub 2		contribution gives the right-sum r.
r=s-f*h
Print r
t=(l+r)/2
Print t
End
```
Check: For f=sin x, lower limit 0, upper limit pi/2, and n = 10, you should get left-sum l = .91940317, right-sum r = 1.076482803, and trapezoid approximation t = 0.997942986.
Anthony Phillips
Math Dept SUNY Stony Brook
tony@math.sunysb.edu
September 8 1997