' fsprlib.bas - jackord@kw.igs.net - revised 18 Mar 04 - Liberty Basic v4.00 ' Initialize Window nomainwin WindowWidth=410 ' pixel scale 0-400 WindowHeight=329 ' pixel scale 0-300 UpperLeftX=100: UpperLeftY=100 open "Spring" for graphics_nsb as #1 #1 "trapclose [quit]" #1 "cls ; down ; color blue" xsc=400/.83: ysc=300/.23 m=2: k=200: gr=9.8: dt=.005: ym=0 t=0: y=0: v=0: a=0-gr-k*y/m ' Feynman algorithm #1 "place "; int(xsc*(t+.1)); " "; int(ysc*(.02-y)) v=v+a*dt/2: vo=v while vo<0 or v>=0 ' test for return vo=v: t=t+dt: y=y+v*dt: a=0-gr-k*y/m: v=v+a*dt #1 "goto "; int(xsc*(t+.1)); " "; int(ysc*(.02-y)) if vo<0 and v>=0 then ym=y ' test for bottom wend t=t+dt/2-v/a ' correct time #1 "color black ; place 80 15" #1 "\Ymin = "; ym; " (expect "; 0-2*m*gr/k; ")" #1 "\Yret = "; y; " (expect 0)" #1 "\Time = "; t; " (expect "; .8*atn(1); ")" wait [quit] close #1 end