Trapezoid and Simpson's Methods on the TI-82/83

 

PROGRAM:TRAPSIMP

 

:Prompt A,B,N

 

:(B-A)/ND

D is x

:AX

X is assuming values of Xo, X1, X2, X3, ... etc.

:Y1S

S is storing the sums for the Simpson method

:Y1T

T is storing the sums for the Trapezoid method

:1C

C is counter, so that on the even index values, Simpson can be tested

:While X<B

 

:C+1C

 

:X+DX                                                       

Increment to next X

:S+2Y1S

Add f(xi) to both sums

:T+2Y1T

 

:If C/2=iPart(C/2)

 

:S+2Y1S

Increment for Simpson when value is 4f(xi)

:End

 

:S-Y1S

f(B) has been added in twice, so subtract it once

:T-Y1T

 

:Disp “TRAPEZOID ",DT/2

Multiply by h/2 for Trapezoid and display

:Disp “SIMPSON ",DS/3

Multiply by Ih/3 for Simpson and display

 

 

Test:     ;  n = 4;  i.e. 

  Gives   Trapezoid .2045      and   Simpson.2028