← Mathematical Foundations

01 · Lesson 10

Numerical methods

A numerical method replaces a continuous or otherwise difficult mathematical problem with finite calculations. It produces an approximation whose accuracy must be investigated, not assumed.

Scenario: an epidemic equation has no convenient formula

Coupled SIR or SEIR equations contain interacting state variables. Even when the model is clearly defined, an explicit formula for every compartment may be unavailable. A computer can approximate the trajectory at selected times.

Euler’s method

For \(dy/dt=f(t,y)\), choose time step \(h>0\). Euler’s update is

\[t_{n+1}=t_n+h,\qquad y_{n+1}=y_n+h f(t_n,y_n).\]

The derivative gives a local slope. Multiplying by \(h\) approximates change over one step. Adding that change gives the next state.

Worked one-step interpretation

For medicine elimination \(dA/dt=-0.2A\), with \(A_0=100\) mg and \(h=0.5\) hour,

\[A_1=100+0.5(-0.2\times100)=90\text{ mg}.\]

This is an approximation at \(t=0.5\). The exact exponential solution gives about \(90.48\) mg, so the method has introduced numerical error.

Sources of numerical error

ErrorMeaning
Local truncation errorError introduced during one idealised step
Global errorAccumulated difference across the computed interval
Round-off errorFinite computer representation of real numbers
Statistical errorFinite-sample uncertainty in stochastic simulation; not the same as discretisation error

Step refinement and convergence

Repeat the calculation using \(h\), \(h/2\) and \(h/4\). If relevant outcomes approach stable values, this provides evidence of numerical convergence. Agreement is not proof that the biological model is correct; it checks the calculation for that model.

Euler’s method is first order: under standard conditions, halving \(h\) approximately halves global discretisation error. Higher-order methods can achieve greater accuracy per step.

Stability and biological validity

A mathematically valid ODE can produce an unstable numerical trajectory when a method or time step is unsuitable. Large steps may create oscillation, negative compartments or artificial growth.

The test \(h>0\) is a logical validity condition. A tolerance such as \(|S+I+R-N|<10^{-12}\) instead handles small floating-point discrepancies. These are different uses of comparison.

Beyond ODEs

Numerical methods also approximate PDEs on spatial grids, optimise parameters, solve linear systems, simulate random processes and integrate SDEs. Each method has assumptions and diagnostics appropriate to its problem class.

What this lesson adds

You can now interpret a numerical update, distinguish numerical errors, perform step refinement, and separate numerical verification from biological model validation.