The Central Idea
A continuous model may describe a state \(x(t)\) for every real time \(t\). A numerical simulation instead evaluates the model at selected time levels:
\[ t_0,\ t_1,\ t_2,\ldots. \]The central computational pattern is
\[ \boxed{ \text{current state} \longrightarrow \text{time-step rule} \longrightarrow \text{next state} }. \]Repeating this process produces an approximate trajectory of the evolving system.
What Is Time-Stepping?
Time-stepping is the numerical process of advancing a dynamic model from one discrete time level to another.
If
\[ t_n=t_0+n\Delta t, \]then \(\Delta t\) is the time-step size.
A simulation computes approximations
\[ x_0,\ x_1,\ x_2,\ldots \]intended to represent
\[ x(t_0),\ x(t_1),\ x(t_2),\ldots. \]Uniform Time Steps
The simplest time grid uses a constant step size:
\[ t_{n+1}=t_n+\Delta t. \]Starting at \(t_0=0\) with
\[ \Delta t=0.5, \]the time levels are
\[ 0,\ 0.5,\ 1.0,\ 1.5,\ 2.0,\ldots. \]Equal spacing makes indexing and many numerical formulas especially simple.
Number of Time Steps
If a simulation runs from \(t_0\) to \(T\) using a constant step size \(\Delta t\), then the number of intervals is
\[ \boxed{ N=\frac{T-t_0}{\Delta t} } \]when the quotient is an integer.
For example, from \(0\) to \(10\) seconds using
\[ \Delta t=0.25\text{ second}, \]the simulation uses
\[ N=\frac{10}{0.25}=40 \]time intervals.
Discrete Update Rules
Some models are already naturally discrete in time.
For example,
\[ P_{n+1}=1.03P_n \]says that the next population is \(3\%\) larger than the current population.
Starting from
\[ P_0=1000, \]the first two updates are
\[ P_1=1.03(1000)=1030, \] \[ P_2=1.03(1030)=1060.9. \]From Continuous Change to Discrete Change
Continuous dynamic models are often expressed with differential equations.
Consider
\[ \frac{dx}{dt}=f(t,x). \]Over a small time interval \(\Delta t\), the change in \(x\) can be approximated by
\[ \Delta x\approx \frac{dx}{dt}\Delta t. \]Using the model equation,
\[ \Delta x\approx f(t,x)\Delta t. \]The Basic Forward Update
If the current state is \(x_n\), then
\[ x_{n+1}\approx x_n+\Delta x. \]Substituting the estimated change gives
\[ \boxed{ x_{n+1} = x_n+\Delta t\,f(t_n,x_n) }. \]This is the basic forward Euler time-stepping rule.
Euler's Method
Euler's method estimates the next state using the derivative evaluated at the current state.
For
\[ \frac{dx}{dt}=f(t,x), \]the Euler update is
\[ \boxed{ x_{n+1}=x_n+\Delta t\,f(t_n,x_n) }. \]Geometrically, the method follows the current tangent direction for one finite time step.
Example: Constant Rate of Change
Suppose
\[ \frac{dx}{dt}=4, \qquad x(0)=3. \]With
\[ \Delta t=0.5, \]Euler's method gives
\[ x_1=x_0+(0.5)(4)=3+2=5. \]The next step gives
\[ x_2=5+(0.5)(4)=7. \]Because the derivative is constant, Euler's method is exact for this model.
Example: Exponential Growth
Consider
\[ \frac{dP}{dt}=0.1P, \qquad P(0)=100. \]With \(\Delta t=1\),
\[ P_{n+1} = P_n+(1)(0.1P_n) = 1.1P_n. \]Therefore,
\[ P_1=110, \] \[ P_2=121. \]The continuous growth law has become a discrete update rule.
Example: Exponential Decay
Suppose
\[ \frac{dQ}{dt}=-0.2Q, \qquad Q(0)=50. \]Using \(\Delta t=1\),
\[ Q_{n+1} = Q_n-0.2Q_n = 0.8Q_n. \]Thus,
\[ Q_1=40, \] \[ Q_2=32. \]Time-Stepping as a Loop
A basic simulation can be represented by pseudocode:
SET t = initial_time
SET x = initial_state
REPEAT until final_time is reached
COMPUTE rate = f(t, x)
COMPUTE x_new = x + dt * rate
SET t = t + dt
SET x = x_new
RECORD t, x
END REPEAT
This pattern appears throughout computational science.
State, Rate, and Increment
It is useful to distinguish three quantities:
- the current state \(x_n\);
- the current rate \(f(t_n,x_n)\);
- the estimated increment \(\Delta t\,f(t_n,x_n)\).
The update is then
\[ \boxed{ \text{next state} = \text{current state} + \text{estimated increment} }. \]The Role of Step Size
The time-step size \(\Delta t\) controls how far the simulation advances before recomputing the model's rate of change.
A smaller \(\Delta t\) generally samples the evolving dynamics more frequently. A larger \(\Delta t\) advances more quickly but may miss important changes.
This creates the fundamental tradeoff
\[ \boxed{ \text{smaller time steps} \Rightarrow \text{usually greater numerical detail and greater cost} }. \]Coarse and Fine Time Steps
Suppose a process is simulated for \(10\) seconds.
With
\[ \Delta t=1, \]there are \(10\) time intervals.
With
\[ \Delta t=0.1, \]there are \(100\) time intervals.
The second simulation performs ten times as many updates over the same duration.
Local Time-Stepping Error
A numerical method approximates the exact evolution over each step.
The error introduced during one step is called a local discretization error or local truncation error.
For a curved trajectory, following the tangent line for a finite interval does not generally land exactly on the true solution curve.
Reducing \(\Delta t\) often reduces this local error.
Accumulated Error
A simulation may perform thousands or millions of updates. Small errors made at individual steps can accumulate.
The resulting difference between the numerical trajectory and the exact trajectory over many steps is a global numerical error.
Accurate time-stepping therefore depends not only on one update, but on how errors propagate across the full simulation.
Refining the Time Step
A standard numerical check is to repeat the simulation using smaller values of \(\Delta t\).
For example:
\[ \Delta t=0.4,\qquad 0.2,\qquad 0.1,\qquad 0.05. \]If the computed result stabilizes as the step size decreases, the calculation may be converging with respect to time resolution.
Convergence Under Time-Step Refinement
Ideally,
\[ \boxed{ \text{numerical solution} \longrightarrow \text{continuous-model solution} \quad\text{as}\quad \Delta t\to0 }. \]Whether this occurs depends on both the time-stepping method and the mathematical problem.
A method that does not approach the intended solution under refinement is not suitable for the problem.
Stability
Numerical stability concerns whether errors and perturbations remain controlled as the simulation advances.
A method may use a mathematically valid update formula but behave poorly when the time step is too large.
Instability can appear as:
- unphysical oscillation;
- rapid numerical growth;
- sign changes that should not occur;
- overflow;
- loss of meaningful accuracy.
A Simple Stability Example
Consider the decay equation
\[ \frac{dx}{dt}=-kx, \qquad k>0. \]Euler's method gives
\[ x_{n+1} = x_n-k\Delta t\,x_n. \]Therefore,
\[ \boxed{ x_{n+1}=(1-k\Delta t)x_n }. \]The numerical behavior depends directly on the factor \(1-k\Delta t\).
When the Step Is Too Large
Suppose
\[ k=1 \]and
\[ \Delta t=3. \]Then
\[ 1-k\Delta t=1-3=-2. \]The numerical update becomes
\[ x_{n+1}=-2x_n. \]Instead of decaying smoothly toward zero, the computed values alternate signs and double in magnitude. The time step has produced unstable numerical behavior.
Accuracy and Stability Are Different
A stable simulation is not necessarily accurate.
A method can remain bounded while still producing values that differ substantially from the intended solution.
Likewise, a formula may be accurate for sufficiently small steps but unstable for larger ones.
Time-step selection must therefore consider both accuracy and stability.
Multiple State Variables
Many dynamic systems contain several interacting state variables.
Suppose
\[ \frac{dx}{dt}=f(x,y), \] \[ \frac{dy}{dt}=g(x,y). \]A forward Euler step gives
\[ x_{n+1} = x_n+\Delta t\,f(x_n,y_n), \] \[ y_{n+1} = y_n+\Delta t\,g(x_n,y_n). \]Simultaneous State Updates
In a coupled system, all next-state values should normally be calculated from the same current state before the current state is replaced.
COMPUTE dx = f(x, y)
COMPUTE dy = g(x, y)
COMPUTE x_new = x + dt * dx
COMPUTE y_new = y + dt * dy
SET x = x_new
SET y = y_new
Updating \(x\) before computing the new \(y\) may change the numerical model.
Vector Form
A system of state variables can be collected into a vector
\[ \mathbf{x}(t). \]If
\[ \frac{d\mathbf{x}}{dt} = \mathbf{f}(t,\mathbf{x}), \]then the Euler update becomes
\[ \boxed{ \mathbf{x}_{n+1} = \mathbf{x}_n + \Delta t\,\mathbf{f}(t_n,\mathbf{x}_n) }. \]This compact form applies to systems with two variables, hundreds of variables, or far more.
Time-Stepping a Position-Velocity Model
Suppose position \(x\) and velocity \(v\) satisfy
\[ \frac{dx}{dt}=v, \] \[ \frac{dv}{dt}=a. \]A basic forward step gives
\[ x_{n+1}=x_n+\Delta t\,v_n, \] \[ v_{n+1}=v_n+\Delta t\,a_n. \]Position and velocity are advanced together through time.
Example: Constant Acceleration
Let
\[ x_0=0,\qquad v_0=10,\qquad a=-2, \]with
\[ \Delta t=1. \]Then
\[ x_1=0+(1)(10)=10, \] \[ v_1=10+(1)(-2)=8. \]The next Euler step gives
\[ x_2=10+(1)(8)=18, \] \[ v_2=8-2=6. \]Explicit Methods
An explicit time-stepping method computes the next state directly from information already known at the current or previous time levels.
Forward Euler is explicit:
\[ x_{n+1} = x_n+\Delta t\,f(t_n,x_n). \]The right side contains only known quantities when the step begins.
Implicit Methods
An implicit time-stepping method may define the next state using the next state itself.
A basic implicit form is
\[ x_{n+1} = x_n+\Delta t\,f(t_{n+1},x_{n+1}). \]Because \(x_{n+1}\) appears on both sides, an algebraic equation or system must usually be solved at each step.
Explicit Versus Implicit Tradeoffs
Explicit methods are often easier and cheaper per step.
Implicit methods may require more work per step because they involve solving an equation, but they can have stronger stability properties for some problems.
There is therefore no universally best time-stepping method. The appropriate choice depends on the dynamics, required accuracy, stiffness, computational cost, and model structure.
Fixed and Adaptive Time Steps
A fixed-step simulation uses one constant value of \(\Delta t\).
An adaptive method changes the time-step size during the simulation.
Conceptually,
\[ \Delta t \longrightarrow \Delta t_n. \]Smaller steps can be used during rapid change and larger steps during smoother behavior.
Why Adaptive Stepping Can Help
Some dynamic systems spend long periods changing slowly and short periods changing rapidly.
A single very small step size may waste computation during the slow periods. A single large step may miss the rapid behavior.
Adaptive stepping attempts to allocate computational effort where the model needs it most.
Events in a Simulation
Some models contain events that occur when a condition becomes true.
Examples include:
- a projectile reaching the ground;
- a tank becoming empty;
- a population crossing a threshold;
- a machine failing;
- a control system switching modes;
- a queue reaching capacity.
Time-stepping implementations should detect and handle such events explicitly.
Crossing a Threshold Between Steps
Suppose a simulation checks a quantity only at
\[ t_n \]and
\[ t_{n+1}. \]A threshold may actually be crossed somewhere between those two times.
A coarse time step may therefore report the event late unless interpolation or more precise event detection is used.
Stopping Conditions
A simulation may stop when:
- a final time is reached;
- a fixed number of steps has been completed;
- a state threshold is crossed;
- a steady state is reached;
- an error tolerance is satisfied;
- an event terminates the modeled process.
The stopping condition is part of the time-stepping algorithm.
Recording the Simulation History
A simulation often records the state at each time level:
\[ (t_0,x_0),\quad (t_1,x_1),\quad (t_2,x_2),\ldots. \]These stored values can later be used for:
- tables;
- graphs;
- animations;
- error analysis;
- comparison with observations;
- parameter studies.
Not Every Step Must Be Saved
A simulation may use a very small internal time step but record outputs less frequently.
For example, the model might compute every
\[ 0.001\text{ second} \]but save results every
\[ 0.1\text{ second}. \]Computational resolution and output resolution do not have to be identical.
Time-Step Selection and Physical Scales
The time step should be small enough to resolve the fastest important dynamics in the model.
If a phenomenon changes substantially over a characteristic time scale
\[ \tau, \]then a step size much larger than \(\tau\) may fail to represent that behavior.
Time-step selection should therefore reflect the scales present in the modeled system.
Dimensionless Step Size
A useful comparison is sometimes formed by dividing the time step by a characteristic time scale:
\[ \frac{\Delta t}{\tau}. \]This ratio measures the numerical step relative to the system's natural time scale.
Such dimensionless comparisons often help organize stability and resolution requirements.
Time-Stepping and Spatial Discretization
Many simulations discretize both space and time.
A field may be represented as
\[ u_i^n, \]where \(i\) indexes spatial location and \(n\) indexes time.
The simulation then updates the entire spatial field from time level \(n\) to time level \(n+1\).
A Space-Time Grid
In one spatial dimension,
\[ x_i=x_0+i\Delta x \]and
\[ t_n=t_0+n\Delta t. \]A computed solution can therefore be viewed on the discrete lattice
\[ (x_i,t_n). \]Finite-difference simulations commonly use this space-time structure.
Time-Step Restrictions
In some spatial simulations, \(\Delta t\) cannot be chosen independently of \(\Delta x\).
Stability may require a relationship of the general form
\[ \Delta t \le C(\Delta x)^p, \]where \(C\) and \(p\) depend on the equation and numerical method.
This means that refining the spatial grid may force the simulation to use smaller time steps as well.
Verification by Hand
The first few time steps should often be simple enough to check manually.
Suppose
\[ x_{n+1}=x_n+0.5(2x_n), \qquad x_0=4. \]Then
\[ x_1=4+0.5(8)=8. \]If the implementation produces something else, the update rule, parameter, indexing, or initialization should be inspected.
Check the Time Index
A common implementation error is to associate the wrong state with the wrong time.
If the simulation begins at
\[ t_0=0 \]with state \(x_0\), then after one step the new state \(x_1\) corresponds to
\[ t_1=t_0+\Delta t. \]The state should be recorded after the time has been advanced consistently.
Check Conservation Laws
Some dynamic models conserve a quantity such as total mass, total probability, or another invariant.
If the mathematical model requires
\[ M(t)=M_0, \]then the numerical simulation should be checked for unacceptable drift in \(M\).
Conservation checks can expose time-stepping or implementation errors.
Check Positivity and Bounds
A model may require quantities to remain inside a restricted range.
For example,
\[ P_n\ge0 \]for population, or
\[ 0\le p_n\le1 \]for probability.
If a time-stepping method violates these bounds, the step size, method, or model formulation may require attention.
Common Error: Using the Wrong Time Step
If the intended simulation uses
\[ \Delta t=0.01, \]but the implementation accidentally uses
\[ \Delta t=0.1, \]every update is ten times larger than intended.
Time-step values should be defined explicitly and reported with the simulation configuration.
Common Error: Updating Variables Sequentially
In a coupled system, replacing one state variable before all new values have been computed can change the equations being simulated.
The safe pattern is
\[ \text{old state} \longrightarrow \text{compute all new values} \longrightarrow \text{replace old state}. \]Common Error: Assuming Smaller Steps Fix Everything
Reducing \(\Delta t\) can reduce time-discretization error, but it cannot repair:
- incorrect model equations;
- wrong parameters;
- incorrect initial conditions;
- coding errors;
- inappropriate boundary conditions;
- poor spatial resolution;
- invalid modeling assumptions.
Time-step refinement is one diagnostic, not a substitute for full model verification and validation.
Common Error: Taking a Step Beyond the Final Time
Suppose the simulation should stop at
\[ T=1 \]but the current time is \(0.95\) and
\[ \Delta t=0.1. \]A full step reaches \(1.05\), beyond the requested final time.
The implementation may need to shorten the final step or otherwise handle the endpoint deliberately.
Common Error: Comparing Simulations at Different Times
Two simulations using different time steps may store results at different time levels.
Comparing \(x_n\) from one simulation directly with \(x_n\) from another may be meaningless if the corresponding times differ.
Numerical results should be compared at matching physical times.
A Reliable Time-Stepping Workflow
- Identify the dynamic state variables.
- Specify the initial time and initial state.
- Write the differential or discrete update laws.
- Choose a time-stepping method.
- Select an initial time-step size.
- Compute all next-state values from the current state.
- Advance the time index consistently.
- Apply constraints, boundaries, and event checks.
- Record the required outputs.
- Repeat until the stopping condition is reached.
- Repeat the simulation with smaller \(\Delta t\).
- Check accuracy, stability, and qualitative behavior.
Practice 1: Construct the Time Grid
A simulation runs from \(t=0\) to \(t=2\) using
\[ \Delta t=0.5. \]List all time levels.
Practice 2: Count the Steps
A simulation runs from \(t=0\) to \(t=6\) with
\[ \Delta t=0.25. \]How many time intervals are used?
Practice 3: One Euler Step
Use Euler's method for
\[ \frac{dx}{dt}=3x \]with
\[ x_0=2,\qquad \Delta t=0.1. \]Find \(x_1\).
Practice 4: Two Euler Steps
Continue Practice 3 for one additional step and find \(x_2\).
Practice 5: Decay Update
For
\[ \frac{dQ}{dt}=-0.5Q, \]write the Euler update formula when
\[ \Delta t=0.2. \]Practice 6: Simultaneous Updates
A system is
\[ \frac{dx}{dt}=x+y, \] \[ \frac{dy}{dt}=x-y. \]Write the forward Euler update formulas using time step \(\Delta t\).
Practice 7: Refinement
A simulation currently uses
\[ \Delta t=0.08. \]If the time step is halved twice, what step size results?
Practice 8: Identify the Stability Warning
A model represents a decaying physical quantity, but the computed solution begins alternating signs and increasing in magnitude.
What numerical issue should be investigated first?
Practice Answers
Practice 1
\[ \boxed{ 0,\ 0.5,\ 1.0,\ 1.5,\ 2.0 }. \]Practice 2
\[ N=\frac{6}{0.25}=\boxed{24}. \]Practice 3
Euler's method gives
\[ x_1 = x_0+\Delta t(3x_0). \]Therefore,
\[ x_1 = 2+0.1(6) = \boxed{2.6}. \]Practice 4
\[ x_2 = 2.6+0.1(3\cdot2.6) \] \[ = 2.6+0.78 = \boxed{3.38}. \]Practice 5
\[ Q_{n+1} = Q_n+0.2(-0.5Q_n) \] \[ = \boxed{0.9Q_n}. \]Practice 6
\[ \boxed{ x_{n+1} = x_n+\Delta t(x_n+y_n) } \]and
\[ \boxed{ y_{n+1} = y_n+\Delta t(x_n-y_n) }. \]Practice 7
Halving once gives
\[ 0.04, \]and halving again gives
\[ \boxed{0.02}. \]Practice 8
Investigate numerical instability, especially whether the selected time step is too large for the chosen time-stepping method.
What to Remember
Time-stepping advances a dynamic computational model through discrete increments of time.
- time levels are commonly written \(t_n=t_0+n\Delta t\);
- the time-step size controls temporal resolution;
- Euler's method uses \(x_{n+1}=x_n+\Delta t\,f(t_n,x_n)\);
- coupled state variables should usually be updated simultaneously;
- smaller steps often reduce error but increase computational cost;
- stability and accuracy are distinct requirements;
- refinement studies help test sensitivity to \(\Delta t\);
- events, boundaries, stopping rules, and output times must be handled explicitly.
The central principle is: advance the system in steps small enough and with a method reliable enough to preserve the behavior that matters.
Where We Go Next
Time-stepping describes how a system evolves from one time level to the next. Some simulations, however, model many individual entities whose local behaviors and interactions collectively generate large-scale patterns.
The next lesson, Agent-Based Models, examines computational systems built from interacting agents with individual states, rules, decisions, neighborhoods, and emergent behavior.