Introduction
This program computes left, right, Trapezoid, Midpoint, and
Simpson's approximations for
.
If you have not used one of the programs posted on this website before,
you should read through
the information in the Intro to Programming
section first.
The Program
Note: The main program, ASUM, will
call a subprogram, SUMM. Both programs are given below.
| <<"N" ":N:" INPUT | |
| OBJ |
|
| "A" ":A:" INPUT | |
| OBJ |
|
| "B" ":B:" INPUT | |
| OBJ |
|
| 0 'SUM' STO | |
| B A - N / 'H' STO | |
| A 'X' STO | |
| SUMM SUM 'L' STO | |
| 0 'SUM' STO | |
| A H+'X' STO SUMM | |
| SUM 'R' STO | |
| 0 'SUM' STO | |
| A H 2 / + 'X' STO | |
| SUMM SUM 'M' STO | |
| L H * 'L' STO | |
| R H * 'R' STO | |
| M H * 'M' STO | |
| L R + 2 / 'T' STO | |
| 2 3 / M * T 3 / + 'S' STO | |
| L "LHAND" |
|
| R "RHAND" |
|
| M "MIDPT" |
|
| T "TRAP" |
|
| S "SIMPSON" |
|
| {A B N H L R T M S X SUM} | |
| PURGE>> | |
| ENTER 'ASUM' STO | {This stores the program under variable name ASUM.} |
| <<1 N FOR C FUNC | |
| EVAL SUM + 'SUM' STO X | |
| H + |
|
| STO NEXT>> | |
| ENTER 'SUMM' STO |
Running the Program
You will need to enter a function f(x) into
a variable called FUNC before running the program. Follow the instructions
in