Left Right Sums - TI 89 or TI 92

Introduction
This program computes left and right hand approximations for  $\int\limits_a^bf(x)dx$.
 
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.


If you have a TI Connectivity Cable, you can download the program main.lrsums.89p


The Program
:lrsums( ) {This will already appear if you named the program lrsums}
:Prgm {This will already appear}
:Lbl p {Lbl is in the CATALOG menu}
:Local a,b,n {Local is in the F4 menu}
:Input "a=", a {Input is in the F3 menu}
:Input "b=", b
:Input "n=", n
:(b-a)/n$\to$
:a$\to$x
:0$\to$l {The 0 is a zero}{The l is a lowercase L} 
:0$\to$ {The 0 is a zero} 
:For j,1,n {The 1 is a one}
:l+y1(x)*h$\to$ (The l is a lowercase L} {y1 is the Y button followed by a 1}
:x+h$\to$
:EndFor {For EndFor is in the F2 menu}
:l+y1(b)*h$\to$ {The l is a lowercase L}
:r-y1(a)*h$\to$
:(l+r)/2$\to$ {The l is a lowercase L}
:Disp "left", l {Disp is in the F3 menu} {l is a lowercase L}
:Disp "right", r
:Disp "average", t
:Pause {Pause is in the CATALOG menu}
:Goto p {Goto is in the CATALOG menu}
:EndPrgm {This will already appear}


Running the Program
 
You will need to enter a function f(x) into y1 before running the program. The program will ask for values of A, B, and N (number of subdivisions).
 
To test the program try the following:
  f(x)  =  x2+ 3,   A=1,   B=4,   N=20.
 
Your answer will be
left
28.88625
right
31.13625
average
30.01125