I encourage you to play around with the juptyer notebook for this lecture - you can copy the code with the this notebook button on the side of this page.
Warning
These notes are mainly a record of what we discussed and are not a substitute for attending the lectures and reading books! If anything is unclear/wrong, let me know and I will update the notes.
Tip
This lecture is mostly based on Burden, Faires, and Burden (2015) section 5.4 & 5.5
5.1 Recap
Recall that we are considering IVPs: seek u :[0,T] \to \mathbb R such that
We will suppose that f is continuous on [0,T] \times \mathbb R and Lipschitz in the second argument and so the problem is well-posed and there exists a unique solution to (\text{IVP}). Recall one-step methods:
where t_j = j \frac{T}{n} = j h define the mesh. We saw last week that, if the local truncation error is \tau_{j+1} = O(h^p) as h\to 0 (i.e. if the method is consistent with order of accuracy p) and |\frac{\partial \phi}{\partial u}| \leq L on [0,T] \times \mathbb R, then we have the error bound
Taylor methods: use the expansion u(t_{j+1}) = u(t_j) + h u'(t_j) + \frac{h^2}{2} u''(t_j) + \dots and use the fact that u'(t) = f(t, u(t)) to evaluate the higher derivatives:
in \alpha, \beta and found that, under the choice \alpha := \frac{h}{2} and \beta := \frac{h}{2} f(t_j, u_j), the local truncation error is \kappa_{j+1}(h) = O(h^2). This method is known as the midpoint method:
Exercise 5.1 Write down the Butcher tableau for (i) Euler’s method, (ii) Midpoint method (also known as improved Euler’s method), and the following 2-stage, order 2 methods:
functionRK( u0, f, T, n, A, b, c ) h = T/n t =0:h:T u =fill(float(u0), n+1) s, =size(A) s = s+1 k =fill(float(u0), s)for j =1:n k[1] = h *f( t[j], u[j] )for i =1:s-1 k[i+1] = h *f( t[j] + h * c[i], u[j] +sum( A[i,ℓ] * k[ℓ] for ℓ ∈1:i ) )end u[j+1] = u[j] +sum( b[ℓ] * k[ℓ] for ℓ ∈1:s )endreturn uend
We want to compare the error made with the computational cost involved (rather than n).
Euler:
\begin{align}
u_{j+1} = u_j + h f( t_j, u_j)
\end{align}
General 2 stage RK:
\begin{align}
u_{j+1} = u_j &+ b_1 h f(t_j, u_j) \nonumber\\
&+ b_2 h f\big( t_j + c_1 h, u_j + a_{11} h f(t_j, u_j) \big)
\end{align}
Exercise 5.2 How many function evaluations are needed to implement these methods? What about a general s-stage RK method?
Example 5.4 We return to Example 5.2 and plot the errors against the function evaluations:
A general s-stage RK method requires s function evaluations.
We have seen that Euler (1-stage RK method) has order 1,
We have seen many (we have written them all down!) 2-stage, order 2 methods,
RK4 is a 4-stage, order 4 method (there are many others),
However, if s\geq 5, the best possible order of accuracy is p < s.
(For 5 \leq s \leq 7 the maximal order of accuracy is s-1 and, for 8 \leq s \leq 9 the maximal order of accuracy is s-2 and, for s \geq 10, the maximal order of accuracy is s-3.)
5.3 Adaptive RK methods
Here, we look at example 6.1.8 from Driscoll and Braun (2018):
Example 5.5 A model for the velocity v(t) of a skydiver at time t is given by
where g \approx 9.81 \text{m/s}^2 is the acceleration due to gravity, m is the mass of the skydiver, and k(t) models the effects of air-resistance. A simple model for k is given as a step function: