Numerical methods for ODEs

Initial value problem

Given $f: \R\times \R^d \to \R^d$ and $\v y_0\in \R^d$, consider an initial value problem $$ \begin{align*} \v y' ={}& \v f(t, \v y), \quad 0\leq t\leq T, \\ \v y(0) ={}& \v y_0. \end{align*} $$

For a certain step size $h>0$, seek an approximation $\v y_{n} \approx \v y(t_n)$ where $t_n = nh$.

Definition (convergent method) open_in_new

Suppose given a step size $h>0$, a numerical method generates $(\v y_n^{(h)})_{n=0}^N$ where $N = \lfloor T/h\rfloor$.

We say the method is convergent if $$ \begin{align*} \max_{n} \|\v y_n^{(h)} - \v y(t_n)\| \to 0 \qquad \text{as }h\to 0. \end{align*} $$

Definition (local truncation error, order of method) open_in_new

The local truncation error of a numerical method is the error of the method assuming we have obtained the true solution previously: for a method $\v y_{n+1} = \v ϕ(t_n, \v y_0, \ldots, \v y_n)$, the local truncation error is $$ \begin{align*} \v η_{n+1} = \v y(t_{n+1}) - \v ϕ(t_n, \v y(t_{0}), \ldots, \v y(t_n)). \end{align*} $$

We say the method has order $p$ if $\v η_{n+1} = O(h^{p+1})$ where $h$ is the step size.

One-step methods open_in_new

Euler's method open_in_new
Euler method

For an initial value problem, $$ \begin{align*} \v y_{n+1} = \v y_n + h \v f(t_n, \v y_n). \end{align*} $$

Theorem (convergence of the Euler method) open_in_new

For an initial value problem, suppose

  • $\v y''$ is bounded on $[0,T]$; and

  • $\v f$ is Lipschitz in $\v y$, i.e. $\|\v f(t,\v x) - \v f(t, \v y)\| \leq λ\|\v x - \v y\|$ for all $0\leq t\leq T$ and $\v x,\v y\in \R^d$.

Then the Euler method has order 1 and is convergent, with global error $\v e_n := \v y(t_n) - \v y_n = O(h)$.

Proof

Theta methods open_in_new
Theta methods

For an initial value problem and some $θ\in [0,1]$, $$ \begin{align*} \v y_{n+1} = \v y_n + h\bigl(θ\,\v f(t_n, \v y_n) + (1-θ)\, \v f(t_{n+1}, \v y_{n+1})\bigr). \end{align*} $$

$θ$

Name

Scheme

$1$

Euler method

$\v y_{n+1} = \v y_n + h\, \v f(t_n ,\v y_n)$

explicit

$1/2$

Trapezoidal rule

$\v y_{n+1} = \v y_n + \frac{1}{2}h\bigl(\v f(t_n ,\v y_n) + \v f(t_{n+1}, \v y_{n+1})\bigr)$

implicit

$0$

Backward Euler

$\v y_{n+1} = \v y_n + h\, \v f(t_{n+1}, \v y_{n+1})$

implicit

For $θ\in [0,1)$, the method is implicit: we need to solve an equation for $\v y_{n+1}$ (by e.g. fixed point iteration, Newton-Raphson, modified Newton-Raphson etc).

Proposition (order of theta methods) open_in_new

A theta method has order

  • 2 if $θ=1/2$ (the trapezoidal rule); or

  • 1 otherwise.

Proof

Multistep methods open_in_new
Multistep method

For an initial value problem, an $s$-step method use $\v y_n, \v y_{n+1}, \ldots, \v y_{n+s-1}$ to find $\v y_{n+s}$ by $$ \begin{align*} \sum_{m=0}^{s} a_m \v y_{n+m} = h\sum_{m=0}^{s} b_m \v f_{n+m} \end{align*} $$ where $\v f_{n+m} = \v f(t_{n+m}, \v y_{n+m})$.

  • We say it is homogeneous if it satisfies the normalisation condition $a_s = 1$.

  • It is explicit if $b_s = 0$, and implicit otherwise.

Define the polynomials $$ \begin{align*} ρ(w) = \sum_{m=0}^{s} a_m w^m, \qquad σ(w) = \sum_{m=0}^{s} b_m w^m. \end{align*} $$

Theorem (order of multistep method) open_in_new

The following are equivalent conditions for a multistep method to have order $p\geq 1$:

  1. its coefficients satisfy $$ \begin{align*} \sum_{m=0}^{s} a_m ={}& 0, \\ \sum_{m=0}^{s} m^k a_m ={}& k \sum_{m=0}^{s} m^{k-1} b_m, \qquad \forall k=1,2,\ldots,p; \end{align*} $$

  2. it is exact on $\mathcal{P}_p$: $$ \begin{align*} \sum_{m=0}^{s} a_m Q(t_{n+m}) = h\sum_{m=0}^{s} b_m Q'(t_{n+m}) \qquad \forall Q\in \mathcal{P}_p; \end{align*} $$

  3. the associated polynomials satisfy $$ \begin{align*} ρ(e^{z}) - zσ(e^{z}) = O(z^{p+1}), \qquad \text{as } z\to 0 \end{align*} $$ or equivalently (with the substitution $w=e^z$ and noting $\log w = O(|w-1|)$) $$ \begin{align*} \frac{ρ(w)}{\log w} = σ(w) + O(|w-1|^{p}), \qquad \text{as }w\to 1. \end{align*} $$

Proof

Theorem (Dahlquist equivalence theorem) open_in_new

A multistep method is convergent iff

  • it is of order $p\geq 1$; and

  • the polynomial $ρ$ satisfies the root condition, i.e. all complex roots of $ρ$ lie in $|z|\leq 1$ and all roots with modulus 1 are simple.

Constructing multistep methods with maximum order open_in_new

To construct an $s$-step method, we can take some $ρ\in \mathcal{P}_s$ such that $ρ(1) = 0$ and $ρ$ satisfies the root condition. Then we can determine $σ$ by expanding $$ \begin{align*} \frac{ρ(w)}{\log w} = σ(w) + O(|w-1|^p). \end{align*} $$

  • For an implicit method, we allow $σ\in \mathcal{P}_s$, so we obtain an order of $p=s+1$.

  • For an explicit method, we allow $σ\in \mathcal{P}_{s-1}$, so we obtain an order of $p=s$.

Adams methods open_in_new

The choice $ρ(w)$ $= w^s - w^{s-1} = w^{s-1}(w-1)$ corresponds to Adams methods.

  • Adams-Bashforth methods are explicit, and has order $p=s$.

  • Adams-Moulton methods are implicit, and has order $p=s+1$.

Proposition (coefficients of Adams methods as integrals of polynomials) open_in_new

The coefficients $b_m$ in an $s$-step Adams method are given by $$ \begin{align*} b_m = \int_{s-1}^{s} l_m(t) \d t \end{align*} $$ where $l_m(t) = ω(t)/(t-m)ω'(m)$ are the Lagrange fundamental polynomials:

  • for an Adams-Bashforth (explicit) method, the nodes are $0,1,\ldots,s$, i.e. $ω(t) = \prod_{m=0}^{s} (t-m)$;

  • for an Adams-Moulton (implicit) method, the nodes are $0,1,\ldots,s-1$, i.e. $ω(t) = \prod_{m=0}^{s-1} (t-m)$.

Proof

Example (2-step Adams methods)

Backward differentiation formula open_in_new

We can construct an implicit $s$-step, $s$-order method by taking $σ(w)$ $= b_s w^s$ and normalising $b_s = 1$.

Proposition (coefficients of the backward differentiation formula) open_in_new

In the $s$-step backward differentiation formula, the coefficients are given by $$ \begin{align*} ρ(w) ={}& \sum_{k=1}^{s} \frac{1}{k}w^{s-k} (w-1)^k \in \mathcal{P}_s, \\ \end{align*} $$ or equivalently $$ \begin{align*} a_s ={}& \sum_{k=1}^{s} \frac{1}{k}, \\ a_m ={}& \frac{(-1)^{s-m}}{s-m}\pmat{s \\ m}. \end{align*} $$

Derivation

Higher order multistep methods open_in_new

(Non-examinable)

There are no $s$-step method of order $2s+1$ (derivation), but there exists unique implicit method of order $2s$ and explicit method of order $2s-1$.

However:

Theorem (first Dahlquist barrier) open_in_new

If an $s$-step method is convergent (i.e. the root condition is satisfied), then

  • $p\leq s$ for an explicit method (achieved by Adams-Bashforth);

  • $p\leq s+1$ for an implicit method when $s$ is odd (achieved by Adams-Moulton);

  • $p\leq s+2$ for an implicit method when $s$ is even (achieved by $ρ(w) = w^s - 1$).

Runge-Kutta methods open_in_new
Runge-Kutta methods

For an initial value problem, an $s$-stage explicit Runge-Kutta method has the form $$ \begin{align*} \v k_1 ={}& \v f(t_n, \v y_n), && c_1 = 0\\ \v k_2 ={}& \v f(t_n + c_2 h, \v y_n + h(a_{21} \v k_1)), &&c_2 = a_{21} \\ \v k_3 ={}& \v f(t_n + c_3 h, \v y_n + h(a_{31} \v k_1 + a_{32} \v k_2)), &&c_3 = a_{31} + a_{32} \\ \vdots \\ \v k_s ={}& \v f\Bigl(t_n + c_s h, \v y_n + h \sum_{j=1}^{s-1} a_{sj} \v k_j\Bigr), && c_s = \sum_{j=1}^{s-1} a_{sj} \\ \v y_{n+1} ={}& \v y_n + h \sum_{i=1}^{s} b_i \v k_i, && 1 = \sum_{i=1}^{s} b_i. \end{align*} $$

A general Runge-Kutta method is $$ \begin{align*} \v k_i ={}& \v f(t_n + c_ih, \v y_n + h\sum_{j=1}^{s} a_{ij} \v k_j), &&c_i = \sum_{j=1}^{s} a_{ij}, &&i=1,2,\ldots,s, \\ \v y_{n+1} ={}& \v y_n + h \sum_{i=1}^{s} b_i \v k_i, &&1 = \sum_{i=1}^{s} b_i. \end{align*} $$ which is explicit if $a_{ij} \leq 0$ for all $i\leq j$ and implicit otherwise.

Motivation of Runge-Kutta methods

Example (order of explicit two-stage Runge-Kutta)

Example (order of implicit two-stage Runge-Kutta)

Theorem (collocation at zeros of orthogonal polynomial) open_in_new

Suppose $\prod_{i=1}^{s} (t-c_i)$ is orthogonal on the interval $[0,1]$ to all polynomials of degree $r-1\leq s-1$. Let $l_i$ be the fundamental Lagrange polynomials of degree $s-1$ for the knots $c_i$, and $$ \begin{align*} a_{ij} = \int_{0}^{c_i} l_j(t) \d t, \qquad b_i = \int_{0}^{1} l_i(t) \d t. \end{align*} $$ Then the (highly implicit) $s$-stage Runge-Kutta method with these parameters is of order $s+r$.

  • The highest order of an $s$-stage implicit Runge-Kutta method (known as the Guass-Legendre Runge-Kutta method) is $2s$, corresponding to the collocation at zeros of the Legendre polynomial.

Stiff ODEs open_in_new

An ODE is said to be stiff if we have to depress the step size $h$ for stability well beyond the need of accuracy.

Example (stiff ODE)

Definition (linear stability domain, A-stable) open_in_new

Suppose a numerical method applied to $y' = λy, y(0)=1$ produces $(y_n^{(h)})_n$. The linear stability domain is $$ \begin{align*} \mathcal{D} = \sb{λh \in \C}{y_n^{(h)}\to 0 \text{ as }n\to \infty}. \end{align*} $$

We say the method is $A$-stable if the left-half plane $\C^- = \sb{z\in \C}{\Re z < 0} \subseteq D$.

Example (linear stability domain of theta methods)

Stability of multistep methods open_in_new

The linear stability domain of a multistep method $\sum_{m=0}^{s} a_m \v y_{n+m} = h \sum_{m=0}^{s} b_m \v f_{n+m}$ contains $z = λh$ iff the solution to the recurrence equation $$ \begin{align*} \sum_{m=0}^{s} a_m y_{n+m} = z \sum_{m=0}^{s} b_m y_{n+m} \end{align*} $$ tends to 0 as $n\to \infty$. This is equivalent to the polynomial $$ \begin{align*} p_z(x) := ρ(x) - z\,σ(x) = \sum_{m=0}^{s} a_m x^m - z \sum_{m=0}^{s} b_mx^m \end{align*} $$ having the moduli of all roots $<1$.

Tricks to finding the linear stability domain:

  • $z\in \partial D$ iff $p_z(x) = 0$ for some $|x|=1$. So if we write $x=e^{it}$ ($t\in \R$), then $$ \begin{align*} z(t) = \frac{ρ(e^{it})}{σ(e^{it})}, \end{align*} $$ defines the curve $\partial D$.

  • If we're looking for the real stability interval $I = \mathcal{D}\cap \R$, the boundary is given by $p_{z_1}(1) = 0 \iff z_1 = ρ(1)/σ(1)$ and $p_{z_2}(-1) = 0 \iff z_2 = ρ(-1)/σ(-1)$. Moreover if the method has order $\geq 1$, then $ρ(1) = 0$, so it is highly likely that $$ \begin{align*} I = \Bigl(\frac{ρ(-1)}{σ(-1)}, 0\Bigr). \end{align*} $$

Example (finding real stability interval)

Theorem (second Dahlquist barrier) open_in_new

No multistep method of order $p\geq 3$ can be $A$-stable.

Still, some high-order multistep methods are of good use, e.g. BDF methods of order $\leq 6$ have a wedge about $(-\infty, 0)$. We say these are $A_0$-stable.

Stability of Runge-Kutta methods open_in_new

Lemma (no explicit Runge-Kutta method can be A-stable) open_in_new

However, implicit Runge-Kutta methods may be $A$-stable. (Example)

Numerical implementation of methods for ODEs open_in_new

Milne device open_in_new

For multistep methods, we use a pair of methods of the same order $p$:

  • the predictor: explicit, lower computational cost; and

  • the corrector: implicit, higher accuracy.

The predictor provides a good initial guess in the solution of the implicit corrector equations, and allows for error estimation:

If the local truncation errors are $$ \begin{align*} \v y(t_{n+1}) - \v y_{n+1}^{\text{P}} ={}& c_{\text{P}} h^{p+1} \v y^{(p+1)}(t_n) + O(h^{p+2}), \\ \v y(t_{n+1}) - \v y_{n+1}^{\text{C}} ={}& c_{\text{C}} h^{p+1} \v y^{(p+1)}(t_n) + O(h^{p+2}), \end{align*} $$ then we estimate the error as $$ \begin{align*} \v y(t_{n+1}) - \v y_{n+1}^\text{C} \approx -\frac{c_{\text{C}}}{c_\text{P} - c_\text{C}}(\v y_{n+1}^\text{P} - \v y_{n+1}^{\text{C}}). \end{align*} $$

Embedded Runge-Kutta method open_in_new

Runge-Kutta methods do not have a single error constant.

Instead we use two (typically explicit) Runge-Kutta methods:

  1. one of $s$ stages and order $p$; and

  2. one of $s+l$ stages and order $p+1$,

with the first $s$ stages identical to reduce computational cost. Then we have an estimate of the lower order method $$ \begin{align*} \v y(t_{n+1}) - \v y_{n+1}^{[1]}\approx \v y_{n+1}^{[2]} - \v y_{n+1}^{[1]}. \end{align*} $$

For example $$ \begin{align*} k_1 ={}& f(t_n, y_n), \\ k_2 ={}& f(t_n + \frac{1}{2}h, y_n + \frac{1}{2}hk_1), \\ k_3 ={}& f(t_n + h, y_n - hk_1 + 2hk_2), \\ y_{n+1}^{[1]} ={}& y_n + hk_2, \\ y_{n+1}^{[2]} ={}& y_n + \frac{1}{6}h(k_1 + 4k_2 + k_3). \end{align*} $$ $y_{n+1}^{[1]}$ has order $2$ accuracy, and $y_{n+1}^{[2]}$ has order $3$ accuracy.

Zadunaisky device open_in_new

Suppose the ODE $\v y'(t) = \v f(t, \v y)$ is solved by an arbitrary numerical method of order $p$, and we have stored some past values $\v y_n, \v y_{n-1}, \ldots, \v y_{n-p}$.

Let $\v q\in \mathcal{P}_p$ be a polynomial that interpolates $\v q(t_i) = \v y_i$ for $i=n,\ldots,n-p$. Then $\v q(t) - \v y(t) = O(h^{p+1})$. Note $\v q$ solves a new ODE $$ \begin{align*} \v z' = \v f(t,\v z) + \underbrace{\v q' - \v f(t, \v q)}_{\text{small}}, \tag{*} \end{align*} $$ which slightly differs from our original ODE by a term $\v q' - \v y'$ which we expect to be small.

Now apply the same method to produce $\v z_{n+1}$. The Zadunaisky device estimates the local truncation error of $\v y_{n+1}$ as $$ \begin{align*} \v y(t_{n+1}) - \v y_{n+1} \approx \v q(t_{n+1}) - \v z_{n+1}. \end{align*} $$