Graphing Calculator Programs
for

Calculus Applied to the Real World
Numerical Integration:
Trapezoid and Simpson Approximations

              Text on Numerical Integration
Index of On-Line Topics
Return to Main Page
Everything for Calculus
Utility: Numerical Integration Utility

Graphing Calculator Program to Compute Left- and Right-Hand Riemann Sums and Trapezoid Rule (TI-83)

PROGRAM: TRAP
:Input ("N? ",N) Prompts for the number of rectangles
:Input ("LEFT ENDPOINT? ",A) Prompts for the left end-point a
:Input ("RIGHT ENDPOINT? ",B) Prompts for the right end-point b
:(B-A)/ND D is x = (b-a)/n
: 0R Set R to 0 (zero); it will eventually be the right-hand sum
: 0L Set L to 0 (zero); it will eventually be the left-hand sum
:AX X is the current x-coordinate
:For (I,1,N) Start of a loop-recall the sigma notation
:L+Y1L Increment L by the by f(xi-1)
:A+I*DX Corresponds to our formula xi = a + ix
:R+Y1R Increment R by f(xi)
:End End of loop
:L*DL Left sum
:R*DR Right sum
:(L+R)/2T Trapezoidal sum
:Disp "LEFT SUM IS ",L
:Disp "RIGHT SUM IS ",R
:Disp "TRAP SUM IS ",T
:Stop


Graphing Calculator Program for Simpson's Rule (TI-83)

PROGRAM: SIMP
:Input ("EVEN NUMBER N³2? ",N) Make sure that N is even and at least 2
:Input ("LEFT ENDPOINT? ",A)
:Input ("RIGHT ENDPOINT? ",B)
:(B-A)/ND
:0S Set S to 0 (zero)
:AX
:For (I,1,N-1,2) The loop increments I in by 2 each time
:S+Y1S The next four steps compute the sum
:A+I*DX f(xi-1) + 4f(xi) + f(xi+1)
:S+4* Y1S
:X+DX
:S+Y1S
:End
:S*D/3S Multiply by x/3
:Disp "SIMPSON SUM IS ",S
:Stop


Using the Programs

First enter the function f(x) whose sums you wish to compute as Y1 in the "Y=" window. Then run the program. It will first ask for N, which is the number of partitions you wish to use. Enter the number (which must be at least 1) and then press ENTER. (If you are running SIMP, make sure that the number you enter is even.) Next, it will ask for the values of A and B in that order, so you enter them in the same way. Then wait a while (the larger N is, the longer the wait), and the answers will appear.