Introduction
This program computes left and right hand approximations for
. It also includes the average of the approximations.
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, LRSUM, 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 | |
FUNC EVAL 'D' STO | |
SUMM SUM 'L' STO | |
N H*A + 'X' STO | |
FUNC EVAL SUM + 'R' STO | |
R D - 'R' STO | |
L H * 'L' STO | |
R H * 'R' STO | |
L R + 2 / 'T' STO | |
"ESTIMATES" | |
L "LEFT" ![]() |
|
R "RIGHT" ![]() |
|
T "AVG" ![]() |
|
{A B N H L R T D X SUM} | |
PURGE >> | |
ENTER 'LRSUM' STO | {This stores the program under variable name LRSUM.} |
<<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