' h5alib.bas - jackord@kw.igs.net - revised 10 Sep 02 - Liberty Basic v3.01 ' Initialize Window nomainwin button#1, "BB1", [bb1], UL, 203, 10, 30, 20 button#1, "BB2", [bb2], UL, 236, 10, 30, 20 button#1, "BB3", [bb3], UL, 269, 10, 30, 20 button#1, "HO1", [ho1], UL, 302, 10, 30, 20 button#1, "HO2", [ho2], UL, 335, 10, 30, 20 button#1, "HO3", [ho3], UL, 368, 10, 30, 20 WindowWidth=610 ' pixel scale 0-600 WindowHeight=329 ' pixel scale 0-300 UpperLeftX=10: UpperLeftY=100 open "Harmonic Oscillator and Bouncing Ball Eigenvalues" for graphics_nsb as #1 ' no slide bars #1 "trapclose [quit]" gosub [grid] [waitHere] wait [bb1] k=1: b=2: c=3: yo=0: vo=2: goto [eigen] [bb2] k=1: b=3: c=5: yo=0: vo=4: goto [eigen] [bb3] k=1: b=5: c=6: yo=0: vo=8: goto [eigen] [ho1] k=2: b=.5: c=1.5: yo=.8: vo=0: goto [eigen] [ho2] k=2: b=2: c=4: yo=0: vo=2: goto [eigen] [ho3] k=2: b=4: c=6: yo=.8: vo=0: goto [eigen] [eigen] gosub [grid] #1 "color blue" de=.00001 ' Bisection Algorithm e=b: gosub [fey]: yb=y e=c: gosub [fey]: yc=y if yb*yc<0 then while c-b>de e=(b+c)/2: gosub [fey] if y*yb>0 then b=e else c=e wend #1 "color red": e=(b+c)/2: gosub [fey] #1 "place 220 260" #1 "\Energy EigenValue = "; left$(str$(e), 7) #1 "\Probability z>1 = "; 1-s1/s goto [waitHere] [fey] i=0: n=500: dx=.002 x=0: y=yo: v=vo: s=y*y*dx/2: #1 "place 0 "; int(150*(1-y)) if k=1 then a=e*e*e*(x-1)*y else a=e*e*(x*x-1)*y v=v+a*dx/2 while y>0-1 and y<1 and x<3 i=i+1: x=x+dx: y=y+v*dx: #1 "goto "; int(200*x); " "; int(150*(1-y)) if k=1 then a=e*e*e*(x-1)*y else a=e*e*(x*x-1)*y v=v+a*dx if x<1 or v*y<0 then s=s+y*y*dx if i=n then s1=s-y*y*dx/2 end if wend return [grid] #1 "cls": #1 "down": #1 "color black" #1 "line 0 150 600 150" #1 "line 200 0 200 300" #1 "line 400 0 400 300" return [quit] close #1 end