! Friction, version 1. ! John Wise, initiated 2001/01/12, last updated 2001/01/12. ! Based on "Decay" in "Computational Physics" by N. Giordano. program Friction library "IrGraphics*" option nolet id$ = "JHW: Friction, nt:100" dim t(0), v(0) call Init(nt, dt, t0, v0, a) mat redim t(0:nt), v(0:nt) t(0) = t0 v(0) = v0 call Calc(nt, dt, t(), v(), a) call Graph1A(id$, "Time", "Velocity", t(), v(), 1) print " t = "; t(nt) print " v = "; v(nt) print "Done" end sub Init(nt, dt, t0, v0, a) nt = 100 ! number of time steps dt = 0.1 ! time step t0 = 0 ! initial time v0 = 0 ! initial value a = 10 ! terminal velocity end sub sub Calc(nt, dt, t(), v(), a) for i = 1 to nt nd = a - v(i-1) t(i) = t(i-1) + dt v(i) = v(i-1) + nd*dt next i end sub