## SIMPSON'S RULE PROGRAM

### TI-82 and TI-83

General: This program inputs A,B,N and evaluates the Simpson method sum on [A,B], with N equal subdivisions, of the function f(X) stored as an expression in location Y1. See instructions for the Left and Right sum programs for details on how to enter programs on the TI-82. Remember that "->" below is obtained by pressing the "STO" key (above "ON" key).
```Commands:			Remarks and keying instructions

Prompt A,B,N			Receive the interval endpoints and
number of subdivision points from user.
Prompt is 2 on the I/O menu, reached
via the PRGM button.

iPart ((N+1)/2)->M              The function iPart means "integer
part", for example iPart(3.2)=3.  To
enter it, use the MATH menu, then
press right-arrow for "NUM", followed
by 2 for iPart.  For /, press the
division key, under the the ^ key.

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.

2*M->N				By setting n=2*m, we have made sure that n
will be even in what follows.

(B-A)/N->H			H is what we usually call "delta-x",
the subinterval size.

A->X				This initializes x to equal the first
point x0 in the subdivision.

Y1->S				Initialize the sum s to equal f(x) = f(x0).
"Y1" is obtained by pressing "2nd"
then "VARS" for the Y-Vars menu, then
1 for Functions and 1 again for Y1.
Y1 must be defined to give the
function f which we are integrating
(see below)

FOR(I,0,M-1,1)			Begin a loop with counter I, beginning
at 0 and continuing through M-1,
incrementing by 1 each time. Thus, I is set
to 0 (zero) here, and the instructions
below are executed until the command
END is reached. Then I is incremented
by 1 and we go through the same list
of instructions again. This repeats
for each value of I including M-1. Finally
after running through the instructions
the last time with I=M-1, we
proceed with the first command
following the END.

X+H->X				Move to the next point of the subdivision.

S+4*Y1->S			Add 4*f(x) to the sum s.

X+H->X				Move to the next point of the subdivision.

S+2*Y1->S			Add 2*f(x) to the sum s.

End                             Increment I by 1, then go back to beginning
of FOR loop unless I has reached M.

S-Y1->S				The program gets here with x = b, Y1 = 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.

S*H/3->R			The result (r) of Simpson's rule is s*h/3.

Disp "RESULT ",R		The calculator will display RESULT value

```
Ending: After pressing the ENTER key for the last command, Press the QUIT ("2nd" "MODE") key.

Running the program: First you have to type in the expression for the function you want to sum. Press the Y= key (under screen) and enter your function as Y1. Use the [X,T,theta] key for your variable. As a test, put in x to the 4th, i.e. [X,T,theta], then "^", then 4, then ENTER. Then press QUIT. Now to run the sum, press PRGM, select EXEC, and select SIMPSON (If that's what you called it.) The screen will display a prompt pgrmSIMPSON. press ENTER. Enter the A, B, N you want at the question mark (?) prompts.

Check: For Y1=f(x)= x^4, lower limit A = 0, upper limit B = 1, and N = 4, Simpson sum should be: .2005208333

Remark: To run the program again you can type ENTER just after it displays the answer, and it will prompt you for new A, B and N.

September 24 1998