$m_inverse=1 /* this could be chosen as arbitrarily small, like 0.00001 to get effectively smaller time steps) */ $v=0 $theta=0 $dt=1 /* the time interval, you can also make this of arbitrary size */ while(!$done){ ($F_x,$F_y)=ForceCalculator($theta) /* call your magnetics library */ $F_perp=$F_x*sin(theta)+$F_y*cos($theta) $theta=$theta+$v*$dt $v=$v+$F_perp*$scale*dt }