Site hosted by Angelfire.com: Build your free website today!
This program approximates a definite integral using the left-side, right-side, midpoint, trapezoid, and simpson's rule. A comparison with the calculator's own fnInt function is also provided. Note: -> is the 'store' arrow.
:Lbl F
:ClLCD
:Disp "Enter func:"
:InpSt "y=",xs
:St->Eq(xs,y1)
:
:Lbl ST
:ClLCD
:Eq->St(y1,xs)
:Input " Lower=", A
:Input " Upper=", B
:Input " # Div=",N
:(B-A)/N->H
:A->x
:0->L
:0->M
:1->I
:
:Lbl P
:L+H*y1->L
:x+.5x->x
:M+H*y1->M
:x+.5x->x
:IS>(I,N)
:Goto P
:L+H*y1->R
:A->x
:R-H*y1->R
:(L+R)/2->Tr
:(2*M+Tr)/3->S
:fnInt(y1,x,A,B)->Tru
:
:Lbl PRINT
:ClLCD
:Float
:Outpt(1,1,"y=")
:Outpt(1,4,xs)
:Outpt(1,17,"N=")
:Outpt(1,19,N)
:Outpt(2,2,"Left")
:Outpt(2,8,L)
:Outpt(3,2,"Right")
:Outpt(3,8,R)
:Outpt(4,2,"Trap")
:Outpt(4,8,Tr)
:Outpt(5,2,"Mid")
:Outpt(5,8,M)
:Outpt(6,2,"Simp")
:Outpt(6,8,S)
:Outpt(7,2,"Calc")
:Outpt(7,8,Tru)
:
:Lbl theMENU
:Menu(1,"Setup",SET,2,"Output",PRINT,3,"func",F,4,"lims",ST,5,"Quit",QT)
:
:Lb SET
:ClLCD
:Outpt(1,1,"y=")
:Outpt(1,4,xs)
:Outpt(2,1,"Limits")
:Outpt(3,3,"A=")
:Outpt(3,5,A)
:Outpt(4,3,"B=")
:Outpt(4,5,B)
:Outpt(5,1,"#divs:")
:Outpt(5,7,N)
:Goto theMENU
:
:Lbl QT
:"hey baby"
:ClLCD
The beginning block of code can be ommitted, but then the user needs to make sure a function has been entered (in the GRAPH, y(x)= screen) before using the program. I've checked for correctness, but I make no typo-free guarentees.
Last update: 09 01 2000
Back front