Summary. This report investigates the accuracy of three finite difference
schemes for the ordinary differential equation with the
aid of numerical experiments. Numerical artifacts are in particular
Table of contents
We address the initial-value problem
where , , and are prescribed parameters, and is
the unknown function to be estimated. This mathematical model
is relevant for physical phenomena featuring exponential decay
We introduce a mesh in time with points .
For simplicity, we assume constant spacing between the
mesh points: , . Let
be the numerical approximation to the exact solution at .
The -rule is used to solve (REF to equation ode not supported) numerically:
for . This scheme corresponds to
The numerical method is implemented in a Python function
solver (found in the decay_mod module):
def solver(I, a, T, dt, theta): """Solve u'=-a*u, u(0)=I, for t in (0,T] with steps of dt.""" dt = float(dt) # avoid integer division N = int(round(T/dt)) # no of time intervals T = N*dt # adjust T to fit time step dt u = zeros(N+1) # array of u[n] values t = linspace(0, T, N+1) # time mesh u = I # assign initial condition for n in range(0, N): # n=0,1,...,N-1 u[n+1] = (1 - (1-theta)*a*dt)/(1 + theta*dt*a)*u[n] return u, t
We define a set of numerical experiments where , , and are
fixed, while and are varied.
In particular, , , .
How varies with for
is shown in Figure 1.