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

m=ipart((n+1)/2)		The Sharp automatically prompts for the
				undefined variable n (the number of
				subdivisions).  The function ipart means
				"integer part", for example ipart(3.2)=3.
				To enter it, use the MATH menu, then A for
				math, followed by 3 for ipart. The reason for
				this line is that Simpson's rule requires
				n to be even.  We want m=n/2, but if the
				value of n entered is not an even integer, m
                                would have a fractional part.  The more
				complicated formula used here ensures that
				eg n=3 and n=4 both give m=2.

n=2*m				By setting n=2*m, we have made sure that n
				will be even in what follows.
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 and b is the upper limit.
				For /, press the division key, under the
				the ) key.

i=0				This initializes the counter i.

x=a				This initializes x to equal the first
				point x0 in the subdivision.

Gosub 2				Call the subroutine (GOto SUBroutine) that
				evaluates the function f(x) for this x value.
				The answer is returned in the variable f.
				The subroutine is labelled 2 and can be found
				at the end of the program.  After running the
				subroutine the program RETURNs here, to the
				calling point with the value of f set.
				To enter Gosub, press 2ndF followed by
				MATH ("COMMAND"), then B for BRNCH, followed
				by 4 for Gosub.

s=f				Initialize the sum s to equal f(x) = f(x0).

Label 1				This spot in the program is labelled 1.

x=x+h				Move to the next point of the subdivision.

Gosub 2				Evaluate the function at the point x.

s=s+4*f				Add 4*f(x) to the sum s.

x=x+h				Move to the next point of the subdivision.

Gosub 2				Evaluate the function at the point x.

s=s+2*f				Add 2*f(x) to the sum s.

i=i+1				Add 1 to the counter.

If i< m 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 m, (the
				sum is complete and) the program goes on to 
				the next command.

s=s-f				The program gets here with x = b, f = f(b)
				and s=f(x0)+4f(x1)+2f(x2)+...+4f(x(n-1))+2f(xn),
				but in Simpson's rule the last term in s should
				be f(xn), so we need to subtract off one lot of
				f(xn)=f(b), which is what we do in this line.

r=s*h/3				The result (r) of Simpson's rule is s*h/3.

Print r				The calculator will display r=(value).

End				For End, goto the PROG  menu as before, then
				press 6 key.  The program stops running here.

Label 2				This spot in the program is labelled 2.  It is
				the start of the subroutine that evaluates f(x).

f=sin x				This line defines the function to be summed.
				To change functions, edit this line.

Return				End the subroutine, return to the calling point.
Ending: After pressing the ENTER key for the last command (Return), 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 = sin x, lower limit 0, upper limit 2, and 20 subdivisions, the Simpson's rule approximation should be 1.416147624.

Duncan Sands
Math Dept SUNY Stony Brook
November 10 1997