' ftablib.bas - jackord@kw.igs.net - revised 18 Mar 04 - Liberty Basic v4.00 ' Euler and Feynman tables for the motion of a mass attached to a spring. ' The mass is initially passing through the equilibrium position at 2.8 m/s, ' and the motion is followed for 1 s at 1/n s intervals. ' The Euler Algorithm uses: y(t + dt) = y(t) + v(t) * dt ' v(t + dt) = v(t) + a(t) * dt ' The Feynman Algorithm uses: y(t + dt) = y(t) + v(t + dt/2) * dt ' v(t + dt/2) = v(t - dt/2) + a(t) * dt k=8: m=2: n=5: dt=.2 print "Euler Algorithm": print print "Time", "Position", "Velocity", "Acceleration" t=0: y=0: v=2.8: a= 0-k*y/m print t, y, v, a for i = 1 TO n t=t+dt: y=y+v*dt: v=v+a*dt: a=0-k*y/m print t, y, v, a next i print: print: print "Feynman Algorithm": print print "Time", "Position", "Velocity", "Acceleration" t=0: y=0: v=2.8: a=0-k*y/m print t, y, v, a v=v+a*dt/2 for i=1 TO n t=t+dt: y=y+v*dt: a=0-k*y/m print , , v: print t, y, , a v=v+a*dt next i end