$$
\newcommand{\uex}{{u_{\small\mbox{e}}}}
\newcommand{\Aex}{{A_{\small\mbox{e}}}}
\newcommand{\half}{\frac{1}{2}}
\newcommand{\Oof}[1]{\mathcal{O}(#1)}
$$
Implementation
Model:
$$
u'(t) = -au(t),\quad t\in (0,T], \quad u(0)=I
$$
Numerical method:
$$
u^{n+1} = \frac{1 - (1-\theta) a\Delta t}{1 + \theta a\Delta t}u^n
$$
for \( \theta\in [0,1] \). Note
- \( \theta=0 \) gives Forward Euler
- \( \theta=1 \) gives Backward Euler
- \( \theta=1/2 \) gives Crank-Nicolson