I really need help With this program
It is reimunns sum (Sp). Using trapazoidal estimation, Rectangle estimation, in both 2D and 3D. Circle and triangle in 3D. My right edge sum (2D Mode) IS way wacky. Getting severall hundred thousand times higher than the correct answer, Comments in the program say where all that is, and what all I need help with.
Code:
:Repeat 0
:Normal:a+bi:AxesOff:ClrDraw
:Text(0,0,"WHAT SHAPE ARE YOU USING?
:Text(6,10,"TWO DIMENSIONAL
:TExt(12,0,"SQUARE
:Text(18,0,"2.TRAPAZOID
:Text(30,10,"THREE DIMENSIONAL
:Text(36,0,"3.SQUARE
:Text(42,0,"4.CIRCLE
:Text(48,0,"5.TRIANGLE
:Text(54,0,"6.EXIT
:Repeat J
:getKey->J
:End
:If J=92
:.5->Z
:If J= 93
:1->G
:If J=94
:1->Z
:If J=83
:sqrt(3)/4->Z
:If J=82
:pi/8->Z
:ClrHome
:Input "TOP EQUATION",Str1
:String->Equ(Str1,Y1
:ClrHome
:Input "BOTTOM EQUATION",Str2
:String->Equ(Str2,Y2
:ClrHome
:Repeat Ymax>Ymin
:Input "LOWER BOUND Ymin",Ymin
:Input "UPPER BOUND Ymax",Ymax
:If Ymin<=Ymax:Then
:Disp "Ymin CANNOT BE >=","Ymax"
:Rand(90
:End
:End
:Repeat Xmax>Xmin
:Input "LEFT BOUND Xmin",Xmin
:Input "RIGHT BOUND Xmax",Xmax
:If Xmin>= Xmax:Then
:Disp "Xmin CANNOT BE >=","Xmax"
:rand(90
:End
:End
:abs(Xmin-Xmax->L
:Input "NUMBER OF PARTITIONS",N
:L/N->V
://V== partiton size
:If J=93:Then
:1->U
:For(X,Xmin,Xmax,V
://Change X from Xmin to Xmax, incrementing by the partion size
:ZV(2(X!=Xmin and X!=Xmax)(Y1-Y2)->L1(1+dim(L1
:If U=1
:Then
:L1(U)->T
:Else
:T+L1(U)+L1(U-1)->T
://not sure if this is right, this is supposed to be a trapazoidal
://sum estimation. Need Help with that one
:End
:U+1->U
:End
:Pause T
:End
:For(U,0,1,.5
://////////////////////////////////////////
://increments from 0, to .5 to 1
://For some reason my right edge sum is about 300Thousand bigger than it should be
://Right edge sum is found when U==1
://///////////////////////////////////////
:For(X,Xmin+VU,Xmax-VU,V
:0->theta
:if not(D:Then
:(VZ)(Y1-Y2)^2->theta
:Else
:V(Y1-Y2)->Theta
:End
://If D= any number, then we are finding a 3 dimensional sum
://if D=0 then We are finding a 2D Sum.
://I may end up making 2 separate loops for that. Going for speed here, not really size much
://so I would love your opinion on what is faster
:If not(U
:theta+L->L
:If U=.5
:theta+M->M
:if U=1
:theta+R->R
:End:End
:///////////////////////////////////////
://Displays just used for testing purposes. These will be removed in the
://final program
:///////////////////////////////////////
:Disp L,R
:Pause M
://///////////////////////////////////////////
://Somehow my Right Edge Sum "R" When U=1. Ends up several hundred thousand bigger
://than left and midpoint sums. Left and midpoint are correct. U=0, U=>5 respectively
://I cant find why this is..
://////////////////////////////////////////////
://Below here will show the graph of the functions and the partitions
://i had this working when my right edge sum worked. But here is the code anyway
://Speed optimizations welcomed
://////////////////////////////////////////////
:FnOff
:Text(0,40,"GRAPH
:Text(6,0,"1.LEFT EDGE SUM
:Text(12,0,"2.MID POINT SUM
:Text(18,0,"3.RIGHT EDGE SUM
:Text(24,0,"4.NONE
:Repeat J
:getKey->J
:End
:If J=82:Then
:Disp "LEFT EDGE SUM
:Pause L
:Disp "MID POINT SUM
:Pause M
:Disp "RIGHT EDGE SUM
:Pause R
:End
:AxesOn:FnOn
:If J=93:Then
:For(X,Xmin+V,Xmax,V
:Line(X,Y2,X,Y1
://///////////////////////////////////////////////////
://Draws a line between Y1 (Top Equation) And Y2(Bottom Equation)
://At every partition
://working on drawing the top of the "Rectangle" now.
://////////////////////////////////////////////////////
:End
:Text(0,0,Str1,"AND",Str2,"FROM",Xmin,"TO",Xmax
:Text(12,0,"RIGHT EDGE SUM,R
:Pause :End
:If J=92:Then
:For(X,XMin,Xmax,V
:Line(X,Y2,X,Y1
:End
:Text(0,0,Str1,"AND",Str2,"FROM",Xmin,"TO",Xmax
:Text(12,0,"LEFT EDGE SUM",L
:Pause :End
:If J=94:Then
:For(X,Xmin+(V/2),Xmax,V
:Line(X,Y2,X,Y1
:End
:Text(0,0,Str1,"AND",Str2,"FROM",Xmin,"TO",Xmax
:Text(12,0,"MIDPOINT SUM",M
:Pause :End
Thanks in advance for the help
Exactly where the problem part is
Code:
For(U,0,1,.5
:For(X,Xmin+VU,Xmax-VU,V
:0->theta
:if not(D:Then
:(VZ)(Y1-Y2)^2->theta
:Else
:V(Y1-Y2)->Theta
:End
://If D= any number, then we are finding a 3 dimensional sum
://if D=0 then We are finding a 2D Sum.
://I may end up making 2 separate loops for that. Going for speed here, not really size much
://so I would love your opinion on what is faster
:If not(U
:theta+L->L
:If U=.5
:theta+M->M
:if U=1
:theta+R->R
:End:End
Assume Y1 and Y2 are already inputed. You are finding the space between Xmin and Xmax.
Y1 is top equation
Y2 is bottom equation.
V is partition Size found from abs(Xmax-Xmin)/Number of partitons
Should be all you really need to know.
Left Edge (U==0) and Midpoint (U==.5) Come out fine. Right edge (U==1) Has major problems. The number is at least 100K Bigger than it should be. I am sure it is something small I am overlooking.
Thanks weregoose. again
EDIT: I Forgot to add that I have a program that runs at the front, that cleans up any problems. IT delvars all functions, and registers. And all variables. So no problems there.