! Decay, version 1. ! Ian R. Gatland, initiated 1997/08/11, last updated 1998/05/21. ! Based on "Decay" in "Computational Physics" by N. Giordano. program Decay1 library "IrGraphics*" option nolet id$ = "IRG: Decay1" dim t(0), n(0) call Init(nt, dt, t0, n0, r) mat redim t(0:nt), n(0:nt) t(0) = t0 n(0) = n0 call Calc(nt, dt, t(), n(), r) call Graph1A(id$, "time", "number", t(), n(), 1) print " t = "; t(nt) print " n = "; n(nt) print "Done" end sub Init(nt, dt, t0, n0, r) nt = 100 ! number of time steps dt = 0.01 ! time step t0 = 0 ! initial time n0 = 1 ! initial value r = 3 ! decay rate end sub sub Calc(nt, dt, t(), n(), r) for i = 1 to nt nd = - r*n(i-1) t(i) = t(i-1) + dt n(i) = n(i-1) + nd*dt next i end sub