Experiments with Schemes for Exponential Decay

Hans Petter Langtangen [1, 2] (hpl at simula.no)

[1] Center for Biomedical Computing, Simula Research Laboratory

[2] Department of Informatics, University of Oslo.

Jul 2, 2016

Summary. This report investigates the accuracy of three finite difference
schemes for the ordinary differential equation \( u'=-au \) with the
aid of numerical experiments. Numerical artifacts are in particular
demonstrated.

Numerical experiments

A set of numerical experiments has been carried out,
where \( I \), \( a \), and \( T \) are fixed, while \( \Delta t \) and
\( \theta \) are varied. In particular, \( I=1 \), \( a=2 \),
\( \Delta t = 1.25, 0.75, 0.5, 0.1 \).
Figure 1 contains four plots, corresponding to
four decreasing \( \Delta t \) values. The red dashed line
represent the numerical solution computed by the Backward
Euler scheme, while the blue line is the exact solution.
The corresponding results for the Crank-Nicolson and
Forward Euler methods appear in Figures 2
and 3.

Figure 1: The Backward Euler method for decreasing time step values.

Figure 2: The Crank-Nicolson method for decreasing time step values.

Figure 3: The Forward Euler method for decreasing time step values.

Error vs \( \Delta t \)

How the error
$$ E^n = \left(\int_0^T (Ie^{-at} - u^n)^2dt\right)^{\frac{1}{2}}$$
varies with \( \Delta t \) for the three numerical methods
is shown in Figure 4.

Observe:

The data points for the three largest \( \Delta t \) values in the
Forward Euler method are not relevant as the solution behaves
non-physically.

Figure 4: Variation of the error with the time step.

The \( E \) numbers corresponding to Figure 4
are given in the table below.