Fundamentals of Iterative Prediction with Varying Force
It is rare to have a force which is perfectly constant, and iterative analysis of more realistic varying-force systems is substantially more complicated. A toy model demonstrates how programs may be written to analyze these systems.
Main Idea
The physics of iterative prediction with varying force is the same as for prediction with constant force, but it is necessary to generalize the mathematical expressions, which adds complexity to the code.
A Mathematical Model
To begin with, consider a one dimensional force, which may vary with both space and time. Then we write this as [math]\displaystyle{ F(x,t) }[/math]. Now, using the momentum principle, we know that [math]\displaystyle{ F = \frac{\text{d}p}{\text{d}t} }[/math], which in discrete terms is [math]\displaystyle{ \Delta p = F\Delta t }[/math].
Just as with a constant force, this lets us write out for some iteration at [math]\displaystyle{ (x_0,t_0) }[/math] that
<math> p_{final} = p_{initial} + F(x_0,t_0) <\math>
Which we combine with kinematics to produce a new position and time <math> (x_1, t_1) <math>.